From 1e6f77a2c5b716d1c41e5ae669bcd8412e429ff7 Mon Sep 17 00:00:00 2001 From: = <1936278+evalstate@users.noreply.github.com> Date: Tue, 4 Mar 2025 21:03:59 +0000 Subject: [PATCH 1/2] Added Tool Call and Tool Result to GetPrompt for in-context learning of tool usage --- schema/draft/schema.json | 58 ++ schema/draft/schema.ts | 1861 +++++++++++++++++++------------------- 2 files changed, 1012 insertions(+), 907 deletions(-) diff --git a/schema/draft/schema.json b/schema/draft/schema.json index cf96011..bd04173 100644 --- a/schema/draft/schema.json +++ b/schema/draft/schema.json @@ -1407,6 +1407,18 @@ }, "role": { "$ref": "#/definitions/Role" + }, + "toolCalls": { + "items": { + "$ref": "#/definitions/ToolCall" + }, + "type": "array" + }, + "toolResult": { + "items": { + "$ref": "#/definitions/ToolResult" + }, + "type": "array" } }, "required": [ @@ -2065,6 +2077,30 @@ ], "type": "object" }, + "ToolCall": { + "description": "A tool call initiated by the assistant.", + "properties": { + "arguments": { + "additionalProperties": {}, + "description": "The arguments passed to the tool, as a JSON object.", + "type": "object" + }, + "id": { + "description": "A unique identifier for this tool call.\nThis ID is used to match tool calls with their results.", + "type": "string" + }, + "name": { + "description": "The name of the tool being called.", + "type": "string" + } + }, + "required": [ + "arguments", + "id", + "name" + ], + "type": "object" + }, "ToolListChangedNotification": { "description": "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.", "properties": { @@ -2089,6 +2125,28 @@ ], "type": "object" }, + "ToolResult": { + "description": "A result returned from a tool call.", + "properties": { + "content": { + "description": "The content returned from the tool, typically text.", + "type": "string" + }, + "isError": { + "description": "Whether the tool call resulted in an error.\nIf not specified, assumed to be false.", + "type": "boolean" + }, + "toolCallId": { + "description": "The ID of the tool call this result is for.\nThis must match the ID of a previous tool call.", + "type": "string" + } + }, + "required": [ + "content", + "toolCallId" + ], + "type": "object" + }, "UnsubscribeRequest": { "description": "Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.", "properties": { diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index 5f93e96..ec53919 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -1,1132 +1,1179 @@ -/* JSON-RPC types */ -export type JSONRPCMessage = - | JSONRPCRequest - | JSONRPCNotification - | JSONRPCResponse - | JSONRPCError; + /* JSON-RPC types */ + export type JSONRPCMessage = + | JSONRPCRequest + | JSONRPCNotification + | JSONRPCResponse + | JSONRPCError; -export const LATEST_PROTOCOL_VERSION = "DRAFT-2025-v1"; -export const JSONRPC_VERSION = "2.0"; + export const LATEST_PROTOCOL_VERSION = "DRAFT-2025-v1"; + export const JSONRPC_VERSION = "2.0"; -/** - * A progress token, used to associate progress notifications with the original request. - */ -export type ProgressToken = string | number; + /** + * A progress token, used to associate progress notifications with the original request. + */ + export type ProgressToken = string | number; -/** - * An opaque token used to represent a cursor for pagination. - */ -export type Cursor = string; + /** + * An opaque token used to represent a cursor for pagination. + */ + export type Cursor = string; + + export interface Request { + method: string; + params?: { + _meta?: { + /** + * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. + */ + progressToken?: ProgressToken; + }; + [key: string]: unknown; + }; + } -export interface Request { - method: string; - params?: { - _meta?: { + export interface Notification { + method: string; + params?: { /** - * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. + * This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications. */ - progressToken?: ProgressToken; + _meta?: { [key: string]: unknown }; + [key: string]: unknown; }; - [key: string]: unknown; - }; -} + } -export interface Notification { - method: string; - params?: { + export interface Result { /** - * This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications. + * This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses. */ _meta?: { [key: string]: unknown }; [key: string]: unknown; - }; -} + } -export interface Result { /** - * This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses. + * A uniquely identifying ID for a request in JSON-RPC. */ - _meta?: { [key: string]: unknown }; - [key: string]: unknown; -} - -/** - * A uniquely identifying ID for a request in JSON-RPC. - */ -export type RequestId = string | number; - -/** - * A request that expects a response. - */ -export interface JSONRPCRequest extends Request { - jsonrpc: typeof JSONRPC_VERSION; - id: RequestId; -} - -/** - * A notification which does not expect a response. - */ -export interface JSONRPCNotification extends Notification { - jsonrpc: typeof JSONRPC_VERSION; -} - -/** - * A successful (non-error) response to a request. - */ -export interface JSONRPCResponse { - jsonrpc: typeof JSONRPC_VERSION; - id: RequestId; - result: Result; -} - -// Standard JSON-RPC error codes -export const PARSE_ERROR = -32700; -export const INVALID_REQUEST = -32600; -export const METHOD_NOT_FOUND = -32601; -export const INVALID_PARAMS = -32602; -export const INTERNAL_ERROR = -32603; + export type RequestId = string | number; -/** - * A response to a request that indicates an error occurred. - */ -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; - }; -} + /** + * A request that expects a response. + */ + export interface JSONRPCRequest extends Request { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; + } -/* Empty result */ -/** - * A response that indicates success but carries no data. - */ -export type EmptyResult = Result; + /** + * A notification which does not expect a response. + */ + export interface JSONRPCNotification extends Notification { + jsonrpc: typeof JSONRPC_VERSION; + } -/* Cancellation */ -/** - * This notification can be sent by either side to indicate that it is cancelling a previously-issued request. - * - * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished. - * - * 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. - */ -export interface CancelledNotification extends Notification { - method: "notifications/cancelled"; - params: { - /** - * The ID of the request to cancel. - * - * This MUST correspond to the ID of a request previously issued in the same direction. - */ - requestId: RequestId; + /** + * A successful (non-error) response to a request. + */ + export interface JSONRPCResponse { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; + result: Result; + } - /** - * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. - */ - reason?: string; - }; -} + // Standard JSON-RPC error codes + export const PARSE_ERROR = -32700; + export const INVALID_REQUEST = -32600; + export const METHOD_NOT_FOUND = -32601; + export const INVALID_PARAMS = -32602; + export const INTERNAL_ERROR = -32603; -/* Initialization */ -/** - * This request is sent from the client to the server when it first connects, asking it to begin initialization. - */ -export interface InitializeRequest extends Request { - method: "initialize"; - params: { - /** - * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. - */ - protocolVersion: string; - capabilities: ClientCapabilities; - clientInfo: Implementation; - }; -} + /** + * A response to a request that indicates an error occurred. + */ + 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; + }; + } -/** - * After receiving an initialize request from the client, the server sends this response. - */ -export interface InitializeResult extends Result { + /* Empty result */ /** - * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. + * A response that indicates success but carries no data. */ - protocolVersion: string; - capabilities: ServerCapabilities; - serverInfo: Implementation; + export type EmptyResult = Result; + + /* Cancellation */ /** - * Instructions describing how to use the server and its features. + * This notification can be sent by either side to indicate that it is cancelling a previously-issued request. + * + * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished. * - * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt. + * 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. */ - instructions?: string; -} + export interface CancelledNotification extends Notification { + method: "notifications/cancelled"; + params: { + /** + * The ID of the request to cancel. + * + * This MUST correspond to the ID of a request previously issued in the same direction. + */ + requestId: RequestId; -/** - * This notification is sent from the client to the server after initialization has finished. - */ -export interface InitializedNotification extends Notification { - method: "notifications/initialized"; -} + /** + * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. + */ + reason?: string; + }; + } -/** - * 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. - */ -export interface ClientCapabilities { + /* Initialization */ /** - * Experimental, non-standard capabilities that the client supports. + * This request is sent from the client to the server when it first connects, asking it to begin initialization. */ - experimental?: { [key: string]: object }; + export interface InitializeRequest extends Request { + method: "initialize"; + params: { + /** + * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. + */ + protocolVersion: string; + capabilities: ClientCapabilities; + clientInfo: Implementation; + }; + } + /** - * Present if the client supports listing roots. + * After receiving an initialize request from the client, the server sends this response. */ - roots?: { + export interface InitializeResult extends Result { /** - * Whether the client supports notifications for changes to the roots list. + * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. */ - listChanged?: boolean; - }; - /** - * Present if the client supports sampling from an LLM. - */ - sampling?: object; -} + protocolVersion: string; + capabilities: ServerCapabilities; + serverInfo: Implementation; + /** + * Instructions describing how to use the server and its features. + * + * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt. + */ + instructions?: string; + } -/** - * 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. - */ -export interface ServerCapabilities { /** - * Experimental, non-standard capabilities that the server supports. + * This notification is sent from the client to the server after initialization has finished. */ - experimental?: { [key: string]: object }; - /** - * Present if the server supports sending log messages to the client. - */ - logging?: object; + export interface InitializedNotification extends Notification { + method: "notifications/initialized"; + } + /** - * Present if the server offers any prompt templates. + * 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. */ - prompts?: { + export interface ClientCapabilities { /** - * Whether this server supports notifications for changes to the prompt list. + * Experimental, non-standard capabilities that the client supports. */ - listChanged?: boolean; - }; - /** - * Present if the server offers any resources to read. - */ - resources?: { + experimental?: { [key: string]: object }; /** - * Whether this server supports subscribing to resource updates. + * Present if the client supports listing roots. */ - subscribe?: boolean; + roots?: { + /** + * Whether the client supports notifications for changes to the roots list. + */ + listChanged?: boolean; + }; /** - * Whether this server supports notifications for changes to the resource list. + * Present if the client supports sampling from an LLM. */ - listChanged?: boolean; - }; + sampling?: object; + } + /** - * Present if the server offers any tools to call. + * 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. */ - tools?: { + export interface ServerCapabilities { /** - * Whether this server supports notifications for changes to the tool list. + * Experimental, non-standard capabilities that the server supports. */ - listChanged?: boolean; - }; -} - -/** - * Describes the name and version of an MCP implementation. - */ -export interface Implementation { - name: string; - version: 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. - */ -export interface PingRequest extends Request { - method: "ping"; -} - -/* Progress notifications */ -/** - * An out-of-band notification used to inform the receiver of a progress update for a long-running request. - */ -export interface ProgressNotification extends Notification { - method: "notifications/progress"; - params: { + experimental?: { [key: string]: object }; /** - * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. + * Present if the server supports sending log messages to the client. */ - progressToken: ProgressToken; + logging?: object; /** - * The progress thus far. This should increase every time progress is made, even if the total is unknown. - * - * @TJS-type number + * Present if the server offers any prompt templates. */ - progress: number; + prompts?: { + /** + * Whether this server supports notifications for changes to the prompt list. + */ + listChanged?: boolean; + }; /** - * Total number of items to process (or total progress required), if known. - * - * @TJS-type number + * Present if the server offers any resources to read. */ - total?: number; - }; -} - -/* Pagination */ -export interface PaginatedRequest extends Request { - params?: { + resources?: { + /** + * Whether this server supports subscribing to resource updates. + */ + subscribe?: boolean; + /** + * Whether this server supports notifications for changes to the resource list. + */ + listChanged?: boolean; + }; /** - * An opaque token representing the current pagination position. - * If provided, the server should return results starting after this cursor. + * Present if the server offers any tools to call. */ - cursor?: Cursor; - }; -} + tools?: { + /** + * Whether this server supports notifications for changes to the tool list. + */ + listChanged?: boolean; + }; + } -export interface PaginatedResult extends Result { /** - * An opaque token representing the pagination position after the last returned result. - * If present, there may be more results available. + * Describes the name and version of an MCP implementation. */ - nextCursor?: Cursor; -} - -/* Resources */ -/** - * Sent from the client to request a list of resources the server has. - */ -export interface ListResourcesRequest extends PaginatedRequest { - method: "resources/list"; -} - -/** - * The server's response to a resources/list request from the client. - */ -export interface ListResourcesResult extends PaginatedResult { - resources: Resource[]; -} - -/** - * Sent from the client to request a list of resource templates the server has. - */ -export interface ListResourceTemplatesRequest extends PaginatedRequest { - method: "resources/templates/list"; -} - -/** - * The server's response to a resources/templates/list request from the client. - */ -export interface ListResourceTemplatesResult extends PaginatedResult { - resourceTemplates: ResourceTemplate[]; -} - -/** - * Sent from the client to the server, to read a specific resource URI. - */ -export interface ReadResourceRequest extends Request { - method: "resources/read"; - params: { - /** - * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it. - * - * @format uri - */ - uri: string; - }; -} - -/** - * The server's response to a resources/read request from the client. - */ -export interface ReadResourceResult extends Result { - contents: (TextResourceContents | BlobResourceContents)[]; -} + export interface Implementation { + name: string; + version: string; + } -/** - * 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. - */ -export interface ResourceListChangedNotification extends Notification { - method: "notifications/resources/list_changed"; -} + /* 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. + */ + export interface PingRequest extends Request { + method: "ping"; + } -/** - * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. - */ -export interface SubscribeRequest extends Request { - method: "resources/subscribe"; - params: { - /** - * The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it. - * - * @format uri - */ - uri: string; - }; -} + /* Progress notifications */ + /** + * An out-of-band notification used to inform the receiver of a progress update for a long-running request. + */ + export interface ProgressNotification extends Notification { + method: "notifications/progress"; + params: { + /** + * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. + */ + progressToken: ProgressToken; + /** + * The progress thus far. This should increase every time progress is made, even if the total is unknown. + * + * @TJS-type number + */ + progress: number; + /** + * Total number of items to process (or total progress required), if known. + * + * @TJS-type number + */ + total?: number; + }; + } -/** - * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. - */ -export interface UnsubscribeRequest extends Request { - method: "resources/unsubscribe"; - params: { - /** - * The URI of the resource to unsubscribe from. - * - * @format uri - */ - uri: string; - }; -} + /* Pagination */ + export interface PaginatedRequest extends Request { + params?: { + /** + * An opaque token representing the current pagination position. + * If provided, the server should return results starting after this cursor. + */ + cursor?: Cursor; + }; + } -/** - * 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. - */ -export interface ResourceUpdatedNotification extends Notification { - method: "notifications/resources/updated"; - params: { + export interface PaginatedResult extends Result { /** - * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to. - * - * @format uri + * An opaque token representing the pagination position after the last returned result. + * If present, there may be more results available. */ - uri: string; - }; -} + nextCursor?: Cursor; + } -/** - * A known resource that the server is capable of reading. - */ -export interface Resource extends Annotated { + /* Resources */ /** - * The URI of this resource. - * - * @format uri + * Sent from the client to request a list of resources the server has. */ - uri: string; + export interface ListResourcesRequest extends PaginatedRequest { + method: "resources/list"; + } /** - * A human-readable name for this resource. - * - * This can be used by clients to populate UI elements. + * The server's response to a resources/list request from the client. */ - name: string; + export interface ListResourcesResult extends PaginatedResult { + resources: Resource[]; + } /** - * A description of what this resource represents. - * - * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. + * Sent from the client to request a list of resource templates the server has. */ - description?: string; + export interface ListResourceTemplatesRequest extends PaginatedRequest { + method: "resources/templates/list"; + } /** - * The MIME type of this resource, if known. + * The server's response to a resources/templates/list request from the client. */ - mimeType?: string; -} + export interface ListResourceTemplatesResult extends PaginatedResult { + resourceTemplates: ResourceTemplate[]; + } -/** - * A template description for resources available on the server. - */ -export interface ResourceTemplate extends Annotated { /** - * A URI template (according to RFC 6570) that can be used to construct resource URIs. - * - * @format uri-template + * Sent from the client to the server, to read a specific resource URI. */ - uriTemplate: string; + export interface ReadResourceRequest extends Request { + method: "resources/read"; + params: { + /** + * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it. + * + * @format uri + */ + uri: string; + }; + } /** - * A human-readable name for the type of resource this template refers to. - * - * This can be used by clients to populate UI elements. + * The server's response to a resources/read request from the client. */ - name: string; + export interface ReadResourceResult extends Result { + contents: (TextResourceContents | BlobResourceContents)[]; + } /** - * A description of what this template is for. - * - * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. + * 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. */ - description?: string; + export interface ResourceListChangedNotification extends Notification { + method: "notifications/resources/list_changed"; + } /** - * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type. + * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. */ - mimeType?: string; -} + export interface SubscribeRequest extends Request { + method: "resources/subscribe"; + params: { + /** + * The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it. + * + * @format uri + */ + uri: string; + }; + } -/** - * The contents of a specific resource or sub-resource. - */ -export interface ResourceContents { /** - * The URI of this resource. - * - * @format uri - */ - uri: string; - /** - * The MIME type of this resource, if known. + * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. */ - mimeType?: string; -} + export interface UnsubscribeRequest extends Request { + method: "resources/unsubscribe"; + params: { + /** + * The URI of the resource to unsubscribe from. + * + * @format uri + */ + uri: string; + }; + } -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). + * 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. */ - text: string; -} + export interface ResourceUpdatedNotification extends Notification { + method: "notifications/resources/updated"; + params: { + /** + * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to. + * + * @format uri + */ + uri: string; + }; + } -export interface BlobResourceContents extends ResourceContents { /** - * A base64-encoded string representing the binary data of the item. - * - * @format byte + * A known resource that the server is capable of reading. */ - blob: string; -} + export interface Resource extends Annotated { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; -/* Prompts */ -/** - * Sent from the client to request a list of prompts and prompt templates the server has. - */ -export interface ListPromptsRequest extends PaginatedRequest { - method: "prompts/list"; -} + /** + * A human-readable name for this resource. + * + * This can be used by clients to populate UI elements. + */ + name: string; -/** - * The server's response to a prompts/list request from the client. - */ -export interface ListPromptsResult extends PaginatedResult { - prompts: Prompt[]; -} + /** + * A description of what this resource represents. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. + */ + description?: string; -/** - * Used by the client to get a prompt provided by the server. - */ -export interface GetPromptRequest extends Request { - method: "prompts/get"; - params: { /** - * The name of the prompt or prompt template. + * The MIME type of this resource, if known. + */ + mimeType?: string; + } + + /** + * A template description for resources available on the server. + */ + export interface ResourceTemplate extends Annotated { + /** + * A URI template (according to RFC 6570) that can be used to construct resource URIs. + * + * @format uri-template + */ + uriTemplate: string; + + /** + * A human-readable name for the type of resource this template refers to. + * + * This can be used by clients to populate UI elements. */ name: string; + /** - * Arguments to use for templating the prompt. + * A description of what this template is for. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. */ - arguments?: { [key: string]: string }; - }; -} + description?: string; + + /** + * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type. + */ + mimeType?: string; + } -/** - * The server's response to a prompts/get request from the client. - */ -export interface GetPromptResult extends Result { /** - * An optional description for the prompt. + * The contents of a specific resource or sub-resource. */ - description?: string; - messages: PromptMessage[]; -} + export interface ResourceContents { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; + /** + * The MIME type of this resource, if known. + */ + mimeType?: string; + } -/** - * A prompt or prompt template that the server offers. - */ -export interface Prompt { + 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). + */ + text: string; + } + + export interface BlobResourceContents extends ResourceContents { + /** + * A base64-encoded string representing the binary data of the item. + * + * @format byte + */ + blob: string; + } + + /* Prompts */ /** - * The name of the prompt or prompt template. + * Sent from the client to request a list of prompts and prompt templates the server has. */ - name: string; + export interface ListPromptsRequest extends PaginatedRequest { + method: "prompts/list"; + } + /** - * An optional description of what this prompt provides + * The server's response to a prompts/list request from the client. */ - description?: string; + export interface ListPromptsResult extends PaginatedResult { + prompts: Prompt[]; + } + /** - * A list of arguments to use for templating the prompt. + * Used by the client to get a prompt provided by the server. */ - arguments?: PromptArgument[]; -} + export interface GetPromptRequest extends Request { + method: "prompts/get"; + params: { + /** + * The name of the prompt or prompt template. + */ + name: string; + /** + * Arguments to use for templating the prompt. + */ + arguments?: { [key: string]: string }; + }; + } -/** - * Describes an argument that a prompt can accept. - */ -export interface PromptArgument { /** - * The name of the argument. + * The server's response to a prompts/get request from the client. */ - name: string; + export interface GetPromptResult extends Result { + /** + * An optional description for the prompt. + */ + description?: string; + messages: PromptMessage[]; + } + /** - * A human-readable description of the argument. + * A prompt or prompt template that the server offers. */ - description?: string; + export interface Prompt { + /** + * The name of the prompt or prompt template. + */ + name: string; + /** + * An optional description of what this prompt provides + */ + description?: string; + /** + * A list of arguments to use for templating the prompt. + */ + arguments?: PromptArgument[]; + } + /** - * Whether this argument must be provided. + * Describes an argument that a prompt can accept. */ - required?: boolean; -} + export interface PromptArgument { + /** + * The name of the argument. + */ + name: string; + /** + * A human-readable description of the argument. + */ + description?: string; + /** + * Whether this argument must be provided. + */ + required?: boolean; + } -/** - * The sender or recipient of messages and data in a conversation. - */ -export type Role = "user" | "assistant"; + /** + * The sender or recipient of messages and data in a conversation. + */ + export type Role = "user" | "assistant"; -/** - * Describes a message returned as part of a prompt. - * - * This is similar to `SamplingMessage`, but also supports the embedding of - * resources from the MCP server. - */ -export interface PromptMessage { - role: Role; - content: TextContent | ImageContent | AudioContent | EmbeddedResource; -} + /** + * Describes a message returned as part of a prompt. + * + * This is similar to `SamplingMessage`, but also supports the embedding of + * resources from the MCP server. + */ + export interface PromptMessage { + role: Role; + content: TextContent | ImageContent | AudioContent | EmbeddedResource; + toolCalls?: ToolCall[]; // Tool calls requested by the the Assistant + toolResult?: ToolResult[]; // Tool responses returned by the User (Host) + } -/** - * The contents of a resource, embedded into a prompt or tool call result. - * - * It is up to the client how best to render embedded resources for the benefit - * of the LLM and/or the user. - */ -export interface EmbeddedResource extends Annotated { - type: "resource"; - resource: TextResourceContents | BlobResourceContents; -} /** - * 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. + * A tool call initiated by the assistant. */ -export interface PromptListChangedNotification extends Notification { - method: "notifications/prompts/list_changed"; +export interface ToolCall { + /** + * A unique identifier for this tool call. + * This ID is used to match tool calls with their results. + */ + id: string; + + /** + * The name of the tool being called. + */ + name: string; + + /** + * The arguments passed to the tool, as a JSON object. + */ + arguments: { [key: string]: unknown }; } -/* Tools */ /** - * Sent from the client to request a list of tools the server has. + * A result returned from a tool call. */ -export interface ListToolsRequest extends PaginatedRequest { - method: "tools/list"; -} +export interface ToolResult { + /** + * The ID of the tool call this result is for. + * This must match the ID of a previous tool call. + */ + toolCallId: string; + + /** + * The content returned from the tool, typically text. + */ + content: string; -/** - * The server's response to a tools/list request from the client. - */ -export interface ListToolsResult extends PaginatedResult { - tools: Tool[]; + /** + * Whether the tool call resulted in an error. + * If not specified, assumed to be false. + */ + isError?: boolean; } -/** - * The server's response to a tool call. - * - * Any errors that originate from the tool SHOULD be reported inside the result - * object, with `isError` set to true, _not_ as an MCP protocol-level error - * response. Otherwise, the LLM would not be able to see that an error occurred - * and self-correct. - * - * However, any errors in _finding_ the tool, an error indicating that the - * server does not support tool calls, or any other exceptional conditions, - * should be reported as an MCP error response. - */ -export interface CallToolResult extends Result { - content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; /** - * Whether the tool call ended in an error. + * The contents of a resource, embedded into a prompt or tool call result. * - * If not set, this is assumed to be false (the call was successful). + * It is up to the client how best to render embedded resources for the benefit + * of the LLM and/or the user. */ - isError?: boolean; -} - -/** - * Used by the client to invoke a tool provided by the server. - */ -export interface CallToolRequest extends Request { - method: "tools/call"; - params: { - name: string; - arguments?: { [key: string]: unknown }; - }; -} + export interface EmbeddedResource extends Annotated { + type: "resource"; + resource: TextResourceContents | BlobResourceContents; + } -/** - * 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. - */ -export interface ToolListChangedNotification extends Notification { - method: "notifications/tools/list_changed"; -} + /** + * 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. + */ + export interface PromptListChangedNotification extends Notification { + method: "notifications/prompts/list_changed"; + } -/** - * Definition for a tool the client can call. - */ -export interface Tool { + /* Tools */ /** - * The name of the tool. + * Sent from the client to request a list of tools the server has. */ - name: string; + export interface ListToolsRequest extends PaginatedRequest { + method: "tools/list"; + } + /** - * A human-readable description of the tool. + * The server's response to a tools/list request from the client. */ - description?: string; + export interface ListToolsResult extends PaginatedResult { + tools: Tool[]; + } + /** - * A JSON Schema object defining the expected parameters for the tool. + * The server's response to a tool call. + * + * Any errors that originate from the tool SHOULD be reported inside the result + * object, with `isError` set to true, _not_ as an MCP protocol-level error + * response. Otherwise, the LLM would not be able to see that an error occurred + * and self-correct. + * + * However, any errors in _finding_ the tool, an error indicating that the + * server does not support tool calls, or any other exceptional conditions, + * should be reported as an MCP error response. */ - inputSchema: { - type: "object"; - properties?: { [key: string]: object }; - required?: string[]; - }; -} + export interface CallToolResult extends Result { + content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; -/* Logging */ -/** - * A request from the client to the server, to enable or adjust logging. - */ -export interface SetLevelRequest extends Request { - method: "logging/setLevel"; - params: { /** - * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message. + * Whether the tool call ended in an error. + * + * If not set, this is assumed to be false (the call was successful). */ - level: LoggingLevel; - }; -} + isError?: boolean; + } -/** - * 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. - */ -export interface LoggingMessageNotification extends Notification { - method: "notifications/message"; - params: { - /** - * The severity of this log message. - */ - level: LoggingLevel; - /** - * An optional name of the logger issuing this message. - */ - logger?: string; - /** - * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here. - */ - data: unknown; - }; -} + /** + * Used by the client to invoke a tool provided by the server. + */ + export interface CallToolRequest extends Request { + method: "tools/call"; + params: { + name: string; + arguments?: { [key: string]: unknown }; + }; + } -/** - * The severity of a log message. - * - * These map to syslog message severities, as specified in RFC-5424: - * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 - */ -export type LoggingLevel = - | "debug" - | "info" - | "notice" - | "warning" - | "error" - | "critical" - | "alert" - | "emergency"; - -/* 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. - */ -export interface CreateMessageRequest extends Request { - method: "sampling/createMessage"; - params: { - messages: SamplingMessage[]; - /** - * The server's preferences for which model to select. The client MAY ignore these preferences. - */ - modelPreferences?: ModelPreferences; - /** - * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt. - */ - 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. - */ - includeContext?: "none" | "thisServer" | "allServers"; + /** + * 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. + */ + export interface ToolListChangedNotification extends Notification { + method: "notifications/tools/list_changed"; + } + + /** + * Definition for a tool the client can call. + */ + export interface Tool { /** - * @TJS-type number + * The name of the tool. */ - temperature?: number; + name: string; /** - * The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested. + * A human-readable description of the tool. */ - maxTokens: number; - stopSequences?: string[]; + description?: string; /** - * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. + * A JSON Schema object defining the expected parameters for the tool. */ - metadata?: object; - }; -} + inputSchema: { + type: "object"; + properties?: { [key: string]: object }; + required?: string[]; + }; + } -/** - * 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. - */ -export interface CreateMessageResult extends Result, SamplingMessage { + /* Logging */ /** - * The name of the model that generated the message. + * A request from the client to the server, to enable or adjust logging. */ - model: string; + export interface SetLevelRequest extends Request { + method: "logging/setLevel"; + params: { + /** + * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message. + */ + level: LoggingLevel; + }; + } + /** - * The reason why sampling stopped, if known. + * 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. */ - stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string; -} + export interface LoggingMessageNotification extends Notification { + method: "notifications/message"; + params: { + /** + * The severity of this log message. + */ + level: LoggingLevel; + /** + * An optional name of the logger issuing this message. + */ + logger?: string; + /** + * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here. + */ + data: unknown; + }; + } -/** - * Describes a message issued to or received from an LLM API. - */ -export interface SamplingMessage { - role: Role; - content: TextContent | ImageContent | AudioContent; -} + /** + * The severity of a log message. + * + * These map to syslog message severities, as specified in RFC-5424: + * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 + */ + export type LoggingLevel = + | "debug" + | "info" + | "notice" + | "warning" + | "error" + | "critical" + | "alert" + | "emergency"; + + /* 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. + */ + export interface CreateMessageRequest extends Request { + method: "sampling/createMessage"; + params: { + messages: SamplingMessage[]; + /** + * The server's preferences for which model to select. The client MAY ignore these preferences. + */ + modelPreferences?: ModelPreferences; + /** + * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt. + */ + 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. + */ + includeContext?: "none" | "thisServer" | "allServers"; + /** + * @TJS-type number + */ + temperature?: number; + /** + * The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested. + */ + maxTokens: number; + stopSequences?: string[]; + /** + * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. + */ + metadata?: object; + }; + } -/** - * Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed - */ -export interface Annotated { - annotations?: { + /** + * 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. + */ + export interface CreateMessageResult extends Result, SamplingMessage { /** - * Describes who the intended customer of this object or data is. - * - * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). + * The name of the model that generated the message. */ - audience?: Role[]; - + model: string; /** - * Describes how important this data is for operating the server. - * - * A value of 1 means "most important," and indicates that the data is - * effectively required, while 0 means "least important," and indicates that - * the data is entirely optional. - * - * @TJS-type number - * @minimum 0 - * @maximum 1 + * The reason why sampling stopped, if known. */ - priority?: number; + stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string; } -} -/** - * Text provided to or from an LLM. - */ -export interface TextContent extends Annotated { - type: "text"; /** - * The text content of the message. + * Describes a message issued to or received from an LLM API. */ - text: string; -} + export interface SamplingMessage { + role: Role; + content: TextContent | ImageContent | AudioContent; + } -/** - * An image provided to or from an LLM. - */ -export interface ImageContent extends Annotated { - type: "image"; /** - * The base64-encoded image data. - * - * @format byte - */ - data: string; - /** - * The MIME type of the image. Different providers may support different image types. + * Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed */ - mimeType: string; -} + export interface Annotated { + annotations?: { + /** + * Describes who the intended customer of this object or data is. + * + * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). + */ + audience?: Role[]; + /** + * Describes how important this data is for operating the server. + * + * A value of 1 means "most important," and indicates that the data is + * effectively required, while 0 means "least important," and indicates that + * the data is entirely optional. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + priority?: number; + } + } -/** - * Audio provided to or from an LLM. - */ -export interface AudioContent extends Annotated { - type: "audio"; /** - * The base64-encoded audio data. - * - * @format byte + * Text provided to or from an LLM. */ - data: string; + export interface TextContent extends Annotated { + type: "text"; + /** + * The text content of the message. + */ + text: string; + } + /** - * The MIME type of the audio. Different providers may support different audio types. + * An image provided to or from an LLM. */ - mimeType: string; -} + export interface ImageContent extends Annotated { + type: "image"; + /** + * The base64-encoded image data. + * + * @format byte + */ + data: string; + /** + * The MIME type of the image. Different providers may support different image types. + */ + mimeType: string; + } -/** - * The server's preferences for model selection, requested of the client during sampling. - * - * Because LLMs can vary along multiple dimensions, choosing the "best" model is - * rarely straightforward. Different models excel in different areas—some are - * faster but less capable, others are more capable but more expensive, and so - * on. This interface allows servers to express their priorities across multiple - * dimensions to help clients make an appropriate selection for their use case. - * - * 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. - */ -export interface ModelPreferences { /** - * Optional hints to use for model selection. - * - * If multiple hints are specified, the client MUST evaluate them in order - * (such that the first match is taken). - * - * The client SHOULD prioritize these hints over the numeric priorities, but - * MAY still use the priorities to select from ambiguous matches. + * Audio provided to or from an LLM. */ - hints?: ModelHint[]; + export interface AudioContent extends Annotated { + type: "audio"; + /** + * The base64-encoded audio data. + * + * @format byte + */ + data: string; + /** + * The MIME type of the audio. Different providers may support different audio types. + */ + mimeType: string; + } + /** - * How much to prioritize cost when selecting a model. A value of 0 means cost - * is not important, while a value of 1 means cost is the most important - * factor. + * The server's preferences for model selection, requested of the client during sampling. * - * @TJS-type number - * @minimum 0 - * @maximum 1 + * Because LLMs can vary along multiple dimensions, choosing the "best" model is + * rarely straightforward. Different models excel in different areas—some are + * faster but less capable, others are more capable but more expensive, and so + * on. This interface allows servers to express their priorities across multiple + * dimensions to help clients make an appropriate selection for their use case. + * + * 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. */ - costPriority?: number; + export interface ModelPreferences { + /** + * Optional hints to use for model selection. + * + * If multiple hints are specified, the client MUST evaluate them in order + * (such that the first match is taken). + * + * The client SHOULD prioritize these hints over the numeric priorities, but + * MAY still use the priorities to select from ambiguous matches. + */ + hints?: ModelHint[]; + + /** + * How much to prioritize cost when selecting a model. A value of 0 means cost + * is not important, while a value of 1 means cost is the most important + * factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + costPriority?: number; + + /** + * How much to prioritize sampling speed (latency) when selecting a model. A + * value of 0 means speed is not important, while a value of 1 means speed is + * the most important factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + speedPriority?: number; + + /** + * How much to prioritize intelligence and capabilities when selecting a + * model. A value of 0 means intelligence is not important, while a value of 1 + * means intelligence is the most important factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + intelligencePriority?: number; + } /** - * How much to prioritize sampling speed (latency) when selecting a model. A - * value of 0 means speed is not important, while a value of 1 means speed is - * the most important factor. + * Hints to use for model selection. * - * @TJS-type number - * @minimum 0 - * @maximum 1 + * Keys not declared here are currently left unspecified by the spec and are up + * to the client to interpret. */ - speedPriority?: number; + export interface ModelHint { + /** + * A hint for a model name. + * + * The client SHOULD treat this as a substring of a model name; for example: + * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022` + * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc. + * - `claude` should match any Claude model + * + * The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example: + * - `gemini-1.5-flash` could match `claude-3-haiku-20240307` + */ + name?: string; + } + /* Autocomplete */ /** - * How much to prioritize intelligence and capabilities when selecting a - * model. A value of 0 means intelligence is not important, while a value of 1 - * means intelligence is the most important factor. - * - * @TJS-type number - * @minimum 0 - * @maximum 1 + * A request from the client to the server, to ask for completion options. */ - intelligencePriority?: number; -} + export interface CompleteRequest extends Request { + method: "completion/complete"; + params: { + ref: PromptReference | ResourceReference; + /** + * The argument's information + */ + argument: { + /** + * The name of the argument + */ + name: string; + /** + * The value of the argument to use for completion matching. + */ + value: string; + }; + }; + } -/** - * Hints to use for model selection. - * - * Keys not declared here are currently left unspecified by the spec and are up - * to the client to interpret. - */ -export interface ModelHint { /** - * A hint for a model name. - * - * The client SHOULD treat this as a substring of a model name; for example: - * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022` - * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc. - * - `claude` should match any Claude model - * - * The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example: - * - `gemini-1.5-flash` could match `claude-3-haiku-20240307` + * The server's response to a completion/complete request */ - name?: string; -} - -/* Autocomplete */ -/** - * A request from the client to the server, to ask for completion options. - */ -export interface CompleteRequest extends Request { - method: "completion/complete"; - params: { - ref: PromptReference | ResourceReference; - /** - * The argument's information - */ - argument: { + export interface CompleteResult extends Result { + completion: { /** - * The name of the argument + * An array of completion values. Must not exceed 100 items. */ - name: string; + values: string[]; + /** + * The total number of completion options available. This can exceed the number of values actually sent in the response. + */ + total?: number; /** - * The value of the argument to use for completion matching. + * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown. */ - value: string; + hasMore?: boolean; }; - }; -} + } -/** - * The server's response to a completion/complete request - */ -export interface CompleteResult extends Result { - completion: { - /** - * An array of completion values. Must not exceed 100 items. - */ - values: string[]; + /** + * A reference to a resource or resource template definition. + */ + export interface ResourceReference { + type: "ref/resource"; /** - * The total number of completion options available. This can exceed the number of values actually sent in the response. + * The URI or URI template of the resource. + * + * @format uri-template */ - total?: number; + uri: string; + } + + /** + * Identifies a prompt. + */ + export interface PromptReference { + type: "ref/prompt"; /** - * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown. + * The name of the prompt or prompt template */ - hasMore?: boolean; - }; -} + name: string; + } -/** - * A reference to a resource or resource template definition. - */ -export interface ResourceReference { - type: "ref/resource"; + /* Roots */ /** - * The URI or URI template of the resource. + * Sent from the server to request a list of root URIs from the client. Roots allow + * servers to ask for specific directories or files to operate on. A common example + * for roots is providing a set of repositories or directories a server should operate + * on. * - * @format uri-template + * 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. */ - uri: string; -} + export interface ListRootsRequest extends Request { + method: "roots/list"; + } -/** - * Identifies a prompt. - */ -export interface PromptReference { - type: "ref/prompt"; /** - * The name of the prompt or prompt template + * 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. */ - name: string; -} - -/* Roots */ -/** - * Sent from the server to request a list of root URIs from the client. Roots allow - * servers to ask for specific directories or files to operate on. A common example - * for roots is providing a set of repositories or directories a server should operate - * on. - * - * 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. - */ -export interface ListRootsRequest extends Request { - method: "roots/list"; -} - -/** - * 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. - */ -export interface ListRootsResult extends Result { - roots: Root[]; -} + export interface ListRootsResult extends Result { + roots: Root[]; + } -/** - * Represents a root directory or file that the server can operate on. - */ -export interface Root { /** - * The URI identifying the root. This *must* start with file:// for now. - * This restriction may be relaxed in future versions of the protocol to allow - * other URI schemes. - * - * @format uri + * Represents a root directory or file that the server can operate on. */ - uri: string; + export interface Root { + /** + * The URI identifying the root. This *must* start with file:// for now. + * This restriction may be relaxed in future versions of the protocol to allow + * other URI schemes. + * + * @format uri + */ + uri: string; + /** + * An optional name for the root. This can be used to provide a human-readable + * identifier for the root, which may be useful for display purposes or for + * referencing the root in other parts of the application. + */ + name?: string; + } + /** - * An optional name for the root. This can be used to provide a human-readable - * identifier for the root, which may be useful for display purposes or for - * referencing the root in other parts of the application. + * 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. */ - name?: string; -} - -/** - * 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. - */ -export interface RootsListChangedNotification extends Notification { - method: "notifications/roots/list_changed"; -} + export interface RootsListChangedNotification extends Notification { + method: "notifications/roots/list_changed"; + } -/* Client messages */ -export type ClientRequest = - | PingRequest - | InitializeRequest - | CompleteRequest - | SetLevelRequest - | GetPromptRequest - | ListPromptsRequest - | ListResourcesRequest - | ReadResourceRequest - | SubscribeRequest - | UnsubscribeRequest - | CallToolRequest - | ListToolsRequest; - -export type ClientNotification = - | CancelledNotification - | ProgressNotification - | InitializedNotification - | RootsListChangedNotification; - -export type ClientResult = EmptyResult | CreateMessageResult | ListRootsResult; - -/* Server messages */ -export type ServerRequest = - | PingRequest - | CreateMessageRequest - | ListRootsRequest; - -export type ServerNotification = - | CancelledNotification - | ProgressNotification - | LoggingMessageNotification - | ResourceUpdatedNotification - | ResourceListChangedNotification - | ToolListChangedNotification - | PromptListChangedNotification; - -export type ServerResult = - | EmptyResult - | InitializeResult - | CompleteResult - | GetPromptResult - | ListPromptsResult - | ListResourcesResult - | ReadResourceResult - | CallToolResult - | ListToolsResult; + /* Client messages */ + export type ClientRequest = + | PingRequest + | InitializeRequest + | CompleteRequest + | SetLevelRequest + | GetPromptRequest + | ListPromptsRequest + | ListResourcesRequest + | ReadResourceRequest + | SubscribeRequest + | UnsubscribeRequest + | CallToolRequest + | ListToolsRequest; + + export type ClientNotification = + | CancelledNotification + | ProgressNotification + | InitializedNotification + | RootsListChangedNotification; + + export type ClientResult = EmptyResult | CreateMessageResult | ListRootsResult; + + /* Server messages */ + export type ServerRequest = + | PingRequest + | CreateMessageRequest + | ListRootsRequest; + + export type ServerNotification = + | CancelledNotification + | ProgressNotification + | LoggingMessageNotification + | ResourceUpdatedNotification + | ResourceListChangedNotification + | ToolListChangedNotification + | PromptListChangedNotification; + + export type ServerResult = + | EmptyResult + | InitializeResult + | CompleteResult + | GetPromptResult + | ListPromptsResult + | ListResourcesResult + | ReadResourceResult + | CallToolResult + | ListToolsResult; From 45c8f70804d6e87cc5e3e6e494e98db70c5c451a Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Wed, 5 Mar 2025 11:37:03 +0000 Subject: [PATCH 2/2] fix schema tab issue --- schema/draft/schema.ts | 1900 ++++++++++++++++++++-------------------- 1 file changed, 950 insertions(+), 950 deletions(-) diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index ec53919..8018d57 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -1,1179 +1,1179 @@ - /* JSON-RPC types */ - export type JSONRPCMessage = - | JSONRPCRequest - | JSONRPCNotification - | JSONRPCResponse - | JSONRPCError; +/* JSON-RPC types */ +export type JSONRPCMessage = + | JSONRPCRequest + | JSONRPCNotification + | JSONRPCResponse + | JSONRPCError; - export const LATEST_PROTOCOL_VERSION = "DRAFT-2025-v1"; - export const JSONRPC_VERSION = "2.0"; +export const LATEST_PROTOCOL_VERSION = "DRAFT-2025-v1"; +export const JSONRPC_VERSION = "2.0"; - /** - * A progress token, used to associate progress notifications with the original request. - */ - export type ProgressToken = string | number; +/** + * A progress token, used to associate progress notifications with the original request. + */ +export type ProgressToken = string | number; - /** - * An opaque token used to represent a cursor for pagination. - */ - export type Cursor = string; - - export interface Request { - method: string; - params?: { - _meta?: { - /** - * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. - */ - progressToken?: ProgressToken; - }; - [key: string]: unknown; - }; - } +/** + * An opaque token used to represent a cursor for pagination. + */ +export type Cursor = string; - export interface Notification { - method: string; - params?: { +export interface Request { + method: string; + params?: { + _meta?: { /** - * This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications. + * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. */ - _meta?: { [key: string]: unknown }; - [key: string]: unknown; + progressToken?: ProgressToken; }; - } + [key: string]: unknown; + }; +} - export interface Result { +export interface Notification { + method: string; + params?: { /** - * This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses. + * This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications. */ _meta?: { [key: string]: unknown }; [key: string]: unknown; - } + }; +} +export interface Result { /** - * A uniquely identifying ID for a request in JSON-RPC. + * This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses. */ - export type RequestId = string | number; + _meta?: { [key: string]: unknown }; + [key: string]: unknown; +} - /** - * A request that expects a response. - */ - export interface JSONRPCRequest extends Request { - jsonrpc: typeof JSONRPC_VERSION; - id: RequestId; - } +/** + * A uniquely identifying ID for a request in JSON-RPC. + */ +export type RequestId = string | number; - /** - * A notification which does not expect a response. - */ - export interface JSONRPCNotification extends Notification { - jsonrpc: typeof JSONRPC_VERSION; - } +/** + * A request that expects a response. + */ +export interface JSONRPCRequest extends Request { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; +} - /** - * A successful (non-error) response to a request. - */ - export interface JSONRPCResponse { - jsonrpc: typeof JSONRPC_VERSION; - id: RequestId; - result: Result; - } +/** + * A notification which does not expect a response. + */ +export interface JSONRPCNotification extends Notification { + jsonrpc: typeof JSONRPC_VERSION; +} - // Standard JSON-RPC error codes - export const PARSE_ERROR = -32700; - export const INVALID_REQUEST = -32600; - export const METHOD_NOT_FOUND = -32601; - export const INVALID_PARAMS = -32602; - export const INTERNAL_ERROR = -32603; +/** + * A successful (non-error) response to a request. + */ +export interface JSONRPCResponse { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; + result: Result; +} - /** - * A response to a request that indicates an error occurred. - */ - 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; - }; - } +// Standard JSON-RPC error codes +export const PARSE_ERROR = -32700; +export const INVALID_REQUEST = -32600; +export const METHOD_NOT_FOUND = -32601; +export const INVALID_PARAMS = -32602; +export const INTERNAL_ERROR = -32603; + +/** + * A response to a request that indicates an error occurred. + */ +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; + }; +} + +/* Empty result */ +/** + * A response that indicates success but carries no data. + */ +export type EmptyResult = Result; + +/* Cancellation */ +/** + * This notification can be sent by either side to indicate that it is cancelling a previously-issued request. + * + * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished. + * + * 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. + */ +export interface CancelledNotification extends Notification { + method: "notifications/cancelled"; + params: { + /** + * The ID of the request to cancel. + * + * This MUST correspond to the ID of a request previously issued in the same direction. + */ + requestId: RequestId; + + /** + * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. + */ + reason?: string; + }; +} + +/* Initialization */ +/** + * This request is sent from the client to the server when it first connects, asking it to begin initialization. + */ +export interface InitializeRequest extends Request { + method: "initialize"; + params: { + /** + * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. + */ + protocolVersion: string; + capabilities: ClientCapabilities; + clientInfo: Implementation; + }; +} - /* Empty result */ +/** + * After receiving an initialize request from the client, the server sends this response. + */ +export interface InitializeResult extends Result { /** - * A response that indicates success but carries no data. + * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. */ - export type EmptyResult = Result; - - /* Cancellation */ + protocolVersion: string; + capabilities: ServerCapabilities; + serverInfo: Implementation; /** - * This notification can be sent by either side to indicate that it is cancelling a previously-issued request. - * - * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished. + * Instructions describing how to use the server and its features. * - * 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. + * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt. */ - export interface CancelledNotification extends Notification { - method: "notifications/cancelled"; - params: { - /** - * The ID of the request to cancel. - * - * This MUST correspond to the ID of a request previously issued in the same direction. - */ - requestId: RequestId; + instructions?: string; +} - /** - * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. - */ - reason?: string; - }; - } +/** + * This notification is sent from the client to the server after initialization has finished. + */ +export interface InitializedNotification extends Notification { + method: "notifications/initialized"; +} - /* Initialization */ +/** + * 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. + */ +export interface ClientCapabilities { /** - * This request is sent from the client to the server when it first connects, asking it to begin initialization. + * Experimental, non-standard capabilities that the client supports. */ - export interface InitializeRequest extends Request { - method: "initialize"; - params: { - /** - * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. - */ - protocolVersion: string; - capabilities: ClientCapabilities; - clientInfo: Implementation; - }; - } - + experimental?: { [key: string]: object }; /** - * After receiving an initialize request from the client, the server sends this response. + * Present if the client supports listing roots. */ - export interface InitializeResult extends Result { - /** - * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. - */ - protocolVersion: string; - capabilities: ServerCapabilities; - serverInfo: Implementation; + roots?: { /** - * Instructions describing how to use the server and its features. - * - * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt. + * Whether the client supports notifications for changes to the roots list. */ - instructions?: string; - } - + listChanged?: boolean; + }; /** - * This notification is sent from the client to the server after initialization has finished. + * Present if the client supports sampling from an LLM. */ - export interface InitializedNotification extends Notification { - method: "notifications/initialized"; - } + sampling?: 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. + */ +export interface ServerCapabilities { + /** + * Experimental, non-standard capabilities that the server supports. + */ + experimental?: { [key: string]: object }; + /** + * Present if the server supports sending log messages to the client. + */ + logging?: object; /** - * 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. + * Present if the server offers any prompt templates. */ - export interface ClientCapabilities { + prompts?: { /** - * Experimental, non-standard capabilities that the client supports. + * Whether this server supports notifications for changes to the prompt list. */ - experimental?: { [key: string]: object }; + listChanged?: boolean; + }; + /** + * Present if the server offers any resources to read. + */ + resources?: { /** - * Present if the client supports listing roots. + * Whether this server supports subscribing to resource updates. */ - roots?: { - /** - * Whether the client supports notifications for changes to the roots list. - */ - listChanged?: boolean; - }; + subscribe?: boolean; /** - * Present if the client supports sampling from an LLM. + * Whether this server supports notifications for changes to the resource list. */ - sampling?: object; - } - + listChanged?: boolean; + }; /** - * 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. + * Present if the server offers any tools to call. */ - export interface ServerCapabilities { + tools?: { /** - * Experimental, non-standard capabilities that the server supports. + * Whether this server supports notifications for changes to the tool list. */ - experimental?: { [key: string]: object }; + listChanged?: boolean; + }; +} + +/** + * Describes the name and version of an MCP implementation. + */ +export interface Implementation { + name: string; + version: 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. + */ +export interface PingRequest extends Request { + method: "ping"; +} + +/* Progress notifications */ +/** + * An out-of-band notification used to inform the receiver of a progress update for a long-running request. + */ +export interface ProgressNotification extends Notification { + method: "notifications/progress"; + params: { /** - * Present if the server supports sending log messages to the client. + * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. */ - logging?: object; + progressToken: ProgressToken; /** - * Present if the server offers any prompt templates. + * The progress thus far. This should increase every time progress is made, even if the total is unknown. + * + * @TJS-type number */ - prompts?: { - /** - * Whether this server supports notifications for changes to the prompt list. - */ - listChanged?: boolean; - }; + progress: number; /** - * Present if the server offers any resources to read. + * Total number of items to process (or total progress required), if known. + * + * @TJS-type number */ - resources?: { - /** - * Whether this server supports subscribing to resource updates. - */ - subscribe?: boolean; - /** - * Whether this server supports notifications for changes to the resource list. - */ - listChanged?: boolean; - }; + total?: number; + }; +} + +/* Pagination */ +export interface PaginatedRequest extends Request { + params?: { /** - * Present if the server offers any tools to call. + * An opaque token representing the current pagination position. + * If provided, the server should return results starting after this cursor. */ - tools?: { - /** - * Whether this server supports notifications for changes to the tool list. - */ - listChanged?: boolean; - }; - } + cursor?: Cursor; + }; +} +export interface PaginatedResult extends Result { /** - * Describes the name and version of an MCP implementation. + * An opaque token representing the pagination position after the last returned result. + * If present, there may be more results available. */ - export interface Implementation { - name: string; - version: string; - } + nextCursor?: Cursor; +} - /* 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. - */ - export interface PingRequest extends Request { - method: "ping"; - } +/* Resources */ +/** + * Sent from the client to request a list of resources the server has. + */ +export interface ListResourcesRequest extends PaginatedRequest { + method: "resources/list"; +} - /* Progress notifications */ - /** - * An out-of-band notification used to inform the receiver of a progress update for a long-running request. - */ - export interface ProgressNotification extends Notification { - method: "notifications/progress"; - params: { - /** - * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. - */ - progressToken: ProgressToken; - /** - * The progress thus far. This should increase every time progress is made, even if the total is unknown. - * - * @TJS-type number - */ - progress: number; - /** - * Total number of items to process (or total progress required), if known. - * - * @TJS-type number - */ - total?: number; - }; - } +/** + * The server's response to a resources/list request from the client. + */ +export interface ListResourcesResult extends PaginatedResult { + resources: Resource[]; +} - /* Pagination */ - export interface PaginatedRequest extends Request { - params?: { - /** - * An opaque token representing the current pagination position. - * If provided, the server should return results starting after this cursor. - */ - cursor?: Cursor; - }; - } +/** + * Sent from the client to request a list of resource templates the server has. + */ +export interface ListResourceTemplatesRequest extends PaginatedRequest { + method: "resources/templates/list"; +} + +/** + * The server's response to a resources/templates/list request from the client. + */ +export interface ListResourceTemplatesResult extends PaginatedResult { + resourceTemplates: ResourceTemplate[]; +} - export interface PaginatedResult extends Result { +/** + * Sent from the client to the server, to read a specific resource URI. + */ +export interface ReadResourceRequest extends Request { + method: "resources/read"; + params: { /** - * An opaque token representing the pagination position after the last returned result. - * If present, there may be more results available. + * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it. + * + * @format uri */ - nextCursor?: Cursor; - } + uri: string; + }; +} + +/** + * The server's response to a resources/read request from the client. + */ +export interface ReadResourceResult extends Result { + contents: (TextResourceContents | BlobResourceContents)[]; +} + +/** + * 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. + */ +export interface ResourceListChangedNotification extends Notification { + method: "notifications/resources/list_changed"; +} + +/** + * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. + */ +export interface SubscribeRequest extends Request { + method: "resources/subscribe"; + params: { + /** + * The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it. + * + * @format uri + */ + uri: string; + }; +} + +/** + * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. + */ +export interface UnsubscribeRequest extends Request { + method: "resources/unsubscribe"; + params: { + /** + * The URI of the resource to unsubscribe from. + * + * @format uri + */ + uri: string; + }; +} + +/** + * 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. + */ +export interface ResourceUpdatedNotification extends Notification { + method: "notifications/resources/updated"; + params: { + /** + * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to. + * + * @format uri + */ + uri: string; + }; +} - /* Resources */ +/** + * A known resource that the server is capable of reading. + */ +export interface Resource extends Annotated { /** - * Sent from the client to request a list of resources the server has. + * The URI of this resource. + * + * @format uri */ - export interface ListResourcesRequest extends PaginatedRequest { - method: "resources/list"; - } + uri: string; /** - * The server's response to a resources/list request from the client. + * A human-readable name for this resource. + * + * This can be used by clients to populate UI elements. */ - export interface ListResourcesResult extends PaginatedResult { - resources: Resource[]; - } + name: string; /** - * Sent from the client to request a list of resource templates the server has. + * A description of what this resource represents. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. */ - export interface ListResourceTemplatesRequest extends PaginatedRequest { - method: "resources/templates/list"; - } + description?: string; /** - * The server's response to a resources/templates/list request from the client. + * The MIME type of this resource, if known. */ - export interface ListResourceTemplatesResult extends PaginatedResult { - resourceTemplates: ResourceTemplate[]; - } + mimeType?: string; +} +/** + * A template description for resources available on the server. + */ +export interface ResourceTemplate extends Annotated { /** - * Sent from the client to the server, to read a specific resource URI. + * A URI template (according to RFC 6570) that can be used to construct resource URIs. + * + * @format uri-template */ - export interface ReadResourceRequest extends Request { - method: "resources/read"; - params: { - /** - * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it. - * - * @format uri - */ - uri: string; - }; - } + uriTemplate: string; /** - * The server's response to a resources/read request from the client. + * A human-readable name for the type of resource this template refers to. + * + * This can be used by clients to populate UI elements. */ - export interface ReadResourceResult extends Result { - contents: (TextResourceContents | BlobResourceContents)[]; - } + name: string; /** - * 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. + * A description of what this template is for. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. */ - export interface ResourceListChangedNotification extends Notification { - method: "notifications/resources/list_changed"; - } + description?: string; /** - * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. + * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type. */ - export interface SubscribeRequest extends Request { - method: "resources/subscribe"; - params: { - /** - * The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it. - * - * @format uri - */ - uri: string; - }; - } + mimeType?: string; +} +/** + * The contents of a specific resource or sub-resource. + */ +export interface ResourceContents { /** - * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. + * The URI of this resource. + * + * @format uri */ - export interface UnsubscribeRequest extends Request { - method: "resources/unsubscribe"; - params: { - /** - * The URI of the resource to unsubscribe from. - * - * @format uri - */ - uri: string; - }; - } - + uri: string; /** - * 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. + * The MIME type of this resource, if known. */ - export interface ResourceUpdatedNotification extends Notification { - method: "notifications/resources/updated"; - params: { - /** - * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to. - * - * @format uri - */ - uri: string; - }; - } + mimeType?: string; +} +export interface TextResourceContents extends ResourceContents { /** - * A known resource that the server is capable of reading. + * The text of the item. This must only be set if the item can actually be represented as text (not binary data). */ - export interface Resource extends Annotated { - /** - * The URI of this resource. - * - * @format uri - */ - uri: string; - - /** - * A human-readable name for this resource. - * - * This can be used by clients to populate UI elements. - */ - name: string; - - /** - * A description of what this resource represents. - * - * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. - */ - description?: string; - - /** - * The MIME type of this resource, if known. - */ - mimeType?: string; - } + text: string; +} +export interface BlobResourceContents extends ResourceContents { /** - * A template description for resources available on the server. + * A base64-encoded string representing the binary data of the item. + * + * @format byte */ - export interface ResourceTemplate extends Annotated { - /** - * A URI template (according to RFC 6570) that can be used to construct resource URIs. - * - * @format uri-template - */ - uriTemplate: string; - - /** - * A human-readable name for the type of resource this template refers to. - * - * This can be used by clients to populate UI elements. - */ - name: string; - - /** - * A description of what this template is for. - * - * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. - */ - description?: string; + blob: string; +} - /** - * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type. - */ - mimeType?: string; - } +/* Prompts */ +/** + * Sent from the client to request a list of prompts and prompt templates the server has. + */ +export interface ListPromptsRequest extends PaginatedRequest { + method: "prompts/list"; +} - /** - * The contents of a specific resource or sub-resource. - */ - export interface ResourceContents { - /** - * The URI of this resource. - * - * @format uri - */ - uri: string; - /** - * The MIME type of this resource, if known. - */ - mimeType?: string; - } +/** + * The server's response to a prompts/list request from the client. + */ +export interface ListPromptsResult extends PaginatedResult { + prompts: Prompt[]; +} - export interface TextResourceContents extends ResourceContents { +/** + * Used by the client to get a prompt provided by the server. + */ +export interface GetPromptRequest extends Request { + method: "prompts/get"; + params: { /** - * The text of the item. This must only be set if the item can actually be represented as text (not binary data). + * The name of the prompt or prompt template. */ - text: string; - } - - export interface BlobResourceContents extends ResourceContents { + name: string; /** - * A base64-encoded string representing the binary data of the item. - * - * @format byte + * Arguments to use for templating the prompt. */ - blob: string; - } + arguments?: { [key: string]: string }; + }; +} - /* Prompts */ +/** + * The server's response to a prompts/get request from the client. + */ +export interface GetPromptResult extends Result { /** - * Sent from the client to request a list of prompts and prompt templates the server has. + * An optional description for the prompt. */ - export interface ListPromptsRequest extends PaginatedRequest { - method: "prompts/list"; - } + description?: string; + messages: PromptMessage[]; +} +/** + * A prompt or prompt template that the server offers. + */ +export interface Prompt { /** - * The server's response to a prompts/list request from the client. + * The name of the prompt or prompt template. */ - export interface ListPromptsResult extends PaginatedResult { - prompts: Prompt[]; - } - + name: string; /** - * Used by the client to get a prompt provided by the server. + * An optional description of what this prompt provides */ - export interface GetPromptRequest extends Request { - method: "prompts/get"; - params: { - /** - * The name of the prompt or prompt template. - */ - name: string; - /** - * Arguments to use for templating the prompt. - */ - arguments?: { [key: string]: string }; - }; - } - + description?: string; /** - * The server's response to a prompts/get request from the client. + * A list of arguments to use for templating the prompt. */ - export interface GetPromptResult extends Result { - /** - * An optional description for the prompt. - */ - description?: string; - messages: PromptMessage[]; - } + arguments?: PromptArgument[]; +} +/** + * Describes an argument that a prompt can accept. + */ +export interface PromptArgument { /** - * A prompt or prompt template that the server offers. + * The name of the argument. */ - export interface Prompt { - /** - * The name of the prompt or prompt template. - */ - name: string; - /** - * An optional description of what this prompt provides - */ - description?: string; - /** - * A list of arguments to use for templating the prompt. - */ - arguments?: PromptArgument[]; - } - + name: string; /** - * Describes an argument that a prompt can accept. + * A human-readable description of the argument. */ - export interface PromptArgument { - /** - * The name of the argument. - */ - name: string; - /** - * A human-readable description of the argument. - */ - description?: string; - /** - * Whether this argument must be provided. - */ - required?: boolean; - } - + description?: string; /** - * The sender or recipient of messages and data in a conversation. + * Whether this argument must be provided. */ - export type Role = "user" | "assistant"; + required?: boolean; +} - /** - * Describes a message returned as part of a prompt. - * - * This is similar to `SamplingMessage`, but also supports the embedding of - * resources from the MCP server. - */ - export interface PromptMessage { - role: Role; - content: TextContent | ImageContent | AudioContent | EmbeddedResource; - toolCalls?: ToolCall[]; // Tool calls requested by the the Assistant - toolResult?: ToolResult[]; // Tool responses returned by the User (Host) - } +/** + * The sender or recipient of messages and data in a conversation. + */ +export type Role = "user" | "assistant"; + +/** + * Describes a message returned as part of a prompt. + * + * This is similar to `SamplingMessage`, but also supports the embedding of + * resources from the MCP server. + */ +export interface PromptMessage { + role: Role; + content: TextContent | ImageContent | AudioContent | EmbeddedResource; + toolCalls?: ToolCall[]; // Tool calls requested by the the Assistant + toolResult?: ToolResult[]; // Tool responses returned by the User (Host) +} /** * A tool call initiated by the assistant. */ export interface ToolCall { - /** - * A unique identifier for this tool call. - * This ID is used to match tool calls with their results. - */ - id: string; - - /** - * The name of the tool being called. - */ - name: string; - - /** - * The arguments passed to the tool, as a JSON object. - */ - arguments: { [key: string]: unknown }; +/** + * A unique identifier for this tool call. + * This ID is used to match tool calls with their results. + */ +id: string; + +/** + * The name of the tool being called. + */ +name: string; + +/** + * The arguments passed to the tool, as a JSON object. + */ +arguments: { [key: string]: unknown }; } /** * A result returned from a tool call. */ export interface ToolResult { - /** - * The ID of the tool call this result is for. - * This must match the ID of a previous tool call. - */ - toolCallId: string; - - /** - * The content returned from the tool, typically text. - */ - content: string; +/** + * The ID of the tool call this result is for. + * This must match the ID of a previous tool call. + */ +toolCallId: string; - /** - * Whether the tool call resulted in an error. - * If not specified, assumed to be false. - */ - isError?: boolean; +/** + * The content returned from the tool, typically text. + */ +content: string; + +/** + * Whether the tool call resulted in an error. + * If not specified, assumed to be false. + */ +isError?: boolean; } +/** + * The contents of a resource, embedded into a prompt or tool call result. + * + * It is up to the client how best to render embedded resources for the benefit + * of the LLM and/or the user. + */ +export interface EmbeddedResource extends Annotated { + type: "resource"; + resource: TextResourceContents | BlobResourceContents; +} + +/** + * 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. + */ +export interface PromptListChangedNotification extends Notification { + method: "notifications/prompts/list_changed"; +} + +/* Tools */ +/** + * Sent from the client to request a list of tools the server has. + */ +export interface ListToolsRequest extends PaginatedRequest { + method: "tools/list"; +} + +/** + * The server's response to a tools/list request from the client. + */ +export interface ListToolsResult extends PaginatedResult { + tools: Tool[]; +} + +/** + * The server's response to a tool call. + * + * Any errors that originate from the tool SHOULD be reported inside the result + * object, with `isError` set to true, _not_ as an MCP protocol-level error + * response. Otherwise, the LLM would not be able to see that an error occurred + * and self-correct. + * + * However, any errors in _finding_ the tool, an error indicating that the + * server does not support tool calls, or any other exceptional conditions, + * should be reported as an MCP error response. + */ +export interface CallToolResult extends Result { + content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; + /** - * The contents of a resource, embedded into a prompt or tool call result. + * Whether the tool call ended in an error. * - * It is up to the client how best to render embedded resources for the benefit - * of the LLM and/or the user. + * If not set, this is assumed to be false (the call was successful). */ - export interface EmbeddedResource extends Annotated { - type: "resource"; - resource: TextResourceContents | BlobResourceContents; - } + isError?: boolean; +} - /** - * 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. - */ - export interface PromptListChangedNotification extends Notification { - method: "notifications/prompts/list_changed"; - } +/** + * Used by the client to invoke a tool provided by the server. + */ +export interface CallToolRequest extends Request { + method: "tools/call"; + params: { + name: string; + arguments?: { [key: string]: unknown }; + }; +} - /* Tools */ +/** + * 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. + */ +export interface ToolListChangedNotification extends Notification { + method: "notifications/tools/list_changed"; +} + +/** + * Definition for a tool the client can call. + */ +export interface Tool { /** - * Sent from the client to request a list of tools the server has. + * The name of the tool. */ - export interface ListToolsRequest extends PaginatedRequest { - method: "tools/list"; - } - + name: string; /** - * The server's response to a tools/list request from the client. + * A human-readable description of the tool. */ - export interface ListToolsResult extends PaginatedResult { - tools: Tool[]; - } - + description?: string; /** - * The server's response to a tool call. - * - * Any errors that originate from the tool SHOULD be reported inside the result - * object, with `isError` set to true, _not_ as an MCP protocol-level error - * response. Otherwise, the LLM would not be able to see that an error occurred - * and self-correct. - * - * However, any errors in _finding_ the tool, an error indicating that the - * server does not support tool calls, or any other exceptional conditions, - * should be reported as an MCP error response. + * A JSON Schema object defining the expected parameters for the tool. */ - export interface CallToolResult extends Result { - content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; + inputSchema: { + type: "object"; + properties?: { [key: string]: object }; + required?: string[]; + }; +} +/* Logging */ +/** + * A request from the client to the server, to enable or adjust logging. + */ +export interface SetLevelRequest extends Request { + method: "logging/setLevel"; + params: { /** - * Whether the tool call ended in an error. - * - * If not set, this is assumed to be false (the call was successful). + * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message. */ - isError?: boolean; - } - - /** - * Used by the client to invoke a tool provided by the server. - */ - export interface CallToolRequest extends Request { - method: "tools/call"; - params: { - name: string; - arguments?: { [key: string]: unknown }; - }; - } + level: LoggingLevel; + }; +} - /** - * 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. - */ - export interface ToolListChangedNotification extends Notification { - method: "notifications/tools/list_changed"; - } +/** + * 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. + */ +export interface LoggingMessageNotification extends Notification { + method: "notifications/message"; + params: { + /** + * The severity of this log message. + */ + level: LoggingLevel; + /** + * An optional name of the logger issuing this message. + */ + logger?: string; + /** + * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here. + */ + data: unknown; + }; +} - /** - * Definition for a tool the client can call. - */ - export interface Tool { +/** + * The severity of a log message. + * + * These map to syslog message severities, as specified in RFC-5424: + * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 + */ +export type LoggingLevel = + | "debug" + | "info" + | "notice" + | "warning" + | "error" + | "critical" + | "alert" + | "emergency"; + +/* 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. + */ +export interface CreateMessageRequest extends Request { + method: "sampling/createMessage"; + params: { + messages: SamplingMessage[]; /** - * The name of the tool. + * The server's preferences for which model to select. The client MAY ignore these preferences. */ - name: string; + modelPreferences?: ModelPreferences; /** - * A human-readable description of the tool. + * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt. */ - description?: string; + systemPrompt?: string; /** - * A JSON Schema object defining the expected parameters for the tool. + * 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. */ - inputSchema: { - type: "object"; - properties?: { [key: string]: object }; - required?: string[]; - }; - } + includeContext?: "none" | "thisServer" | "allServers"; + /** + * @TJS-type number + */ + temperature?: number; + /** + * The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested. + */ + maxTokens: number; + stopSequences?: string[]; + /** + * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. + */ + metadata?: object; + }; +} - /* Logging */ +/** + * 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. + */ +export interface CreateMessageResult extends Result, SamplingMessage { /** - * A request from the client to the server, to enable or adjust logging. + * The name of the model that generated the message. */ - export interface SetLevelRequest extends Request { - method: "logging/setLevel"; - params: { - /** - * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message. - */ - level: LoggingLevel; - }; - } - + model: string; /** - * 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. + * The reason why sampling stopped, if known. */ - export interface LoggingMessageNotification extends Notification { - method: "notifications/message"; - params: { - /** - * The severity of this log message. - */ - level: LoggingLevel; - /** - * An optional name of the logger issuing this message. - */ - logger?: string; - /** - * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here. - */ - data: unknown; - }; - } + stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string; +} - /** - * The severity of a log message. - * - * These map to syslog message severities, as specified in RFC-5424: - * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 - */ - export type LoggingLevel = - | "debug" - | "info" - | "notice" - | "warning" - | "error" - | "critical" - | "alert" - | "emergency"; - - /* 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. - */ - export interface CreateMessageRequest extends Request { - method: "sampling/createMessage"; - params: { - messages: SamplingMessage[]; - /** - * The server's preferences for which model to select. The client MAY ignore these preferences. - */ - modelPreferences?: ModelPreferences; - /** - * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt. - */ - 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. - */ - includeContext?: "none" | "thisServer" | "allServers"; - /** - * @TJS-type number - */ - temperature?: number; - /** - * The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested. - */ - maxTokens: number; - stopSequences?: string[]; - /** - * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. - */ - metadata?: object; - }; - } +/** + * Describes a message issued to or received from an LLM API. + */ +export interface SamplingMessage { + role: Role; + content: TextContent | ImageContent | AudioContent; +} - /** - * 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. - */ - export interface CreateMessageResult extends Result, SamplingMessage { +/** + * Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed + */ +export interface Annotated { + annotations?: { /** - * The name of the model that generated the message. + * Describes who the intended customer of this object or data is. + * + * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). */ - model: string; + audience?: Role[]; + /** - * The reason why sampling stopped, if known. + * Describes how important this data is for operating the server. + * + * A value of 1 means "most important," and indicates that the data is + * effectively required, while 0 means "least important," and indicates that + * the data is entirely optional. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 */ - stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string; + priority?: number; } +} +/** + * Text provided to or from an LLM. + */ +export interface TextContent extends Annotated { + type: "text"; /** - * Describes a message issued to or received from an LLM API. + * The text content of the message. */ - export interface SamplingMessage { - role: Role; - content: TextContent | ImageContent | AudioContent; - } + text: string; +} +/** + * An image provided to or from an LLM. + */ +export interface ImageContent extends Annotated { + type: "image"; /** - * Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed + * The base64-encoded image data. + * + * @format byte */ - export interface Annotated { - annotations?: { - /** - * Describes who the intended customer of this object or data is. - * - * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). - */ - audience?: Role[]; - - /** - * Describes how important this data is for operating the server. - * - * A value of 1 means "most important," and indicates that the data is - * effectively required, while 0 means "least important," and indicates that - * the data is entirely optional. - * - * @TJS-type number - * @minimum 0 - * @maximum 1 - */ - priority?: number; - } - } - + data: string; /** - * Text provided to or from an LLM. + * The MIME type of the image. Different providers may support different image types. */ - export interface TextContent extends Annotated { - type: "text"; - /** - * The text content of the message. - */ - text: string; - } + mimeType: string; +} + +/** + * Audio provided to or from an LLM. + */ +export interface AudioContent extends Annotated { + type: "audio"; /** - * An image provided to or from an LLM. + * The base64-encoded audio data. + * + * @format byte */ - export interface ImageContent extends Annotated { - type: "image"; - /** - * The base64-encoded image data. - * - * @format byte - */ - data: string; - /** - * The MIME type of the image. Different providers may support different image types. - */ - mimeType: string; - } - - + data: string; /** - * Audio provided to or from an LLM. + * The MIME type of the audio. Different providers may support different audio types. */ - export interface AudioContent extends Annotated { - type: "audio"; - /** - * The base64-encoded audio data. - * - * @format byte - */ - data: string; - /** - * The MIME type of the audio. Different providers may support different audio types. - */ - mimeType: string; - } + mimeType: string; +} +/** + * The server's preferences for model selection, requested of the client during sampling. + * + * Because LLMs can vary along multiple dimensions, choosing the "best" model is + * rarely straightforward. Different models excel in different areas—some are + * faster but less capable, others are more capable but more expensive, and so + * on. This interface allows servers to express their priorities across multiple + * dimensions to help clients make an appropriate selection for their use case. + * + * 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. + */ +export interface ModelPreferences { /** - * The server's preferences for model selection, requested of the client during sampling. + * Optional hints to use for model selection. * - * Because LLMs can vary along multiple dimensions, choosing the "best" model is - * rarely straightforward. Different models excel in different areas—some are - * faster but less capable, others are more capable but more expensive, and so - * on. This interface allows servers to express their priorities across multiple - * dimensions to help clients make an appropriate selection for their use case. + * If multiple hints are specified, the client MUST evaluate them in order + * (such that the first match is taken). * - * 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. + * The client SHOULD prioritize these hints over the numeric priorities, but + * MAY still use the priorities to select from ambiguous matches. */ - export interface ModelPreferences { - /** - * Optional hints to use for model selection. - * - * If multiple hints are specified, the client MUST evaluate them in order - * (such that the first match is taken). - * - * The client SHOULD prioritize these hints over the numeric priorities, but - * MAY still use the priorities to select from ambiguous matches. - */ - hints?: ModelHint[]; - - /** - * How much to prioritize cost when selecting a model. A value of 0 means cost - * is not important, while a value of 1 means cost is the most important - * factor. - * - * @TJS-type number - * @minimum 0 - * @maximum 1 - */ - costPriority?: number; + hints?: ModelHint[]; - /** - * How much to prioritize sampling speed (latency) when selecting a model. A - * value of 0 means speed is not important, while a value of 1 means speed is - * the most important factor. - * - * @TJS-type number - * @minimum 0 - * @maximum 1 - */ - speedPriority?: number; - - /** - * How much to prioritize intelligence and capabilities when selecting a - * model. A value of 0 means intelligence is not important, while a value of 1 - * means intelligence is the most important factor. - * - * @TJS-type number - * @minimum 0 - * @maximum 1 - */ - intelligencePriority?: number; - } + /** + * How much to prioritize cost when selecting a model. A value of 0 means cost + * is not important, while a value of 1 means cost is the most important + * factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + costPriority?: number; /** - * Hints to use for model selection. + * How much to prioritize sampling speed (latency) when selecting a model. A + * value of 0 means speed is not important, while a value of 1 means speed is + * the most important factor. * - * Keys not declared here are currently left unspecified by the spec and are up - * to the client to interpret. + * @TJS-type number + * @minimum 0 + * @maximum 1 */ - export interface ModelHint { - /** - * A hint for a model name. - * - * The client SHOULD treat this as a substring of a model name; for example: - * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022` - * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc. - * - `claude` should match any Claude model - * - * The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example: - * - `gemini-1.5-flash` could match `claude-3-haiku-20240307` - */ - name?: string; - } + speedPriority?: number; - /* Autocomplete */ /** - * A request from the client to the server, to ask for completion options. + * How much to prioritize intelligence and capabilities when selecting a + * model. A value of 0 means intelligence is not important, while a value of 1 + * means intelligence is the most important factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 */ - export interface CompleteRequest extends Request { - method: "completion/complete"; - params: { - ref: PromptReference | ResourceReference; - /** - * The argument's information - */ - argument: { - /** - * The name of the argument - */ - name: string; - /** - * The value of the argument to use for completion matching. - */ - value: string; - }; - }; - } + intelligencePriority?: number; +} +/** + * Hints to use for model selection. + * + * Keys not declared here are currently left unspecified by the spec and are up + * to the client to interpret. + */ +export interface ModelHint { /** - * The server's response to a completion/complete request + * A hint for a model name. + * + * The client SHOULD treat this as a substring of a model name; for example: + * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022` + * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc. + * - `claude` should match any Claude model + * + * The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example: + * - `gemini-1.5-flash` could match `claude-3-haiku-20240307` */ - export interface CompleteResult extends Result { - completion: { - /** - * An array of completion values. Must not exceed 100 items. - */ - values: string[]; + name?: string; +} + +/* Autocomplete */ +/** + * A request from the client to the server, to ask for completion options. + */ +export interface CompleteRequest extends Request { + method: "completion/complete"; + params: { + ref: PromptReference | ResourceReference; + /** + * The argument's information + */ + argument: { /** - * The total number of completion options available. This can exceed the number of values actually sent in the response. + * The name of the argument */ - total?: number; + name: string; /** - * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown. + * The value of the argument to use for completion matching. */ - hasMore?: boolean; + value: string; }; - } + }; +} - /** - * A reference to a resource or resource template definition. - */ - export interface ResourceReference { - type: "ref/resource"; +/** + * The server's response to a completion/complete request + */ +export interface CompleteResult extends Result { + completion: { /** - * The URI or URI template of the resource. - * - * @format uri-template + * An array of completion values. Must not exceed 100 items. */ - uri: string; - } - - /** - * Identifies a prompt. - */ - export interface PromptReference { - type: "ref/prompt"; + values: string[]; /** - * The name of the prompt or prompt template + * The total number of completion options available. This can exceed the number of values actually sent in the response. */ - name: string; - } + total?: number; + /** + * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown. + */ + hasMore?: boolean; + }; +} - /* Roots */ +/** + * A reference to a resource or resource template definition. + */ +export interface ResourceReference { + type: "ref/resource"; /** - * Sent from the server to request a list of root URIs from the client. Roots allow - * servers to ask for specific directories or files to operate on. A common example - * for roots is providing a set of repositories or directories a server should operate - * on. + * The URI or URI template of the resource. * - * 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. + * @format uri-template */ - export interface ListRootsRequest extends Request { - method: "roots/list"; - } + uri: string; +} +/** + * Identifies a prompt. + */ +export interface PromptReference { + type: "ref/prompt"; /** - * 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. + * The name of the prompt or prompt template */ - export interface ListRootsResult extends Result { - roots: Root[]; - } + name: string; +} +/* Roots */ +/** + * Sent from the server to request a list of root URIs from the client. Roots allow + * servers to ask for specific directories or files to operate on. A common example + * for roots is providing a set of repositories or directories a server should operate + * on. + * + * 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. + */ +export interface ListRootsRequest extends Request { + method: "roots/list"; +} + +/** + * 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. + */ +export interface ListRootsResult extends Result { + roots: Root[]; +} + +/** + * Represents a root directory or file that the server can operate on. + */ +export interface Root { /** - * Represents a root directory or file that the server can operate on. + * The URI identifying the root. This *must* start with file:// for now. + * This restriction may be relaxed in future versions of the protocol to allow + * other URI schemes. + * + * @format uri */ - export interface Root { - /** - * The URI identifying the root. This *must* start with file:// for now. - * This restriction may be relaxed in future versions of the protocol to allow - * other URI schemes. - * - * @format uri - */ - uri: string; - /** - * An optional name for the root. This can be used to provide a human-readable - * identifier for the root, which may be useful for display purposes or for - * referencing the root in other parts of the application. - */ - name?: string; - } - + uri: string; /** - * 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. + * An optional name for the root. This can be used to provide a human-readable + * identifier for the root, which may be useful for display purposes or for + * referencing the root in other parts of the application. */ - export interface RootsListChangedNotification extends Notification { - method: "notifications/roots/list_changed"; - } + name?: string; +} + +/** + * 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. + */ +export interface RootsListChangedNotification extends Notification { + method: "notifications/roots/list_changed"; +} - /* Client messages */ - export type ClientRequest = - | PingRequest - | InitializeRequest - | CompleteRequest - | SetLevelRequest - | GetPromptRequest - | ListPromptsRequest - | ListResourcesRequest - | ReadResourceRequest - | SubscribeRequest - | UnsubscribeRequest - | CallToolRequest - | ListToolsRequest; - - export type ClientNotification = - | CancelledNotification - | ProgressNotification - | InitializedNotification - | RootsListChangedNotification; - - export type ClientResult = EmptyResult | CreateMessageResult | ListRootsResult; - - /* Server messages */ - export type ServerRequest = - | PingRequest - | CreateMessageRequest - | ListRootsRequest; - - export type ServerNotification = - | CancelledNotification - | ProgressNotification - | LoggingMessageNotification - | ResourceUpdatedNotification - | ResourceListChangedNotification - | ToolListChangedNotification - | PromptListChangedNotification; - - export type ServerResult = - | EmptyResult - | InitializeResult - | CompleteResult - | GetPromptResult - | ListPromptsResult - | ListResourcesResult - | ReadResourceResult - | CallToolResult - | ListToolsResult; +/* Client messages */ +export type ClientRequest = + | PingRequest + | InitializeRequest + | CompleteRequest + | SetLevelRequest + | GetPromptRequest + | ListPromptsRequest + | ListResourcesRequest + | ReadResourceRequest + | SubscribeRequest + | UnsubscribeRequest + | CallToolRequest + | ListToolsRequest; + +export type ClientNotification = + | CancelledNotification + | ProgressNotification + | InitializedNotification + | RootsListChangedNotification; + +export type ClientResult = EmptyResult | CreateMessageResult | ListRootsResult; + +/* Server messages */ +export type ServerRequest = + | PingRequest + | CreateMessageRequest + | ListRootsRequest; + +export type ServerNotification = + | CancelledNotification + | ProgressNotification + | LoggingMessageNotification + | ResourceUpdatedNotification + | ResourceListChangedNotification + | ToolListChangedNotification + | PromptListChangedNotification; + +export type ServerResult = + | EmptyResult + | InitializeResult + | CompleteResult + | GetPromptResult + | ListPromptsResult + | ListResourcesResult + | ReadResourceResult + | CallToolResult + | ListToolsResult;