ExperimentalReadonly ExperimentalabortAbortSignal that triggers when the request is cancelled.
MCP Protocol: Triggered when client sends notifications/cancelled
with a matching requestId. This is the SDK's native AbortSignal,
created per-request and managed by the MCP protocol layer.
Tools SHOULD check this signal periodically during long-running operations and abort gracefully when triggered.
Optional Readonly ExperimentalauthAuthentication context for the current request.
Available when auth middleware is configured on the server.
Contains the verified token info (authInfo) and optional
consumer-provided data (extra) from the onAuthenticated hook.
undefined when no auth is configured (anonymous access).
ReadonlyauthInfo: AuthInfoVerified auth info from the Bearer token
Optional Readonlyextra?: Record<string, unknown>Consumer-provided extra data from onAuthenticated hook
Optional Readonly ExperimentalcreateRequest LLM sampling from the client.
MCP Protocol: Sends a sampling/createMessage request to the client,
which returns an LLM-generated response. This enables server-initiated
LLM interactions (e.g., asking the LLM to summarize data for the user).
Availability: Only present when the client declares sampling capability
AND the session is stateful. In stateless mode or when the client doesn't
support sampling, this will be undefined.
Sampling request parameters (messages, model preferences, etc.)
The LLM's response with model info and stop reason
Optional Readonly ExperimentalelicitRequest user input via the client's elicitation UI.
MCP Protocol: Sends an elicitation/create request to the client,
which presents a form or URL to the user and returns their input.
Availability: Only present when the client declares elicitation capability
AND the session is stateful. In stateless mode or when the client doesn't
support elicitation, this will be undefined.
Elicitation parameters (form schema or URL)
User's response (accept/decline/cancel with optional content)
if (context.elicitInput) {
const result = await context.elicitInput({
message: 'Please confirm the deployment target',
requestedSchema: {
type: 'object',
properties: {
confirmed: { type: 'boolean', title: 'Confirm deployment' },
},
},
});
if (result.action === 'accept') {
// result.content contains the form values
}
}
Optional Readonly ExperimentallistList the client's root URIs.
MCP Protocol: Sends a roots/list request to the client, which returns
the set of root URIs (workspace folders, project roots, etc.) the client
has made available to the server.
Availability: Only present when the client declares roots capability
AND the session is stateful. In stateless mode or when the client doesn't
support roots, this will be undefined.
Array of root objects with URI and optional name
Optional Readonly ExperimentalreportReports progress for long-running operations.
MCP Protocol: Sends notifications/progress to the client.
Only available if the MCP client requested progress tracking by
including _meta.progressToken in the tools/call request.
If not requested, this will be undefined.
The framework applies rate-limiting (100ms minimum interval) to prevent flooding the client with notifications.
Readonly ExperimentalrequestThe JSON-RPC request ID for this tool call.
Useful for logging, tracing, and correlating requests. This is the real protocol-level request ID from the MCP client.
Optional Readonly ExperimentalsessionThe session ID from the transport, if available.
Identifies which MCP client session invoked this tool. Available in HTTP transport mode (Streamable HTTP, SSE), not in stdio.
Readonly ExperimentalstatelessWhether this tool is executing in stateless mode.
In stateless mode, the server creates a fresh session per request — no persistent state is maintained between calls.
Per-request features (work normally in stateless):
Cross-request features (unavailable in stateless by design):
notifications/cancelled) — needs routing to original sessionsampling/createMessage) — server→client requires persistent channelelicitation/create) — server→client requires persistent channelroots/list) — server→client requires persistent channelTools MAY use this flag to adapt behavior for cross-request limitations, e.g., avoiding operations that rely on server-initiated client requests.
Readonly ExperimentaltaskThe task ID being queried
Readonly ExperimentaltaskRequest-scoped task store for retrieving task status and results.
Context passed to
taskHandler.getTask()andtaskHandler.getTaskResult().Extends the base tool context with the task ID of the task being queried and access to the task store for retrieving task status and results.
MCP Tasks is an experimental SDK feature
Example