mcp: update mcp types to latest draft

This commit is contained in:
Connor Peet
2025-09-27 10:53:27 -07:00
parent 7de09762d9
commit f80ce2e135
2 changed files with 223 additions and 61 deletions
@@ -259,7 +259,7 @@ export class McpServerRequestHandler extends Disposable {
} while (nextCursor !== undefined && !token.isCancellationRequested);
}
private sendNotification<N extends MCP.ClientNotification>(notification: N): void {
private sendNotification<N extends MCP.ClientNotification>(notification: Omit<N, 'jsonrpc'>): void {
this.send({ ...notification, jsonrpc: MCP.JSONRPC_VERSION });
}
@@ -26,9 +26,12 @@ export namespace MCP {
*
* ⚠️ Do not edit within `namespace` manually except to update schema versions ⚠️
*/
export namespace MCP {
export namespace MCP {/* JSON-RPC types */
/**
* Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
*
* @internal
*/
export type JSONRPCMessage =
| JSONRPCRequest
@@ -36,7 +39,9 @@ export namespace MCP {
| JSONRPCResponse
| JSONRPCError;
/** @internal */
export const LATEST_PROTOCOL_VERSION = "2025-06-18";
/** @internal */
export const JSONRPC_VERSION = "2.0";
/**
@@ -49,11 +54,12 @@ export namespace MCP {
*/
export type Cursor = string;
/** @internal */
export interface Request {
method: string;
params?: {
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: {
/**
@@ -66,11 +72,12 @@ export namespace MCP {
};
}
/** @internal */
export interface Notification {
method: string;
params?: {
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
[key: string]: unknown;
@@ -79,12 +86,27 @@ export namespace MCP {
export interface Result {
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
[key: string]: unknown;
}
export interface Error {
/**
* The error type that occurred.
*/
code: number;
/**
* A short description of the error. The message SHOULD be limited to a concise single sentence.
*/
message: string;
/**
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
*/
data?: unknown;
}
/**
* A uniquely identifying ID for a request in JSON-RPC.
*/
@@ -115,10 +137,15 @@ export namespace MCP {
}
// 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;
/**
@@ -127,20 +154,7 @@ export namespace MCP {
export interface JSONRPCError {
jsonrpc: typeof JSONRPC_VERSION;
id: RequestId;
error: {
/**
* The error type that occurred.
*/
code: number;
/**
* A short description of the error. The message SHOULD be limited to a concise single sentence.
*/
message: string;
/**
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
*/
data?: unknown;
};
error: Error;
}
/* Empty result */
@@ -158,8 +172,10 @@ export namespace MCP {
* This notification indicates that the result will be unused, so any associated processing SHOULD cease.
*
* A client MUST NOT attempt to cancel its `initialize` request.
*
* @category notifications/cancelled
*/
export interface CancelledNotification extends Notification {
export interface CancelledNotification extends JSONRPCNotification {
method: "notifications/cancelled";
params: {
/**
@@ -179,8 +195,10 @@ export namespace MCP {
/* Initialization */
/**
* This request is sent from the client to the server when it first connects, asking it to begin initialization.
*
* @category initialize
*/
export interface InitializeRequest extends Request {
export interface InitializeRequest extends JSONRPCRequest {
method: "initialize";
params: {
/**
@@ -194,6 +212,8 @@ export namespace MCP {
/**
* After receiving an initialize request from the client, the server sends this response.
*
* @category initialize
*/
export interface InitializeResult extends Result {
/**
@@ -213,8 +233,10 @@ export namespace MCP {
/**
* This notification is sent from the client to the server after initialization has finished.
*
* @category notifications/initialized
*/
export interface InitializedNotification extends Notification {
export interface InitializedNotification extends JSONRPCNotification {
method: "notifications/initialized";
}
@@ -294,8 +316,63 @@ export namespace MCP {
};
}
/**
* An optionally-sized icon that can be displayed in a user interface.
*/
export interface Icon {
/**
* A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a
* `data:` URI with Base64-encoded image data.
*
* Consumers SHOULD takes steps to ensure URLs serving icons are from the
* same domain as the client/server or a trusted domain.
*
* Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain
* executable JavaScript.
*
* @format uri
*/
src: string;
/**
* Optional MIME type override if the source MIME type is missing or generic.
* For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`.
*/
mimeType?: string;
/**
* Optional string that specifies one or more sizes at which the icon can be used.
* For example: `"48x48"`, `"48x48 96x96"`, or `"any"` for scalable formats like SVG.
*
* If not provided, the client should assume that the icon can be used at any size.
*/
sizes?: string;
}
/**
* Base interface to add `icons` property.
*
* @internal
*/
export interface Icons {
/**
* Optional set of sized icons that the client can display in a user interface.
*
* Clients that support rendering icons MUST support at least the following MIME types:
* - `image/png` - PNG images (safe, universal compatibility)
* - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
*
* Clients that support rendering icons SHOULD also support:
* - `image/svg+xml` - SVG images (scalable but requires security precautions)
* - `image/webp` - WebP images (modern, efficient format)
*/
icons?: Icon[];
}
/**
* Base interface for metadata with name (identifier) and title (display name) properties.
*
* @internal
*/
export interface BaseMetadata {
/**
@@ -315,25 +392,36 @@ export namespace MCP {
}
/**
* Describes the name and version of an MCP implementation, with an optional title for UI representation.
* Describes the MCP implementation
*/
export interface Implementation extends BaseMetadata {
export interface Implementation extends BaseMetadata, Icons {
version: string;
/**
* An optional URL of the website for this implementation.
*
* @format uri
*/
websiteUrl?: string;
}
/* Ping */
/**
* 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
*/
export interface PingRequest extends Request {
export interface PingRequest extends JSONRPCRequest {
method: "ping";
}
/* Progress notifications */
/**
* An out-of-band notification used to inform the receiver of a progress update for a long-running request.
*
* @category notifications/progress
*/
export interface ProgressNotification extends Notification {
export interface ProgressNotification extends JSONRPCNotification {
method: "notifications/progress";
params: {
/**
@@ -360,7 +448,8 @@ export namespace MCP {
}
/* Pagination */
export interface PaginatedRequest extends Request {
/** @internal */
export interface PaginatedRequest extends JSONRPCRequest {
params?: {
/**
* An opaque token representing the current pagination position.
@@ -370,6 +459,7 @@ export namespace MCP {
};
}
/** @internal */
export interface PaginatedResult extends Result {
/**
* An opaque token representing the pagination position after the last returned result.
@@ -381,6 +471,8 @@ export namespace MCP {
/* Resources */
/**
* Sent from the client to request a list of resources the server has.
*
* @category resources/list
*/
export interface ListResourcesRequest extends PaginatedRequest {
method: "resources/list";
@@ -388,6 +480,8 @@ export namespace MCP {
/**
* The server's response to a resources/list request from the client.
*
* @category resources/list
*/
export interface ListResourcesResult extends PaginatedResult {
resources: Resource[];
@@ -395,6 +489,8 @@ export namespace MCP {
/**
* Sent from the client to request a list of resource templates the server has.
*
* @category resources/templates/list
*/
export interface ListResourceTemplatesRequest extends PaginatedRequest {
method: "resources/templates/list";
@@ -402,6 +498,8 @@ export namespace MCP {
/**
* The server's response to a resources/templates/list request from the client.
*
* @category resources/templates/list
*/
export interface ListResourceTemplatesResult extends PaginatedResult {
resourceTemplates: ResourceTemplate[];
@@ -409,8 +507,10 @@ export namespace MCP {
/**
* Sent from the client to the server, to read a specific resource URI.
*
* @category resources/read
*/
export interface ReadResourceRequest extends Request {
export interface ReadResourceRequest extends JSONRPCRequest {
method: "resources/read";
params: {
/**
@@ -424,6 +524,8 @@ export namespace MCP {
/**
* The server's response to a resources/read request from the client.
*
* @category resources/read
*/
export interface ReadResourceResult extends Result {
contents: (TextResourceContents | BlobResourceContents)[];
@@ -431,15 +533,19 @@ export namespace MCP {
/**
* 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
*/
export interface ResourceListChangedNotification extends Notification {
export interface ResourceListChangedNotification extends JSONRPCNotification {
method: "notifications/resources/list_changed";
}
/**
* Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
*
* @category resources/subscribe
*/
export interface SubscribeRequest extends Request {
export interface SubscribeRequest extends JSONRPCRequest {
method: "resources/subscribe";
params: {
/**
@@ -453,8 +559,10 @@ export namespace MCP {
/**
* 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
*/
export interface UnsubscribeRequest extends Request {
export interface UnsubscribeRequest extends JSONRPCRequest {
method: "resources/unsubscribe";
params: {
/**
@@ -468,8 +576,10 @@ export namespace MCP {
/**
* 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
*/
export interface ResourceUpdatedNotification extends Notification {
export interface ResourceUpdatedNotification extends JSONRPCNotification {
method: "notifications/resources/updated";
params: {
/**
@@ -484,7 +594,7 @@ export namespace MCP {
/**
* A known resource that the server is capable of reading.
*/
export interface Resource extends BaseMetadata {
export interface Resource extends BaseMetadata, Icons {
/**
* The URI of this resource.
*
@@ -517,7 +627,7 @@ export namespace MCP {
size?: number;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -551,7 +661,7 @@ export namespace MCP {
annotations?: Annotations;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -572,7 +682,7 @@ export namespace MCP {
mimeType?: string;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -596,6 +706,8 @@ export namespace MCP {
/* Prompts */
/**
* Sent from the client to request a list of prompts and prompt templates the server has.
*
* @category prompts/list
*/
export interface ListPromptsRequest extends PaginatedRequest {
method: "prompts/list";
@@ -603,6 +715,8 @@ export namespace MCP {
/**
* The server's response to a prompts/list request from the client.
*
* @category prompts/list
*/
export interface ListPromptsResult extends PaginatedResult {
prompts: Prompt[];
@@ -610,8 +724,10 @@ export namespace MCP {
/**
* Used by the client to get a prompt provided by the server.
*
* @category prompts/get
*/
export interface GetPromptRequest extends Request {
export interface GetPromptRequest extends JSONRPCRequest {
method: "prompts/get";
params: {
/**
@@ -627,6 +743,8 @@ export namespace MCP {
/**
* The server's response to a prompts/get request from the client.
*
* @category prompts/get
*/
export interface GetPromptResult extends Result {
/**
@@ -639,18 +757,19 @@ export namespace MCP {
/**
* A prompt or prompt template that the server offers.
*/
export interface Prompt extends BaseMetadata {
export interface Prompt extends BaseMetadata, Icons {
/**
* An optional description of what this prompt provides
*/
description?: string;
/**
* A list of arguments to use for templating the prompt.
*/
arguments?: PromptArgument[];
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -677,7 +796,9 @@ export namespace MCP {
/**
* Describes a message returned as part of a prompt.
*
* This is similar to ` */
* This is similar to `SamplingMessage`, but also supports the embedding of
* resources from the MCP server.
*/
export interface PromptMessage {
role: Role;
content: ContentBlock;
@@ -708,20 +829,24 @@ export namespace MCP {
annotations?: Annotations;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
/**
* 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
*/
export interface PromptListChangedNotification extends Notification {
export interface PromptListChangedNotification extends JSONRPCNotification {
method: "notifications/prompts/list_changed";
}
/* Tools */
/**
* Sent from the client to request a list of tools the server has.
*
* @category tools/list
*/
export interface ListToolsRequest extends PaginatedRequest {
method: "tools/list";
@@ -729,6 +854,8 @@ export namespace MCP {
/**
* The server's response to a tools/list request from the client.
*
* @category tools/list
*/
export interface ListToolsResult extends PaginatedResult {
tools: Tool[];
@@ -736,6 +863,8 @@ export namespace MCP {
/**
* The server's response to a tool call.
*
* @category tools/call
*/
export interface CallToolResult extends Result {
/**
@@ -767,8 +896,10 @@ export namespace MCP {
/**
* Used by the client to invoke a tool provided by the server.
*
* @category tools/call
*/
export interface CallToolRequest extends Request {
export interface CallToolRequest extends JSONRPCRequest {
method: "tools/call";
params: {
name: string;
@@ -778,8 +909,10 @@ export namespace MCP {
/**
* 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
*/
export interface ToolListChangedNotification extends Notification {
export interface ToolListChangedNotification extends JSONRPCNotification {
method: "notifications/tools/list_changed";
}
@@ -840,7 +973,7 @@ export namespace MCP {
/**
* Definition for a tool the client can call.
*/
export interface Tool extends BaseMetadata {
export interface Tool extends BaseMetadata, Icons {
/**
* A human-readable description of the tool.
*
@@ -875,7 +1008,7 @@ export namespace MCP {
annotations?: ToolAnnotations;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -883,8 +1016,10 @@ export namespace MCP {
/* Logging */
/**
* A request from the client to the server, to enable or adjust logging.
*
* @category logging/setLevel
*/
export interface SetLevelRequest extends Request {
export interface SetLevelRequest extends JSONRPCRequest {
method: "logging/setLevel";
params: {
/**
@@ -895,9 +1030,11 @@ export namespace MCP {
}
/**
* Notification 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.
* 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
*/
export interface LoggingMessageNotification extends Notification {
export interface LoggingMessageNotification extends JSONRPCNotification {
method: "notifications/message";
params: {
/**
@@ -934,8 +1071,10 @@ export namespace MCP {
/* Sampling */
/**
* 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
*/
export interface CreateMessageRequest extends Request {
export interface CreateMessageRequest extends JSONRPCRequest {
method: "sampling/createMessage";
params: {
messages: SamplingMessage[];
@@ -956,7 +1095,9 @@ export namespace MCP {
*/
temperature?: number;
/**
* The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.
* The requested maximum number of tokens to sample (to prevent runaway completions).
*
* The client MAY choose to sample fewer tokens than the requested maximum.
*/
maxTokens: number;
stopSequences?: string[];
@@ -969,6 +1110,8 @@ export namespace MCP {
/**
* 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.
*
* @category sampling/createMessage
*/
export interface CreateMessageResult extends Result, SamplingMessage {
/**
@@ -1024,7 +1167,6 @@ export namespace MCP {
lastModified?: string;
}
/** */
export type ContentBlock =
| TextContent
| ImageContent
@@ -1049,7 +1191,7 @@ export namespace MCP {
annotations?: Annotations;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -1078,7 +1220,7 @@ export namespace MCP {
annotations?: Annotations;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -1107,7 +1249,7 @@ export namespace MCP {
annotations?: Annotations;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -1195,8 +1337,10 @@ export namespace MCP {
/* Autocomplete */
/**
* A request from the client to the server, to ask for completion options.
*
* @category completion/complete
*/
export interface CompleteRequest extends Request {
export interface CompleteRequest extends JSONRPCRequest {
method: "completion/complete";
params: {
ref: PromptReference | ResourceTemplateReference;
@@ -1228,6 +1372,8 @@ export namespace MCP {
/**
* The server's response to a completion/complete request
*
* @category completion/complete
*/
export interface CompleteResult extends Result {
completion: {
@@ -1275,8 +1421,10 @@ export namespace MCP {
*
* 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
*/
export interface ListRootsRequest extends Request {
export interface ListRootsRequest extends JSONRPCRequest {
method: "roots/list";
}
@@ -1284,6 +1432,8 @@ export namespace MCP {
* The client's response to a roots/list request from the server.
* This result contains an array of Root objects, each representing a root directory
* or file that the server can operate on.
*
* @category roots/list
*/
export interface ListRootsResult extends Result {
roots: Root[];
@@ -1309,7 +1459,7 @@ export namespace MCP {
name?: string;
/**
* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
@@ -1318,15 +1468,19 @@ export namespace MCP {
* A notification from the client to the server, informing it that the list of roots has changed.
* 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
*/
export interface RootsListChangedNotification extends Notification {
export interface RootsListChangedNotification extends JSONRPCNotification {
method: "notifications/roots/list_changed";
}
/**
* A request from the server to elicit additional information from the user via the client.
*
* @category elicitation/create
*/
export interface ElicitRequest extends Request {
export interface ElicitRequest extends JSONRPCRequest {
method: "elicitation/create";
params: {
/**
@@ -1394,12 +1548,14 @@ export namespace MCP {
/**
* The client's response to an elicitation request.
*
* @category elicitation/create
*/
export interface ElicitResult extends Result {
/**
* The user action in response to the elicitation.
* - "accept": User submitted the form/confirmed the action
* - "decline": User explicitly declined the action
* - "decline": User explicitly decline the action
* - "cancel": User dismissed without making an explicit choice
*/
action: "accept" | "decline" | "cancel";
@@ -1412,6 +1568,7 @@ export namespace MCP {
}
/* Client messages */
/** @internal */
export type ClientRequest =
| PingRequest
| InitializeRequest
@@ -1427,12 +1584,14 @@ export namespace MCP {
| CallToolRequest
| ListToolsRequest;
/** @internal */
export type ClientNotification =
| CancelledNotification
| ProgressNotification
| InitializedNotification
| RootsListChangedNotification;
/** @internal */
export type ClientResult =
| EmptyResult
| CreateMessageResult
@@ -1440,12 +1599,14 @@ export namespace MCP {
| ElicitResult;
/* Server messages */
/** @internal */
export type ServerRequest =
| PingRequest
| CreateMessageRequest
| ListRootsRequest
| ElicitRequest;
/** @internal */
export type ServerNotification =
| CancelledNotification
| ProgressNotification
@@ -1455,6 +1616,7 @@ export namespace MCP {
| ToolListChangedNotification
| PromptListChangedNotification;
/** @internal */
export type ServerResult =
| EmptyResult
| InitializeResult