Type Alias: CreateGatedToolRegistrarOptions
CreateGatedToolRegistrarOptions =
object
Defined in: createGatedToolRegistrar.ts:49
Options for createGatedToolRegistrar.
Properties
buildContext?
optionalbuildContext?: (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
| Parameter | Type |
|---|---|
ctx | ToolCallContext |
Returns
Record<string, unknown>
enforceScope?
optionalenforceScope?: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?
optionalgates?: (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
| Parameter | Type |
|---|---|
ctx | ToolCallContext |
Returns
void | Promise<void>
notFoundMessage?
optionalnotFoundMessage?: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?
optionalonError?: (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
| Parameter | Type |
|---|---|
error | unknown |
ctx | ToolCallContext |
Returns
void | Promise<void>
resolveIdentity?
optionalresolveIdentity?: () =>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
server
server:
McpServer
Defined in: createGatedToolRegistrar.ts:51
The MCP server instance to register tools on.