Skip to content

Documentation / @agentick/mcp / MCPHandlerContext

Interface: MCPHandlerContext

Defined in: protocol/types.ts:316

Context passed to all MCP handlers (tools, resources, prompts). Contains the enriched request context (user, tenantId, roles, metadata) and the raw SDK extra for low-level needs.

Extended by

Properties

elicit?

optional elicit: ElicitAPI

Defined in: protocol/types.ts:360

Sugar surface for elicitation/create — pause mid-tool to ask the user for structured input (form mode) or to walk an external URL flow (URL mode). Undefined when the client did not advertise any elicitation sub-capability.


extra

extra: MCPHandlerExtra

Defined in: protocol/types.ts:320

Raw SDK handler extra — sessionId, requestId, signal, authInfo.


request

request: MCPRequestContext

Defined in: protocol/types.ts:318

Authenticated request context — user identity, tenant, roles, metadata.


roots

roots: RootsAPI

Defined in: protocol/types.ts:344

Sugar surface for roots/list — fetch the client's declared filesystem roots and check whether paths are within them. Always present; returns an empty list when the client did not advertise the roots capability. Permissive defaults: assertWithin and isWithin no-op (pass) when no roots are declared.

Per MCP spec 2025-11-25, root URIs MUST be file://. Non-file schemes are filtered out defensively.


sample?

optional sample: SampleAPI

Defined in: protocol/types.ts:352

Sugar surface for sampling/createMessage — ask the client to run an LLM completion on the server's behalf. Undefined when the client did not advertise the sampling capability. Use ctx.sample?.text(...) or guard explicitly: if (!ctx.sample) throw ....


sendProgress()?

optional sendProgress: (progress, total?, message?) => Promise<void>

Defined in: protocol/types.ts:333

Send a progress notification to the client. Only available when the client supplied a progressToken in _meta. Undefined otherwise.

Parameters

progress

number

Current progress value

total?

number

Total progress value (optional)

message?

string

Human-readable progress message (optional)

Returns

Promise<void>


sessionId

sessionId: string

Defined in: protocol/types.ts:322

Shortcut: the session ID for this request.


signal

signal: AbortSignal

Defined in: protocol/types.ts:324

AbortSignal — aborted when the client sends notifications/cancelled.

Released under the ISC License.