Skip to main content

Type Alias: CreateGatedToolRegistrarOptions

CreateGatedToolRegistrarOptions = object

Defined in: createGatedToolRegistrar.ts:49

Options for createGatedToolRegistrar.

Properties

buildContext?

optional buildContext?: (ctx) => Record<string, unknown>

Defined in: createGatedToolRegistrar.ts:83

Called once per invocation to produce extra key-value pairs that are merged into the handler args. Receives the full ToolCallContext so context can vary by identity or by call args.

Parameters

ParameterType
ctxToolCallContext

Returns

Record<string, unknown>


enforceScope?

optional enforceScope?: boolean

Defined in: createGatedToolRegistrar.ts:71

When true (default), checks def.requiredScope against identity.scopes and returns an isError result when the scope is absent. Set to false to skip the scope check (e.g. when all scopes are enforced by gates).


gates?

optional gates?: (ctx) => void | Promise<void>[]

Defined in: createGatedToolRegistrar.ts:65

Global authorization gates run after the scope check, in order, before per-tool gates. Each receives the full ToolCallContext — both identity and the validated call args — so gate predicates may be conditional on either. Throw to reject the call; return (or resolve) to continue. Gates own their own error handling — onError covers the tool handler only.

Parameters

ParameterType
ctxToolCallContext

Returns

void | Promise<void>


notFoundMessage?

optional notFoundMessage?: string

Defined in: createGatedToolRegistrar.ts:88

Message returned as an isError result when the handler resolves to null or undefined. Defaults to "Not found".


onError?

optional onError?: (error, ctx) => void | Promise<void>

Defined in: createGatedToolRegistrar.ts:77

Called when the tool handler throws. Use for error reporting/telemetry. The error is always rethrown after this hook completes. Note: scope-check failures and gate rejections do not trigger onError.

Parameters

ParameterType
errorunknown
ctxToolCallContext

Returns

void | Promise<void>


resolveIdentity?

optional resolveIdentity?: () => ToolIdentity

Defined in: createGatedToolRegistrar.ts:56

Called once per tool invocation to resolve the caller's identity. Defaults to getIdentity() from the request context.

Returns

ToolIdentity


server

server: McpServer

Defined in: createGatedToolRegistrar.ts:51

The MCP server instance to register tools on.