From 2710b3148c709280f0289b428672836ec1356611 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 23 Dec 2025 04:21:25 +0000 Subject: [PATCH] chore: update spec.types.ts from upstream --- src/spec.types.ts | 858 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 770 insertions(+), 88 deletions(-) diff --git a/src/spec.types.ts b/src/spec.types.ts index c58636350..07a1cceff 100644 --- a/src/spec.types.ts +++ b/src/spec.types.ts @@ -3,7 +3,7 @@ * * Source: https://github.com/modelcontextprotocol/modelcontextprotocol * Pulled from: https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/main/schema/draft/schema.ts - * Last updated from commit: 11ad2a720d8e2f54881235f734121db0bda39052 + * Last updated from commit: 35fa160caf287a9c48696e3ae452c0645c713669 * * DO NOT EDIT THIS FILE MANUALLY. Changes will be overwritten by automated updates. * To update this file, run: npm run fetch:spec-types @@ -12,31 +12,52 @@ /** * Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent. * - * @internal + * @category JSON-RPC */ export type JSONRPCMessage = | JSONRPCRequest | JSONRPCNotification - | JSONRPCResponse - | JSONRPCError; + | JSONRPCResponse; /** @internal */ -export const LATEST_PROTOCOL_VERSION = "DRAFT-2025-v3"; +export const LATEST_PROTOCOL_VERSION = "DRAFT-2026-v1"; /** @internal */ export const JSONRPC_VERSION = "2.0"; /** * A progress token, used to associate progress notifications with the original request. + * + * @category Common Types */ export type ProgressToken = string | number; /** * An opaque token used to represent a cursor for pagination. + * + * @category Common Types */ export type Cursor = string; +/** + * Common params for any task-augmented request. + * + * @internal + */ +export interface TaskAugmentedRequestParams extends RequestParams { + /** + * If specified, the caller is requesting task-augmented execution for this request. + * The request will return a CreateTaskResult immediately, and the actual result can be + * retrieved later via tasks/result. + * + * Task augmentation is subject to capability negotiation - receivers MUST declare support + * for task augmentation of specific request types in their capabilities. + */ + task?: TaskMetadata; +} /** * Common params for any request. + * + * @internal */ export interface RequestParams { /** @@ -75,6 +96,9 @@ export interface Notification { params?: { [key: string]: any }; } +/** + * @category Common Types + */ export interface Result { /** * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage. @@ -83,6 +107,9 @@ export interface Result { [key: string]: unknown; } +/** + * @category Common Types + */ export interface Error { /** * The error type that occurred. @@ -100,11 +127,15 @@ export interface Error { /** * A uniquely identifying ID for a request in JSON-RPC. + * + * @category Common Types */ export type RequestId = string | number; /** * A request that expects a response. + * + * @category JSON-RPC */ export interface JSONRPCRequest extends Request { jsonrpc: typeof JSONRPC_VERSION; @@ -113,6 +144,8 @@ export interface JSONRPCRequest extends Request { /** * A notification which does not expect a response. + * + * @category JSON-RPC */ export interface JSONRPCNotification extends Notification { jsonrpc: typeof JSONRPC_VERSION; @@ -120,37 +153,63 @@ export interface JSONRPCNotification extends Notification { /** * A successful (non-error) response to a request. + * + * @category JSON-RPC */ -export interface JSONRPCResponse { +export interface JSONRPCResultResponse { jsonrpc: typeof JSONRPC_VERSION; id: RequestId; result: Result; } +/** + * A response to a request that indicates an error occurred. + * + * @category JSON-RPC + */ +export interface JSONRPCErrorResponse { + jsonrpc: typeof JSONRPC_VERSION; + id?: RequestId; + error: Error; +} + +/** + * A response to a request, containing either the result or error. + */ +export type JSONRPCResponse = JSONRPCResultResponse | JSONRPCErrorResponse; + // Standard JSON-RPC error codes -/** @internal */ export const PARSE_ERROR = -32700; -/** @internal */ export const INVALID_REQUEST = -32600; -/** @internal */ export const METHOD_NOT_FOUND = -32601; -/** @internal */ export const INVALID_PARAMS = -32602; -/** @internal */ export const INTERNAL_ERROR = -32603; +// Implementation-specific JSON-RPC error codes [-32000, -32099] +/** @internal */ +export const URL_ELICITATION_REQUIRED = -32042; + /** - * A response to a request that indicates an error occurred. + * An error response that indicates that the server requires the client to provide additional information via an elicitation request. + * + * @internal */ -export interface JSONRPCError { - jsonrpc: typeof JSONRPC_VERSION; - id: RequestId; - error: Error; +export interface URLElicitationRequiredError + extends Omit { + error: Error & { + code: typeof URL_ELICITATION_REQUIRED; + data: { + elicitations: ElicitRequestURLParams[]; + [key: string]: unknown; + }; + }; } /* Empty result */ /** * A response that indicates success but carries no data. + * + * @category Common Types */ export type EmptyResult = Result; @@ -158,15 +217,17 @@ export type EmptyResult = Result; /** * Parameters for a `notifications/cancelled` notification. * - * @category notifications/cancelled + * @category `notifications/cancelled` */ export interface CancelledNotificationParams extends NotificationParams { /** * The ID of the request to cancel. * * This MUST correspond to the ID of a request previously issued in the same direction. + * This MUST be provided for cancelling non-task requests. + * This MUST NOT be used for cancelling tasks (use the `tasks/cancel` request instead). */ - requestId: RequestId; + requestId?: RequestId; /** * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. @@ -183,7 +244,9 @@ export interface CancelledNotificationParams extends NotificationParams { * * A client MUST NOT attempt to cancel its `initialize` request. * - * @category notifications/cancelled + * For task cancellation, use the `tasks/cancel` request instead of this notification. + * + * @category `notifications/cancelled` */ export interface CancelledNotification extends JSONRPCNotification { method: "notifications/cancelled"; @@ -194,7 +257,7 @@ export interface CancelledNotification extends JSONRPCNotification { /** * Parameters for an `initialize` request. * - * @category initialize + * @category `initialize` */ export interface InitializeRequestParams extends RequestParams { /** @@ -208,7 +271,7 @@ export interface InitializeRequestParams extends RequestParams { /** * This request is sent from the client to the server when it first connects, asking it to begin initialization. * - * @category initialize + * @category `initialize` */ export interface InitializeRequest extends JSONRPCRequest { method: "initialize"; @@ -218,7 +281,7 @@ export interface InitializeRequest extends JSONRPCRequest { /** * After receiving an initialize request from the client, the server sends this response. * - * @category initialize + * @category `initialize` */ export interface InitializeResult extends Result { /** @@ -239,7 +302,7 @@ export interface InitializeResult extends Result { /** * This notification is sent from the client to the server after initialization has finished. * - * @category notifications/initialized + * @category `notifications/initialized` */ export interface InitializedNotification extends JSONRPCNotification { method: "notifications/initialized"; @@ -248,6 +311,8 @@ export interface InitializedNotification extends JSONRPCNotification { /** * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities. + * + * @category `initialize` */ export interface ClientCapabilities { /** @@ -266,15 +331,64 @@ export interface ClientCapabilities { /** * Present if the client supports sampling from an LLM. */ - sampling?: object; + sampling?: { + /** + * Whether the client supports context inclusion via includeContext parameter. + * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it). + */ + context?: object; + /** + * Whether the client supports tool use via tools and toolChoice parameters. + */ + tools?: object; + }; /** * Present if the client supports elicitation from the server. */ - elicitation?: object; + elicitation?: { form?: object; url?: object }; + + /** + * Present if the client supports task-augmented requests. + */ + tasks?: { + /** + * Whether this client supports tasks/list. + */ + list?: object; + /** + * Whether this client supports tasks/cancel. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for sampling-related requests. + */ + sampling?: { + /** + * Whether the client supports task-augmented sampling/createMessage requests. + */ + createMessage?: object; + }; + /** + * Task support for elicitation-related requests. + */ + elicitation?: { + /** + * Whether the client supports task-augmented elicitation/create requests. + */ + create?: object; + }; + }; + }; } /** * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities. + * + * @category `initialize` */ export interface ServerCapabilities { /** @@ -320,10 +434,39 @@ export interface ServerCapabilities { */ listChanged?: boolean; }; + /** + * Present if the server supports task-augmented requests. + */ + tasks?: { + /** + * Whether this server supports tasks/list. + */ + list?: object; + /** + * Whether this server supports tasks/cancel. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for tool-related requests. + */ + tools?: { + /** + * Whether the server supports task-augmented tools/call requests. + */ + call?: object; + }; + }; + }; } /** * An optionally-sized icon that can be displayed in a user interface. + * + * @category Common Types */ export interface Icon { /** @@ -407,11 +550,22 @@ export interface BaseMetadata { } /** - * Describes the MCP implementation + * Describes the MCP implementation. + * + * @category `initialize` */ export interface Implementation extends BaseMetadata, Icons { version: string; + /** + * An optional human-readable description of what this implementation does. + * + * This can be used by clients or servers to provide context about their purpose + * and capabilities. For example, a server might describe the types of resources + * or tools it provides, while a client might describe its intended use case. + */ + description?: string; + /** * An optional URL of the website for this implementation. * @@ -424,7 +578,7 @@ export interface Implementation extends BaseMetadata, Icons { /** * A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected. * - * @category ping + * @category `ping` */ export interface PingRequest extends JSONRPCRequest { method: "ping"; @@ -436,7 +590,7 @@ export interface PingRequest extends JSONRPCRequest { /** * Parameters for a `notifications/progress` notification. * - * @category notifications/progress + * @category `notifications/progress` */ export interface ProgressNotificationParams extends NotificationParams { /** @@ -464,7 +618,7 @@ export interface ProgressNotificationParams extends NotificationParams { /** * An out-of-band notification used to inform the receiver of a progress update for a long-running request. * - * @category notifications/progress + * @category `notifications/progress` */ export interface ProgressNotification extends JSONRPCNotification { method: "notifications/progress"; @@ -474,6 +628,8 @@ export interface ProgressNotification extends JSONRPCNotification { /* Pagination */ /** * Common parameters for paginated requests. + * + * @internal */ export interface PaginatedRequestParams extends RequestParams { /** @@ -501,7 +657,7 @@ export interface PaginatedResult extends Result { /** * Sent from the client to request a list of resources the server has. * - * @category resources/list + * @category `resources/list` */ export interface ListResourcesRequest extends PaginatedRequest { method: "resources/list"; @@ -510,7 +666,7 @@ export interface ListResourcesRequest extends PaginatedRequest { /** * The server's response to a resources/list request from the client. * - * @category resources/list + * @category `resources/list` */ export interface ListResourcesResult extends PaginatedResult { resources: Resource[]; @@ -519,7 +675,7 @@ export interface ListResourcesResult extends PaginatedResult { /** * Sent from the client to request a list of resource templates the server has. * - * @category resources/templates/list + * @category `resources/templates/list` */ export interface ListResourceTemplatesRequest extends PaginatedRequest { method: "resources/templates/list"; @@ -528,7 +684,7 @@ export interface ListResourceTemplatesRequest extends PaginatedRequest { /** * The server's response to a resources/templates/list request from the client. * - * @category resources/templates/list + * @category `resources/templates/list` */ export interface ListResourceTemplatesResult extends PaginatedResult { resourceTemplates: ResourceTemplate[]; @@ -551,7 +707,7 @@ export interface ResourceRequestParams extends RequestParams { /** * Parameters for a `resources/read` request. * - * @category resources/read + * @category `resources/read` */ // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface ReadResourceRequestParams extends ResourceRequestParams {} @@ -559,7 +715,7 @@ export interface ReadResourceRequestParams extends ResourceRequestParams {} /** * Sent from the client to the server, to read a specific resource URI. * - * @category resources/read + * @category `resources/read` */ export interface ReadResourceRequest extends JSONRPCRequest { method: "resources/read"; @@ -569,7 +725,7 @@ export interface ReadResourceRequest extends JSONRPCRequest { /** * The server's response to a resources/read request from the client. * - * @category resources/read + * @category `resources/read` */ export interface ReadResourceResult extends Result { contents: (TextResourceContents | BlobResourceContents)[]; @@ -578,7 +734,7 @@ export interface ReadResourceResult extends Result { /** * An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client. * - * @category notifications/resources/list_changed + * @category `notifications/resources/list_changed` */ export interface ResourceListChangedNotification extends JSONRPCNotification { method: "notifications/resources/list_changed"; @@ -588,7 +744,7 @@ export interface ResourceListChangedNotification extends JSONRPCNotification { /** * Parameters for a `resources/subscribe` request. * - * @category resources/subscribe + * @category `resources/subscribe` */ // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface SubscribeRequestParams extends ResourceRequestParams {} @@ -596,7 +752,7 @@ export interface SubscribeRequestParams extends ResourceRequestParams {} /** * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. * - * @category resources/subscribe + * @category `resources/subscribe` */ export interface SubscribeRequest extends JSONRPCRequest { method: "resources/subscribe"; @@ -606,7 +762,7 @@ export interface SubscribeRequest extends JSONRPCRequest { /** * Parameters for a `resources/unsubscribe` request. * - * @category resources/unsubscribe + * @category `resources/unsubscribe` */ // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface UnsubscribeRequestParams extends ResourceRequestParams {} @@ -614,7 +770,7 @@ export interface UnsubscribeRequestParams extends ResourceRequestParams {} /** * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. * - * @category resources/unsubscribe + * @category `resources/unsubscribe` */ export interface UnsubscribeRequest extends JSONRPCRequest { method: "resources/unsubscribe"; @@ -624,7 +780,7 @@ export interface UnsubscribeRequest extends JSONRPCRequest { /** * Parameters for a `notifications/resources/updated` notification. * - * @category notifications/resources/updated + * @category `notifications/resources/updated` */ export interface ResourceUpdatedNotificationParams extends NotificationParams { /** @@ -638,7 +794,7 @@ export interface ResourceUpdatedNotificationParams extends NotificationParams { /** * A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request. * - * @category notifications/resources/updated + * @category `notifications/resources/updated` */ export interface ResourceUpdatedNotification extends JSONRPCNotification { method: "notifications/resources/updated"; @@ -647,6 +803,8 @@ export interface ResourceUpdatedNotification extends JSONRPCNotification { /** * A known resource that the server is capable of reading. + * + * @category `resources/list` */ export interface Resource extends BaseMetadata, Icons { /** @@ -688,6 +846,8 @@ export interface Resource extends BaseMetadata, Icons { /** * A template description for resources available on the server. + * + * @category `resources/templates/list` */ export interface ResourceTemplate extends BaseMetadata, Icons { /** @@ -722,6 +882,8 @@ export interface ResourceTemplate extends BaseMetadata, Icons { /** * The contents of a specific resource or sub-resource. + * + * @internal */ export interface ResourceContents { /** @@ -741,6 +903,9 @@ export interface ResourceContents { _meta?: { [key: string]: unknown }; } +/** + * @category Content + */ export interface TextResourceContents extends ResourceContents { /** * The text of the item. This must only be set if the item can actually be represented as text (not binary data). @@ -748,6 +913,9 @@ export interface TextResourceContents extends ResourceContents { text: string; } +/** + * @category Content + */ export interface BlobResourceContents extends ResourceContents { /** * A base64-encoded string representing the binary data of the item. @@ -761,7 +929,7 @@ export interface BlobResourceContents extends ResourceContents { /** * Sent from the client to request a list of prompts and prompt templates the server has. * - * @category prompts/list + * @category `prompts/list` */ export interface ListPromptsRequest extends PaginatedRequest { method: "prompts/list"; @@ -770,7 +938,7 @@ export interface ListPromptsRequest extends PaginatedRequest { /** * The server's response to a prompts/list request from the client. * - * @category prompts/list + * @category `prompts/list` */ export interface ListPromptsResult extends PaginatedResult { prompts: Prompt[]; @@ -779,7 +947,7 @@ export interface ListPromptsResult extends PaginatedResult { /** * Parameters for a `prompts/get` request. * - * @category prompts/get + * @category `prompts/get` */ export interface GetPromptRequestParams extends RequestParams { /** @@ -795,7 +963,7 @@ export interface GetPromptRequestParams extends RequestParams { /** * Used by the client to get a prompt provided by the server. * - * @category prompts/get + * @category `prompts/get` */ export interface GetPromptRequest extends JSONRPCRequest { method: "prompts/get"; @@ -805,7 +973,7 @@ export interface GetPromptRequest extends JSONRPCRequest { /** * The server's response to a prompts/get request from the client. * - * @category prompts/get + * @category `prompts/get` */ export interface GetPromptResult extends Result { /** @@ -817,6 +985,8 @@ export interface GetPromptResult extends Result { /** * A prompt or prompt template that the server offers. + * + * @category `prompts/list` */ export interface Prompt extends BaseMetadata, Icons { /** @@ -837,6 +1007,8 @@ export interface Prompt extends BaseMetadata, Icons { /** * Describes an argument that a prompt can accept. + * + * @category `prompts/list` */ export interface PromptArgument extends BaseMetadata { /** @@ -851,6 +1023,8 @@ export interface PromptArgument extends BaseMetadata { /** * The sender or recipient of messages and data in a conversation. + * + * @category Common Types */ export type Role = "user" | "assistant"; @@ -859,6 +1033,8 @@ export type Role = "user" | "assistant"; * * This is similar to `SamplingMessage`, but also supports the embedding of * resources from the MCP server. + * + * @category `prompts/get` */ export interface PromptMessage { role: Role; @@ -869,6 +1045,8 @@ export interface PromptMessage { * A resource that the server is capable of reading, included in a prompt or tool call result. * * Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests. + * + * @category Content */ export interface ResourceLink extends Resource { type: "resource_link"; @@ -879,6 +1057,8 @@ export interface ResourceLink extends Resource { * * It is up to the client how best to render embedded resources for the benefit * of the LLM and/or the user. + * + * @category Content */ export interface EmbeddedResource { type: "resource"; @@ -897,7 +1077,7 @@ export interface EmbeddedResource { /** * An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client. * - * @category notifications/prompts/list_changed + * @category `notifications/prompts/list_changed` */ export interface PromptListChangedNotification extends JSONRPCNotification { method: "notifications/prompts/list_changed"; @@ -908,7 +1088,7 @@ export interface PromptListChangedNotification extends JSONRPCNotification { /** * Sent from the client to request a list of tools the server has. * - * @category tools/list + * @category `tools/list` */ export interface ListToolsRequest extends PaginatedRequest { method: "tools/list"; @@ -917,7 +1097,7 @@ export interface ListToolsRequest extends PaginatedRequest { /** * The server's response to a tools/list request from the client. * - * @category tools/list + * @category `tools/list` */ export interface ListToolsResult extends PaginatedResult { tools: Tool[]; @@ -926,7 +1106,7 @@ export interface ListToolsResult extends PaginatedResult { /** * The server's response to a tool call. * - * @category tools/call + * @category `tools/call` */ export interface CallToolResult extends Result { /** @@ -959,9 +1139,9 @@ export interface CallToolResult extends Result { /** * Parameters for a `tools/call` request. * - * @category tools/call + * @category `tools/call` */ -export interface CallToolRequestParams extends RequestParams { +export interface CallToolRequestParams extends TaskAugmentedRequestParams { /** * The name of the tool. */ @@ -975,7 +1155,7 @@ export interface CallToolRequestParams extends RequestParams { /** * Used by the client to invoke a tool provided by the server. * - * @category tools/call + * @category `tools/call` */ export interface CallToolRequest extends JSONRPCRequest { method: "tools/call"; @@ -985,7 +1165,7 @@ export interface CallToolRequest extends JSONRPCRequest { /** * An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client. * - * @category notifications/tools/list_changed + * @category `notifications/tools/list_changed` */ export interface ToolListChangedNotification extends JSONRPCNotification { method: "notifications/tools/list_changed"; @@ -1001,6 +1181,8 @@ export interface ToolListChangedNotification extends JSONRPCNotification { * * Clients should never make tool use decisions based on ToolAnnotations * received from untrusted servers. + * + * @category `tools/list` */ export interface ToolAnnotations { /** @@ -1046,8 +1228,30 @@ export interface ToolAnnotations { openWorldHint?: boolean; } +/** + * Execution-related properties for a tool. + * + * @category `tools/list` + */ +export interface ToolExecution { + /** + * Indicates whether this tool supports task-augmented execution. + * This allows clients to handle long-running operations through polling + * the task system. + * + * - "forbidden": Tool does not support task-augmented execution (default when absent) + * - "optional": Tool may support task-augmented execution + * - "required": Tool requires task-augmented execution + * + * Default: "forbidden" + */ + taskSupport?: "forbidden" | "optional" | "required"; +} + /** * Definition for a tool the client can call. + * + * @category `tools/list` */ export interface Tool extends BaseMetadata, Icons { /** @@ -1061,16 +1265,26 @@ export interface Tool extends BaseMetadata, Icons { * A JSON Schema object defining the expected parameters for the tool. */ inputSchema: { + $schema?: string; type: "object"; properties?: { [key: string]: object }; required?: string[]; }; + /** + * Execution-related properties for this tool. + */ + execution?: ToolExecution; + /** * An optional JSON Schema object defining the structure of the tool's output returned in * the structuredContent field of a CallToolResult. + * + * Defaults to JSON Schema 2020-12 when no explicit $schema is provided. + * Currently restricted to type: "object" at the root level. */ outputSchema?: { + $schema?: string; type: "object"; properties?: { [key: string]: object }; required?: string[]; @@ -1089,12 +1303,212 @@ export interface Tool extends BaseMetadata, Icons { _meta?: { [key: string]: unknown }; } +/* Tasks */ + +/** + * The status of a task. + * + * @category `tasks` + */ +export type TaskStatus = + | "working" // The request is currently being processed + | "input_required" // The task is waiting for input (e.g., elicitation or sampling) + | "completed" // The request completed successfully and results are available + | "failed" // The associated request did not complete successfully. For tool calls specifically, this includes cases where the tool call result has `isError` set to true. + | "cancelled"; // The request was cancelled before completion + +/** + * Metadata for augmenting a request with task execution. + * Include this in the `task` field of the request parameters. + * + * @category `tasks` + */ +export interface TaskMetadata { + /** + * Requested duration in milliseconds to retain task from creation. + */ + ttl?: number; +} + +/** + * Metadata for associating messages with a task. + * Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`. + * + * @category `tasks` + */ +export interface RelatedTaskMetadata { + /** + * The task identifier this message is associated with. + */ + taskId: string; +} + +/** + * Data associated with a task. + * + * @category `tasks` + */ +export interface Task { + /** + * The task identifier. + */ + taskId: string; + + /** + * Current task state. + */ + status: TaskStatus; + + /** + * Optional human-readable message describing the current task state. + * This can provide context for any status, including: + * - Reasons for "cancelled" status + * - Summaries for "completed" status + * - Diagnostic information for "failed" status (e.g., error details, what went wrong) + */ + statusMessage?: string; + + /** + * ISO 8601 timestamp when the task was created. + */ + createdAt: string; + + /** + * ISO 8601 timestamp when the task was last updated. + */ + lastUpdatedAt: string; + + /** + * Actual retention duration from creation in milliseconds, null for unlimited. + */ + ttl: number | null; + + /** + * Suggested polling interval in milliseconds. + */ + pollInterval?: number; +} + +/** + * A response to a task-augmented request. + * + * @category `tasks` + */ +export interface CreateTaskResult extends Result { + task: Task; +} + +/** + * A request to retrieve the state of a task. + * + * @category `tasks/get` + */ +export interface GetTaskRequest extends JSONRPCRequest { + method: "tasks/get"; + params: { + /** + * The task identifier to query. + */ + taskId: string; + }; +} + +/** + * The response to a tasks/get request. + * + * @category `tasks/get` + */ +export type GetTaskResult = Result & Task; + +/** + * A request to retrieve the result of a completed task. + * + * @category `tasks/result` + */ +export interface GetTaskPayloadRequest extends JSONRPCRequest { + method: "tasks/result"; + params: { + /** + * The task identifier to retrieve results for. + */ + taskId: string; + }; +} + +/** + * The response to a tasks/result request. + * The structure matches the result type of the original request. + * For example, a tools/call task would return the CallToolResult structure. + * + * @category `tasks/result` + */ +export interface GetTaskPayloadResult extends Result { + [key: string]: unknown; +} + +/** + * A request to cancel a task. + * + * @category `tasks/cancel` + */ +export interface CancelTaskRequest extends JSONRPCRequest { + method: "tasks/cancel"; + params: { + /** + * The task identifier to cancel. + */ + taskId: string; + }; +} + +/** + * The response to a tasks/cancel request. + * + * @category `tasks/cancel` + */ +export type CancelTaskResult = Result & Task; + +/** + * A request to retrieve a list of tasks. + * + * @category `tasks/list` + */ +export interface ListTasksRequest extends PaginatedRequest { + method: "tasks/list"; +} + +/** + * The response to a tasks/list request. + * + * @category `tasks/list` + */ +export interface ListTasksResult extends PaginatedResult { + tasks: Task[]; +} + +/** + * Parameters for a `notifications/tasks/status` notification. + * + * @category `notifications/tasks/status` + */ +export type TaskStatusNotificationParams = NotificationParams & Task; + +/** + * An optional notification from the receiver to the requestor, informing them that a task's status has changed. Receivers are not required to send these notifications. + * + * @category `notifications/tasks/status` + */ +export interface TaskStatusNotification extends JSONRPCNotification { + method: "notifications/tasks/status"; + params: TaskStatusNotificationParams; +} + /* Logging */ /** * Parameters for a `logging/setLevel` request. * - * @category logging/setLevel + * @category `logging/setLevel` */ export interface SetLevelRequestParams extends RequestParams { /** @@ -1106,7 +1520,7 @@ export interface SetLevelRequestParams extends RequestParams { /** * A request from the client to the server, to enable or adjust logging. * - * @category logging/setLevel + * @category `logging/setLevel` */ export interface SetLevelRequest extends JSONRPCRequest { method: "logging/setLevel"; @@ -1116,7 +1530,7 @@ export interface SetLevelRequest extends JSONRPCRequest { /** * Parameters for a `notifications/message` notification. * - * @category notifications/message + * @category `notifications/message` */ export interface LoggingMessageNotificationParams extends NotificationParams { /** @@ -1136,7 +1550,7 @@ export interface LoggingMessageNotificationParams extends NotificationParams { /** * JSONRPCNotification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically. * - * @category notifications/message + * @category `notifications/message` */ export interface LoggingMessageNotification extends JSONRPCNotification { method: "notifications/message"; @@ -1148,6 +1562,8 @@ export interface LoggingMessageNotification extends JSONRPCNotification { * * These map to syslog message severities, as specified in RFC-5424: * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 + * + * @category Common Types */ export type LoggingLevel = | "debug" @@ -1163,9 +1579,9 @@ export type LoggingLevel = /** * Parameters for a `sampling/createMessage` request. * - * @category sampling/createMessage + * @category `sampling/createMessage` */ -export interface CreateMessageRequestParams extends RequestParams { +export interface CreateMessageRequestParams extends TaskAugmentedRequestParams { messages: SamplingMessage[]; /** * The server's preferences for which model to select. The client MAY ignore these preferences. @@ -1176,7 +1592,11 @@ export interface CreateMessageRequestParams extends RequestParams { */ systemPrompt?: string; /** - * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. + * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. + * The client MAY ignore this request. + * + * Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client + * declares ClientCapabilities.sampling.context. These values may be removed in future spec releases. */ includeContext?: "none" | "thisServer" | "allServers"; /** @@ -1194,12 +1614,38 @@ export interface CreateMessageRequestParams extends RequestParams { * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. */ metadata?: object; + /** + * Tools that the model may use during generation. + * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. + */ + tools?: Tool[]; + /** + * Controls how the model uses tools. + * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. + * Default is `{ mode: "auto" }`. + */ + toolChoice?: ToolChoice; +} + +/** + * Controls tool selection behavior for sampling requests. + * + * @category `sampling/createMessage` + */ +export interface ToolChoice { + /** + * Controls the tool use ability of the model: + * - "auto": Model decides whether to use tools (default) + * - "required": Model MUST use at least one tool before completing + * - "none": Model MUST NOT use any tools + */ + mode?: "auto" | "required" | "none"; } /** * A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it. * - * @category sampling/createMessage + * @category `sampling/createMessage` */ export interface CreateMessageRequest extends JSONRPCRequest { method: "sampling/createMessage"; @@ -1207,35 +1653,60 @@ export interface CreateMessageRequest extends JSONRPCRequest { } /** - * The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it. + * The client's response to a sampling/createMessage request from the server. + * The client should inform the user before returning the sampled message, to allow them + * to inspect the response (human in the loop) and decide whether to allow the server to see it. * - * @category sampling/createMessage + * @category `sampling/createMessage` */ export interface CreateMessageResult extends Result, SamplingMessage { /** * The name of the model that generated the message. */ model: string; + /** * The reason why sampling stopped, if known. + * + * Standard values: + * - "endTurn": Natural end of the assistant's turn + * - "stopSequence": A stop sequence was encountered + * - "maxTokens": Maximum token limit was reached + * - "toolUse": The model wants to use one or more tools + * + * This field is an open string to allow for provider-specific stop reasons. */ - stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string; + stopReason?: "endTurn" | "stopSequence" | "maxTokens" | "toolUse" | string; } /** * Describes a message issued to or received from an LLM API. + * + * @category `sampling/createMessage` */ export interface SamplingMessage { role: Role; - content: TextContent | ImageContent | AudioContent; + content: SamplingMessageContentBlock | SamplingMessageContentBlock[]; + /** + * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage. + */ + _meta?: { [key: string]: unknown }; } +export type SamplingMessageContentBlock = + | TextContent + | ImageContent + | AudioContent + | ToolUseContent + | ToolResultContent; /** * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed + * + * @category Common Types */ export interface Annotations { /** - * Describes who the intended customer of this object or data is. + * Describes who the intended audience of this object or data is. * * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). */ @@ -1265,6 +1736,9 @@ export interface Annotations { lastModified?: string; } +/** + * @category Content + */ export type ContentBlock = | TextContent | ImageContent @@ -1274,6 +1748,8 @@ export type ContentBlock = /** * Text provided to or from an LLM. + * + * @category Content */ export interface TextContent { type: "text"; @@ -1296,6 +1772,8 @@ export interface TextContent { /** * An image provided to or from an LLM. + * + * @category Content */ export interface ImageContent { type: "image"; @@ -1325,6 +1803,8 @@ export interface ImageContent { /** * Audio provided to or from an LLM. + * + * @category Content */ export interface AudioContent { type: "audio"; @@ -1352,6 +1832,87 @@ export interface AudioContent { _meta?: { [key: string]: unknown }; } +/** + * A request from the assistant to call a tool. + * + * @category `sampling/createMessage` + */ +export interface ToolUseContent { + type: "tool_use"; + + /** + * A unique identifier for this tool use. + * + * This ID is used to match tool results to their corresponding tool uses. + */ + id: string; + + /** + * The name of the tool to call. + */ + name: string; + + /** + * The arguments to pass to the tool, conforming to the tool's input schema. + */ + input: { [key: string]: unknown }; + + /** + * Optional metadata about the tool use. Clients SHOULD preserve this field when + * including tool uses in subsequent sampling requests to enable caching optimizations. + * + * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage. + */ + _meta?: { [key: string]: unknown }; +} + +/** + * The result of a tool use, provided by the user back to the assistant. + * + * @category `sampling/createMessage` + */ +export interface ToolResultContent { + type: "tool_result"; + + /** + * The ID of the tool use this result corresponds to. + * + * This MUST match the ID from a previous ToolUseContent. + */ + toolUseId: string; + + /** + * The unstructured result content of the tool use. + * + * This has the same format as CallToolResult.content and can include text, images, + * audio, resource links, and embedded resources. + */ + content: ContentBlock[]; + + /** + * An optional structured result object. + * + * If the tool defined an outputSchema, this SHOULD conform to that schema. + */ + structuredContent?: { [key: string]: unknown }; + + /** + * Whether the tool use resulted in an error. + * + * If true, the content typically describes the error that occurred. + * Default: false + */ + isError?: boolean; + + /** + * Optional metadata about the tool result. Clients SHOULD preserve this field when + * including tool results in subsequent sampling requests to enable caching optimizations. + * + * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage. + */ + _meta?: { [key: string]: unknown }; +} + /** * The server's preferences for model selection, requested of the client during sampling. * @@ -1364,6 +1925,8 @@ export interface AudioContent { * These preferences are always advisory. The client MAY ignore them. It is also * up to the client to decide how to interpret these preferences and how to * balance them against other considerations. + * + * @category `sampling/createMessage` */ export interface ModelPreferences { /** @@ -1416,6 +1979,8 @@ export interface ModelPreferences { * * Keys not declared here are currently left unspecified by the spec and are up * to the client to interpret. + * + * @category `sampling/createMessage` */ export interface ModelHint { /** @@ -1436,7 +2001,7 @@ export interface ModelHint { /** * Parameters for a `completion/complete` request. * - * @category completion/complete + * @category `completion/complete` */ export interface CompleteRequestParams extends RequestParams { ref: PromptReference | ResourceTemplateReference; @@ -1468,7 +2033,7 @@ export interface CompleteRequestParams extends RequestParams { /** * A request from the client to the server, to ask for completion options. * - * @category completion/complete + * @category `completion/complete` */ export interface CompleteRequest extends JSONRPCRequest { method: "completion/complete"; @@ -1478,7 +2043,7 @@ export interface CompleteRequest extends JSONRPCRequest { /** * The server's response to a completion/complete request * - * @category completion/complete + * @category `completion/complete` */ export interface CompleteResult extends Result { completion: { @@ -1499,6 +2064,8 @@ export interface CompleteResult extends Result { /** * A reference to a resource or resource template definition. + * + * @category `completion/complete` */ export interface ResourceTemplateReference { type: "ref/resource"; @@ -1512,6 +2079,8 @@ export interface ResourceTemplateReference { /** * Identifies a prompt. + * + * @category `completion/complete` */ export interface PromptReference extends BaseMetadata { type: "ref/prompt"; @@ -1527,7 +2096,7 @@ export interface PromptReference extends BaseMetadata { * This request is typically used when the server needs to understand the file system * structure or access specific locations that the client has permission to read from. * - * @category roots/list + * @category `roots/list` */ export interface ListRootsRequest extends JSONRPCRequest { method: "roots/list"; @@ -1539,7 +2108,7 @@ export interface ListRootsRequest extends JSONRPCRequest { * This result contains an array of Root objects, each representing a root directory * or file that the server can operate on. * - * @category roots/list + * @category `roots/list` */ export interface ListRootsResult extends Result { roots: Root[]; @@ -1547,6 +2116,8 @@ export interface ListRootsResult extends Result { /** * Represents a root directory or file that the server can operate on. + * + * @category `roots/list` */ export interface Root { /** @@ -1575,7 +2146,7 @@ export interface Root { * This notification should be sent whenever the client adds, removes, or modifies any root. * The server should then request an updated list of roots using the ListRootsRequest. * - * @category notifications/roots/list_changed + * @category `notifications/roots/list_changed` */ export interface RootsListChangedNotification extends JSONRPCNotification { method: "notifications/roots/list_changed"; @@ -1583,20 +2154,27 @@ export interface RootsListChangedNotification extends JSONRPCNotification { } /** - * Parameters for an `elicitation/create` request. + * The parameters for a request to elicit non-sensitive information from the user via a form in the client. * - * @category elicitation/create + * @category `elicitation/create` */ -export interface ElicitRequestParams extends RequestParams { +export interface ElicitRequestFormParams extends TaskAugmentedRequestParams { /** - * The message to present to the user. + * The elicitation mode. + */ + mode?: "form"; + + /** + * The message to present to the user describing what information is being requested. */ message: string; + /** * A restricted subset of JSON Schema. * Only top-level properties are allowed, without nesting. */ requestedSchema: { + $schema?: string; type: "object"; properties: { [key: string]: PrimitiveSchemaDefinition; @@ -1605,10 +2183,49 @@ export interface ElicitRequestParams extends RequestParams { }; } +/** + * The parameters for a request to elicit information from the user via a URL in the client. + * + * @category `elicitation/create` + */ +export interface ElicitRequestURLParams extends TaskAugmentedRequestParams { + /** + * The elicitation mode. + */ + mode: "url"; + + /** + * The message to present to the user explaining why the interaction is needed. + */ + message: string; + + /** + * The ID of the elicitation, which must be unique within the context of the server. + * The client MUST treat this ID as an opaque value. + */ + elicitationId: string; + + /** + * The URL that the user should navigate to. + * + * @format uri + */ + url: string; +} + +/** + * The parameters for a request to elicit additional information from the user via the client. + * + * @category `elicitation/create` + */ +export type ElicitRequestParams = + | ElicitRequestFormParams + | ElicitRequestURLParams; + /** * A request from the server to elicit additional information from the user via the client. * - * @category elicitation/create + * @category `elicitation/create` */ export interface ElicitRequest extends JSONRPCRequest { method: "elicitation/create"; @@ -1618,6 +2235,8 @@ export interface ElicitRequest extends JSONRPCRequest { /** * Restricted schema definitions that only allow primitive types * without nested objects or arrays. + * + * @category `elicitation/create` */ export type PrimitiveSchemaDefinition = | StringSchema @@ -1625,6 +2244,9 @@ export type PrimitiveSchemaDefinition = | BooleanSchema | EnumSchema; +/** + * @category `elicitation/create` + */ export interface StringSchema { type: "string"; title?: string; @@ -1635,6 +2257,9 @@ export interface StringSchema { default?: string; } +/** + * @category `elicitation/create` + */ export interface NumberSchema { type: "number" | "integer"; title?: string; @@ -1644,6 +2269,9 @@ export interface NumberSchema { default?: number; } +/** + * @category `elicitation/create` + */ export interface BooleanSchema { type: "boolean"; title?: string; @@ -1653,6 +2281,8 @@ export interface BooleanSchema { /** * Schema for single-selection enumeration without display titles for options. + * + * @category `elicitation/create` */ export interface UntitledSingleSelectEnumSchema { type: "string"; @@ -1676,6 +2306,8 @@ export interface UntitledSingleSelectEnumSchema { /** * Schema for single-selection enumeration with display titles for each option. + * + * @category `elicitation/create` */ export interface TitledSingleSelectEnumSchema { type: "string"; @@ -1706,6 +2338,9 @@ export interface TitledSingleSelectEnumSchema { default?: string; } +/** + * @category `elicitation/create` + */ // Combined single selection enumeration export type SingleSelectEnumSchema = | UntitledSingleSelectEnumSchema @@ -1713,6 +2348,8 @@ export type SingleSelectEnumSchema = /** * Schema for multiple-selection enumeration without display titles for options. + * + * @category `elicitation/create` */ export interface UntitledMultiSelectEnumSchema { type: "array"; @@ -1750,6 +2387,8 @@ export interface UntitledMultiSelectEnumSchema { /** * Schema for multiple-selection enumeration with display titles for each option. + * + * @category `elicitation/create` */ export interface TitledMultiSelectEnumSchema { type: "array"; @@ -1793,6 +2432,9 @@ export interface TitledMultiSelectEnumSchema { default?: string[]; } +/** + * @category `elicitation/create` + */ // Combined multiple selection enumeration export type MultiSelectEnumSchema = | UntitledMultiSelectEnumSchema @@ -1801,6 +2443,8 @@ export type MultiSelectEnumSchema = /** * Use TitledSingleSelectEnumSchema instead. * This interface will be removed in a future version. + * + * @category `elicitation/create` */ export interface LegacyTitledEnumSchema { type: "string"; @@ -1815,6 +2459,9 @@ export interface LegacyTitledEnumSchema { default?: string; } +/** + * @category `elicitation/create` + */ // Union type for all enum schemas export type EnumSchema = | SingleSelectEnumSchema @@ -1824,7 +2471,7 @@ export type EnumSchema = /** * The client's response to an elicitation request. * - * @category elicitation/create + * @category `elicitation/create` */ export interface ElicitResult extends Result { /** @@ -1836,12 +2483,28 @@ export interface ElicitResult extends Result { action: "accept" | "decline" | "cancel"; /** - * The submitted form data, only present when action is "accept". + * The submitted form data, only present when action is "accept" and mode was "form". * Contains values matching the requested schema. + * Omitted for out-of-band mode responses. */ content?: { [key: string]: string | number | boolean | string[] }; } +/** + * An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request. + * + * @category `notifications/elicitation/complete` + */ +export interface ElicitationCompleteNotification extends JSONRPCNotification { + method: "notifications/elicitation/complete"; + params: { + /** + * The ID of the elicitation that completed. + */ + elicitationId: string; + }; +} + /* Client messages */ /** @internal */ export type ClientRequest = @@ -1857,21 +2520,30 @@ export type ClientRequest = | SubscribeRequest | UnsubscribeRequest | CallToolRequest - | ListToolsRequest; + | ListToolsRequest + | GetTaskRequest + | GetTaskPayloadRequest + | ListTasksRequest + | CancelTaskRequest; /** @internal */ export type ClientNotification = | CancelledNotification | ProgressNotification | InitializedNotification - | RootsListChangedNotification; + | RootsListChangedNotification + | TaskStatusNotification; /** @internal */ export type ClientResult = | EmptyResult | CreateMessageResult | ListRootsResult - | ElicitResult; + | ElicitResult + | GetTaskResult + | GetTaskPayloadResult + | ListTasksResult + | CancelTaskResult; /* Server messages */ /** @internal */ @@ -1879,7 +2551,11 @@ export type ServerRequest = | PingRequest | CreateMessageRequest | ListRootsRequest - | ElicitRequest; + | ElicitRequest + | GetTaskRequest + | GetTaskPayloadRequest + | ListTasksRequest + | CancelTaskRequest; /** @internal */ export type ServerNotification = @@ -1889,7 +2565,9 @@ export type ServerNotification = | ResourceUpdatedNotification | ResourceListChangedNotification | ToolListChangedNotification - | PromptListChangedNotification; + | PromptListChangedNotification + | ElicitationCompleteNotification + | TaskStatusNotification; /** @internal */ export type ServerResult = @@ -1902,4 +2580,8 @@ export type ServerResult = | ListResourcesResult | ReadResourceResult | CallToolResult - | ListToolsResult; + | ListToolsResult + | GetTaskResult + | GetTaskPayloadResult + | ListTasksResult + | CancelTaskResult;