Path: blob/main/src/vs/workbench/contrib/mcp/common/modelContextProtocol.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45/* eslint-disable local/code-no-unexternalized-strings */67//#region proposals8/**9* MCP protocol proposals.10* - Proposals here MUST have an MCP PR linked to them11* - Proposals here are subject to change and SHALL be removed when12* the upstream MCP PR is merged or closed.13*/14export namespace MCP {1516// Nothing, yet1718}1920//#endregion2122/**23* Schema updated from the Model Context Protocol repository at24* https://github.com/modelcontextprotocol/specification/tree/main/schema25*26* ⚠️ Do not edit within `namespace` manually except to update schema versions ⚠️27*/28export namespace MCP {29/**30* Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.31*/32export type JSONRPCMessage =33| JSONRPCRequest34| JSONRPCNotification35| JSONRPCResponse36| JSONRPCError;3738export const LATEST_PROTOCOL_VERSION = "2025-06-18";39export const JSONRPC_VERSION = "2.0";4041/**42* A progress token, used to associate progress notifications with the original request.43*/44export type ProgressToken = string | number;4546/**47* An opaque token used to represent a cursor for pagination.48*/49export type Cursor = string;5051export interface Request {52method: string;53params?: {54/**55* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.56*/57_meta?: {58/**59* 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.60*/61progressToken?: ProgressToken;62[key: string]: unknown;63};64[key: string]: unknown;65};66}6768export interface Notification {69method: string;70params?: {71/**72* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.73*/74_meta?: { [key: string]: unknown };75[key: string]: unknown;76};77}7879export interface Result {80/**81* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.82*/83_meta?: { [key: string]: unknown };84[key: string]: unknown;85}8687/**88* A uniquely identifying ID for a request in JSON-RPC.89*/90export type RequestId = string | number;9192/**93* A request that expects a response.94*/95export interface JSONRPCRequest extends Request {96jsonrpc: typeof JSONRPC_VERSION;97id: RequestId;98}99100/**101* A notification which does not expect a response.102*/103export interface JSONRPCNotification extends Notification {104jsonrpc: typeof JSONRPC_VERSION;105}106107/**108* A successful (non-error) response to a request.109*/110export interface JSONRPCResponse {111jsonrpc: typeof JSONRPC_VERSION;112id: RequestId;113result: Result;114}115116// Standard JSON-RPC error codes117export const PARSE_ERROR = -32700;118export const INVALID_REQUEST = -32600;119export const METHOD_NOT_FOUND = -32601;120export const INVALID_PARAMS = -32602;121export const INTERNAL_ERROR = -32603;122123/**124* A response to a request that indicates an error occurred.125*/126export interface JSONRPCError {127jsonrpc: typeof JSONRPC_VERSION;128id: RequestId;129error: {130/**131* The error type that occurred.132*/133code: number;134/**135* A short description of the error. The message SHOULD be limited to a concise single sentence.136*/137message: string;138/**139* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).140*/141data?: unknown;142};143}144145/* Empty result */146/**147* A response that indicates success but carries no data.148*/149export type EmptyResult = Result;150151/* Cancellation */152/**153* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.154*155* 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.156*157* This notification indicates that the result will be unused, so any associated processing SHOULD cease.158*159* A client MUST NOT attempt to cancel its `initialize` request.160*/161export interface CancelledNotification extends Notification {162method: "notifications/cancelled";163params: {164/**165* The ID of the request to cancel.166*167* This MUST correspond to the ID of a request previously issued in the same direction.168*/169requestId: RequestId;170171/**172* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.173*/174reason?: string;175};176}177178/* Initialization */179/**180* This request is sent from the client to the server when it first connects, asking it to begin initialization.181*/182export interface InitializeRequest extends Request {183method: "initialize";184params: {185/**186* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.187*/188protocolVersion: string;189capabilities: ClientCapabilities;190clientInfo: Implementation;191};192}193194/**195* After receiving an initialize request from the client, the server sends this response.196*/197export interface InitializeResult extends Result {198/**199* 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.200*/201protocolVersion: string;202capabilities: ServerCapabilities;203serverInfo: Implementation;204205/**206* Instructions describing how to use the server and its features.207*208* 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.209*/210instructions?: string;211}212213/**214* This notification is sent from the client to the server after initialization has finished.215*/216export interface InitializedNotification extends Notification {217method: "notifications/initialized";218}219220/**221* 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.222*/223export interface ClientCapabilities {224/**225* Experimental, non-standard capabilities that the client supports.226*/227experimental?: { [key: string]: object };228/**229* Present if the client supports listing roots.230*/231roots?: {232/**233* Whether the client supports notifications for changes to the roots list.234*/235listChanged?: boolean;236};237/**238* Present if the client supports sampling from an LLM.239*/240sampling?: object;241/**242* Present if the client supports elicitation from the server.243*/244elicitation?: object;245}246247/**248* 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.249*/250export interface ServerCapabilities {251/**252* Experimental, non-standard capabilities that the server supports.253*/254experimental?: { [key: string]: object };255/**256* Present if the server supports sending log messages to the client.257*/258logging?: object;259/**260* Present if the server supports argument autocompletion suggestions.261*/262completions?: object;263/**264* Present if the server offers any prompt templates.265*/266prompts?: {267/**268* Whether this server supports notifications for changes to the prompt list.269*/270listChanged?: boolean;271};272/**273* Present if the server offers any resources to read.274*/275resources?: {276/**277* Whether this server supports subscribing to resource updates.278*/279subscribe?: boolean;280/**281* Whether this server supports notifications for changes to the resource list.282*/283listChanged?: boolean;284};285/**286* Present if the server offers any tools to call.287*/288tools?: {289/**290* Whether this server supports notifications for changes to the tool list.291*/292listChanged?: boolean;293};294}295296/**297* Base interface for metadata with name (identifier) and title (display name) properties.298*/299export interface BaseMetadata {300/**301* Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).302*/303name: string;304305/**306* Intended for UI and end-user contexts - optimized to be human-readable and easily understood,307* even by those unfamiliar with domain-specific terminology.308*309* If not provided, the name should be used for display (except for Tool,310* where `annotations.title` should be given precedence over using `name`,311* if present).312*/313title?: string;314}315316/**317* Describes the name and version of an MCP implementation, with an optional title for UI representation.318*/319export interface Implementation extends BaseMetadata {320version: string;321}322323/* Ping */324/**325* 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.326*/327export interface PingRequest extends Request {328method: "ping";329}330331/* Progress notifications */332/**333* An out-of-band notification used to inform the receiver of a progress update for a long-running request.334*/335export interface ProgressNotification extends Notification {336method: "notifications/progress";337params: {338/**339* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.340*/341progressToken: ProgressToken;342/**343* The progress thus far. This should increase every time progress is made, even if the total is unknown.344*345* @TJS-type number346*/347progress: number;348/**349* Total number of items to process (or total progress required), if known.350*351* @TJS-type number352*/353total?: number;354/**355* An optional message describing the current progress.356*/357message?: string;358};359}360361/* Pagination */362export interface PaginatedRequest extends Request {363params?: {364/**365* An opaque token representing the current pagination position.366* If provided, the server should return results starting after this cursor.367*/368cursor?: Cursor;369};370}371372export interface PaginatedResult extends Result {373/**374* An opaque token representing the pagination position after the last returned result.375* If present, there may be more results available.376*/377nextCursor?: Cursor;378}379380/* Resources */381/**382* Sent from the client to request a list of resources the server has.383*/384export interface ListResourcesRequest extends PaginatedRequest {385method: "resources/list";386}387388/**389* The server's response to a resources/list request from the client.390*/391export interface ListResourcesResult extends PaginatedResult {392resources: Resource[];393}394395/**396* Sent from the client to request a list of resource templates the server has.397*/398export interface ListResourceTemplatesRequest extends PaginatedRequest {399method: "resources/templates/list";400}401402/**403* The server's response to a resources/templates/list request from the client.404*/405export interface ListResourceTemplatesResult extends PaginatedResult {406resourceTemplates: ResourceTemplate[];407}408409/**410* Sent from the client to the server, to read a specific resource URI.411*/412export interface ReadResourceRequest extends Request {413method: "resources/read";414params: {415/**416* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.417*418* @format uri419*/420uri: string;421};422}423424/**425* The server's response to a resources/read request from the client.426*/427export interface ReadResourceResult extends Result {428contents: (TextResourceContents | BlobResourceContents)[];429}430431/**432* 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.433*/434export interface ResourceListChangedNotification extends Notification {435method: "notifications/resources/list_changed";436}437438/**439* Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.440*/441export interface SubscribeRequest extends Request {442method: "resources/subscribe";443params: {444/**445* The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.446*447* @format uri448*/449uri: string;450};451}452453/**454* Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.455*/456export interface UnsubscribeRequest extends Request {457method: "resources/unsubscribe";458params: {459/**460* The URI of the resource to unsubscribe from.461*462* @format uri463*/464uri: string;465};466}467468/**469* 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.470*/471export interface ResourceUpdatedNotification extends Notification {472method: "notifications/resources/updated";473params: {474/**475* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.476*477* @format uri478*/479uri: string;480};481}482483/**484* A known resource that the server is capable of reading.485*/486export interface Resource extends BaseMetadata {487/**488* The URI of this resource.489*490* @format uri491*/492uri: string;493494/**495* A description of what this resource represents.496*497* 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.498*/499description?: string;500501/**502* The MIME type of this resource, if known.503*/504mimeType?: string;505506/**507* Optional annotations for the client.508*/509annotations?: Annotations;510511/**512* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.513*514* This can be used by Hosts to display file sizes and estimate context window usage.515*/516size?: number;517518/**519* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.520*/521_meta?: { [key: string]: unknown };522}523524/**525* A template description for resources available on the server.526*/527export interface ResourceTemplate extends BaseMetadata {528/**529* A URI template (according to RFC 6570) that can be used to construct resource URIs.530*531* @format uri-template532*/533uriTemplate: string;534535/**536* A description of what this template is for.537*538* 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.539*/540description?: string;541542/**543* 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.544*/545mimeType?: string;546547/**548* Optional annotations for the client.549*/550annotations?: Annotations;551552/**553* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.554*/555_meta?: { [key: string]: unknown };556}557558/**559* The contents of a specific resource or sub-resource.560*/561export interface ResourceContents {562/**563* The URI of this resource.564*565* @format uri566*/567uri: string;568/**569* The MIME type of this resource, if known.570*/571mimeType?: string;572573/**574* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.575*/576_meta?: { [key: string]: unknown };577}578579export interface TextResourceContents extends ResourceContents {580/**581* The text of the item. This must only be set if the item can actually be represented as text (not binary data).582*/583text: string;584}585586export interface BlobResourceContents extends ResourceContents {587/**588* A base64-encoded string representing the binary data of the item.589*590* @format byte591*/592blob: string;593}594595/* Prompts */596/**597* Sent from the client to request a list of prompts and prompt templates the server has.598*/599export interface ListPromptsRequest extends PaginatedRequest {600method: "prompts/list";601}602603/**604* The server's response to a prompts/list request from the client.605*/606export interface ListPromptsResult extends PaginatedResult {607prompts: Prompt[];608}609610/**611* Used by the client to get a prompt provided by the server.612*/613export interface GetPromptRequest extends Request {614method: "prompts/get";615params: {616/**617* The name of the prompt or prompt template.618*/619name: string;620/**621* Arguments to use for templating the prompt.622*/623arguments?: { [key: string]: string };624};625}626627/**628* The server's response to a prompts/get request from the client.629*/630export interface GetPromptResult extends Result {631/**632* An optional description for the prompt.633*/634description?: string;635messages: PromptMessage[];636}637638/**639* A prompt or prompt template that the server offers.640*/641export interface Prompt extends BaseMetadata {642/**643* An optional description of what this prompt provides644*/645description?: string;646/**647* A list of arguments to use for templating the prompt.648*/649arguments?: PromptArgument[];650651/**652* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.653*/654_meta?: { [key: string]: unknown };655}656657/**658* Describes an argument that a prompt can accept.659*/660export interface PromptArgument extends BaseMetadata {661/**662* A human-readable description of the argument.663*/664description?: string;665/**666* Whether this argument must be provided.667*/668required?: boolean;669}670671/**672* The sender or recipient of messages and data in a conversation.673*/674export type Role = "user" | "assistant";675676/**677* Describes a message returned as part of a prompt.678*679* This is similar to ` */680export interface PromptMessage {681role: Role;682content: ContentBlock;683}684685/**686* A resource that the server is capable of reading, included in a prompt or tool call result.687*688* Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.689*/690export interface ResourceLink extends Resource {691type: "resource_link";692}693694/**695* The contents of a resource, embedded into a prompt or tool call result.696*697* It is up to the client how best to render embedded resources for the benefit698* of the LLM and/or the user.699*/700export interface EmbeddedResource {701type: "resource";702resource: TextResourceContents | BlobResourceContents;703704/**705* Optional annotations for the client.706*/707annotations?: Annotations;708709/**710* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.711*/712_meta?: { [key: string]: unknown };713}714/**715* 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.716*/717export interface PromptListChangedNotification extends Notification {718method: "notifications/prompts/list_changed";719}720721/* Tools */722/**723* Sent from the client to request a list of tools the server has.724*/725export interface ListToolsRequest extends PaginatedRequest {726method: "tools/list";727}728729/**730* The server's response to a tools/list request from the client.731*/732export interface ListToolsResult extends PaginatedResult {733tools: Tool[];734}735736/**737* The server's response to a tool call.738*/739export interface CallToolResult extends Result {740/**741* A list of content objects that represent the unstructured result of the tool call.742*/743content: ContentBlock[];744745/**746* An optional JSON object that represents the structured result of the tool call.747*/748structuredContent?: { [key: string]: unknown };749750/**751* Whether the tool call ended in an error.752*753* If not set, this is assumed to be false (the call was successful).754*755* Any errors that originate from the tool SHOULD be reported inside the result756* object, with `isError` set to true, _not_ as an MCP protocol-level error757* response. Otherwise, the LLM would not be able to see that an error occurred758* and self-correct.759*760* However, any errors in _finding_ the tool, an error indicating that the761* server does not support tool calls, or any other exceptional conditions,762* should be reported as an MCP error response.763*/764isError?: boolean;765}766767/**768* Used by the client to invoke a tool provided by the server.769*/770export interface CallToolRequest extends Request {771method: "tools/call";772params: {773name: string;774arguments?: { [key: string]: unknown };775};776}777778/**779* 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.780*/781export interface ToolListChangedNotification extends Notification {782method: "notifications/tools/list_changed";783}784785/**786* Additional properties describing a Tool to clients.787*788* NOTE: all properties in ToolAnnotations are **hints**.789* They are not guaranteed to provide a faithful description of790* tool behavior (including descriptive properties like `title`).791*792* Clients should never make tool use decisions based on ToolAnnotations793* received from untrusted servers.794*/795export interface ToolAnnotations {796/**797* A human-readable title for the tool.798*/799title?: string;800801/**802* If true, the tool does not modify its environment.803*804* Default: false805*/806readOnlyHint?: boolean;807808/**809* If true, the tool may perform destructive updates to its environment.810* If false, the tool performs only additive updates.811*812* (This property is meaningful only when `readOnlyHint == false`)813*814* Default: true815*/816destructiveHint?: boolean;817818/**819* If true, calling the tool repeatedly with the same arguments820* will have no additional effect on the its environment.821*822* (This property is meaningful only when `readOnlyHint == false`)823*824* Default: false825*/826idempotentHint?: boolean;827828/**829* If true, this tool may interact with an "open world" of external830* entities. If false, the tool's domain of interaction is closed.831* For example, the world of a web search tool is open, whereas that832* of a memory tool is not.833*834* Default: true835*/836openWorldHint?: boolean;837}838839/**840* Definition for a tool the client can call.841*/842export interface Tool extends BaseMetadata {843/**844* A human-readable description of the tool.845*846* This can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a "hint" to the model.847*/848description?: string;849850/**851* A JSON Schema object defining the expected parameters for the tool.852*/853inputSchema: {854type: "object";855properties?: { [key: string]: object };856required?: string[];857};858859/**860* An optional JSON Schema object defining the structure of the tool's output returned in861* the structuredContent field of a CallToolResult.862*/863outputSchema?: {864type: "object";865properties?: { [key: string]: object };866required?: string[];867};868869/**870* Optional additional tool information.871*872* Display name precedence order is: title, annotations.title, then name.873*/874annotations?: ToolAnnotations;875876/**877* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.878*/879_meta?: { [key: string]: unknown };880}881882/* Logging */883/**884* A request from the client to the server, to enable or adjust logging.885*/886export interface SetLevelRequest extends Request {887method: "logging/setLevel";888params: {889/**890* 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.891*/892level: LoggingLevel;893};894}895896/**897* 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.898*/899export interface LoggingMessageNotification extends Notification {900method: "notifications/message";901params: {902/**903* The severity of this log message.904*/905level: LoggingLevel;906/**907* An optional name of the logger issuing this message.908*/909logger?: string;910/**911* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.912*/913data: unknown;914};915}916917/**918* The severity of a log message.919*920* These map to syslog message severities, as specified in RFC-5424:921* https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1922*/923export type LoggingLevel =924| "debug"925| "info"926| "notice"927| "warning"928| "error"929| "critical"930| "alert"931| "emergency";932933/* Sampling */934/**935* 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.936*/937export interface CreateMessageRequest extends Request {938method: "sampling/createMessage";939params: {940messages: SamplingMessage[];941/**942* The server's preferences for which model to select. The client MAY ignore these preferences.943*/944modelPreferences?: ModelPreferences;945/**946* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.947*/948systemPrompt?: string;949/**950* 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.951*/952includeContext?: "none" | "thisServer" | "allServers";953/**954* @TJS-type number955*/956temperature?: number;957/**958* The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.959*/960maxTokens: number;961stopSequences?: string[];962/**963* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.964*/965metadata?: object;966};967}968969/**970* 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.971*/972export interface CreateMessageResult extends Result, SamplingMessage {973/**974* The name of the model that generated the message.975*/976model: string;977/**978* The reason why sampling stopped, if known.979*/980stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string;981}982983/**984* Describes a message issued to or received from an LLM API.985*/986export interface SamplingMessage {987role: Role;988content: TextContent | ImageContent | AudioContent;989}990991/**992* Optional annotations for the client. The client can use annotations to inform how objects are used or displayed993*/994export interface Annotations {995/**996* Describes who the intended customer of this object or data is.997*998* It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).999*/1000audience?: Role[];10011002/**1003* Describes how important this data is for operating the server.1004*1005* A value of 1 means "most important," and indicates that the data is1006* effectively required, while 0 means "least important," and indicates that1007* the data is entirely optional.1008*1009* @TJS-type number1010* @minimum 01011* @maximum 11012*/1013priority?: number;10141015/**1016* The moment the resource was last modified, as an ISO 8601 formatted string.1017*1018* Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z").1019*1020* Examples: last activity timestamp in an open file, timestamp when the resource1021* was attached, etc.1022*/1023lastModified?: string;1024}10251026/** */1027export type ContentBlock =1028| TextContent1029| ImageContent1030| AudioContent1031| ResourceLink1032| EmbeddedResource;10331034/**1035* Text provided to or from an LLM.1036*/1037export interface TextContent {1038type: "text";10391040/**1041* The text content of the message.1042*/1043text: string;10441045/**1046* Optional annotations for the client.1047*/1048annotations?: Annotations;10491050/**1051* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.1052*/1053_meta?: { [key: string]: unknown };1054}10551056/**1057* An image provided to or from an LLM.1058*/1059export interface ImageContent {1060type: "image";10611062/**1063* The base64-encoded image data.1064*1065* @format byte1066*/1067data: string;10681069/**1070* The MIME type of the image. Different providers may support different image types.1071*/1072mimeType: string;10731074/**1075* Optional annotations for the client.1076*/1077annotations?: Annotations;10781079/**1080* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.1081*/1082_meta?: { [key: string]: unknown };1083}10841085/**1086* Audio provided to or from an LLM.1087*/1088export interface AudioContent {1089type: "audio";10901091/**1092* The base64-encoded audio data.1093*1094* @format byte1095*/1096data: string;10971098/**1099* The MIME type of the audio. Different providers may support different audio types.1100*/1101mimeType: string;11021103/**1104* Optional annotations for the client.1105*/1106annotations?: Annotations;11071108/**1109* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.1110*/1111_meta?: { [key: string]: unknown };1112}11131114/**1115* The server's preferences for model selection, requested of the client during sampling.1116*1117* Because LLMs can vary along multiple dimensions, choosing the "best" model is1118* rarely straightforward. Different models excel in different areas-some are1119* faster but less capable, others are more capable but more expensive, and so1120* on. This interface allows servers to express their priorities across multiple1121* dimensions to help clients make an appropriate selection for their use case.1122*1123* These preferences are always advisory. The client MAY ignore them. It is also1124* up to the client to decide how to interpret these preferences and how to1125* balance them against other considerations.1126*/1127export interface ModelPreferences {1128/**1129* Optional hints to use for model selection.1130*1131* If multiple hints are specified, the client MUST evaluate them in order1132* (such that the first match is taken).1133*1134* The client SHOULD prioritize these hints over the numeric priorities, but1135* MAY still use the priorities to select from ambiguous matches.1136*/1137hints?: ModelHint[];11381139/**1140* How much to prioritize cost when selecting a model. A value of 0 means cost1141* is not important, while a value of 1 means cost is the most important1142* factor.1143*1144* @TJS-type number1145* @minimum 01146* @maximum 11147*/1148costPriority?: number;11491150/**1151* How much to prioritize sampling speed (latency) when selecting a model. A1152* value of 0 means speed is not important, while a value of 1 means speed is1153* the most important factor.1154*1155* @TJS-type number1156* @minimum 01157* @maximum 11158*/1159speedPriority?: number;11601161/**1162* How much to prioritize intelligence and capabilities when selecting a1163* model. A value of 0 means intelligence is not important, while a value of 11164* means intelligence is the most important factor.1165*1166* @TJS-type number1167* @minimum 01168* @maximum 11169*/1170intelligencePriority?: number;1171}11721173/**1174* Hints to use for model selection.1175*1176* Keys not declared here are currently left unspecified by the spec and are up1177* to the client to interpret.1178*/1179export interface ModelHint {1180/**1181* A hint for a model name.1182*1183* The client SHOULD treat this as a substring of a model name; for example:1184* - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`1185* - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.1186* - `claude` should match any Claude model1187*1188* 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:1189* - `gemini-1.5-flash` could match `claude-3-haiku-20240307`1190*/1191name?: string;1192}11931194/* Autocomplete */1195/**1196* A request from the client to the server, to ask for completion options.1197*/1198export interface CompleteRequest extends Request {1199method: "completion/complete";1200params: {1201ref: PromptReference | ResourceTemplateReference;1202/**1203* The argument's information1204*/1205argument: {1206/**1207* The name of the argument1208*/1209name: string;1210/**1211* The value of the argument to use for completion matching.1212*/1213value: string;1214};12151216/**1217* Additional, optional context for completions1218*/1219context?: {1220/**1221* Previously-resolved variables in a URI template or prompt.1222*/1223arguments?: { [key: string]: string };1224};1225};1226}12271228/**1229* The server's response to a completion/complete request1230*/1231export interface CompleteResult extends Result {1232completion: {1233/**1234* An array of completion values. Must not exceed 100 items.1235*/1236values: string[];1237/**1238* The total number of completion options available. This can exceed the number of values actually sent in the response.1239*/1240total?: number;1241/**1242* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.1243*/1244hasMore?: boolean;1245};1246}12471248/**1249* A reference to a resource or resource template definition.1250*/1251export interface ResourceTemplateReference {1252type: "ref/resource";1253/**1254* The URI or URI template of the resource.1255*1256* @format uri-template1257*/1258uri: string;1259}12601261/**1262* Identifies a prompt.1263*/1264export interface PromptReference extends BaseMetadata {1265type: "ref/prompt";1266}12671268/* Roots */1269/**1270* Sent from the server to request a list of root URIs from the client. Roots allow1271* servers to ask for specific directories or files to operate on. A common example1272* for roots is providing a set of repositories or directories a server should operate1273* on.1274*1275* This request is typically used when the server needs to understand the file system1276* structure or access specific locations that the client has permission to read from.1277*/1278export interface ListRootsRequest extends Request {1279method: "roots/list";1280}12811282/**1283* The client's response to a roots/list request from the server.1284* This result contains an array of Root objects, each representing a root directory1285* or file that the server can operate on.1286*/1287export interface ListRootsResult extends Result {1288roots: Root[];1289}12901291/**1292* Represents a root directory or file that the server can operate on.1293*/1294export interface Root {1295/**1296* The URI identifying the root. This *must* start with file:// for now.1297* This restriction may be relaxed in future versions of the protocol to allow1298* other URI schemes.1299*1300* @format uri1301*/1302uri: string;1303/**1304* An optional name for the root. This can be used to provide a human-readable1305* identifier for the root, which may be useful for display purposes or for1306* referencing the root in other parts of the application.1307*/1308name?: string;13091310/**1311* See [specification/2025-06-18/basic/index#general-fields] for notes on _meta usage.1312*/1313_meta?: { [key: string]: unknown };1314}13151316/**1317* A notification from the client to the server, informing it that the list of roots has changed.1318* This notification should be sent whenever the client adds, removes, or modifies any root.1319* The server should then request an updated list of roots using the ListRootsRequest.1320*/1321export interface RootsListChangedNotification extends Notification {1322method: "notifications/roots/list_changed";1323}13241325/**1326* A request from the server to elicit additional information from the user via the client.1327*/1328export interface ElicitRequest extends Request {1329method: "elicitation/create";1330params: {1331/**1332* The message to present to the user.1333*/1334message: string;1335/**1336* A restricted subset of JSON Schema.1337* Only top-level properties are allowed, without nesting.1338*/1339requestedSchema: {1340type: "object";1341properties: {1342[key: string]: PrimitiveSchemaDefinition;1343};1344required?: string[];1345};1346};1347}13481349/**1350* Restricted schema definitions that only allow primitive types1351* without nested objects or arrays.1352*/1353export type PrimitiveSchemaDefinition =1354| StringSchema1355| NumberSchema1356| BooleanSchema1357| EnumSchema;13581359export interface StringSchema {1360type: "string";1361title?: string;1362description?: string;1363minLength?: number;1364maxLength?: number;1365format?: "email" | "uri" | "date" | "date-time";1366}13671368export interface NumberSchema {1369type: "number" | "integer";1370title?: string;1371description?: string;1372minimum?: number;1373maximum?: number;1374}13751376export interface BooleanSchema {1377type: "boolean";1378title?: string;1379description?: string;1380default?: boolean;1381}13821383export interface EnumSchema {1384type: "string";1385title?: string;1386description?: string;1387enum: string[];1388enumNames?: string[]; // Display names for enum values1389}13901391/**1392* The client's response to an elicitation request.1393*/1394export interface ElicitResult extends Result {1395/**1396* The user action in response to the elicitation.1397* - "accept": User submitted the form/confirmed the action1398* - "decline": User explicitly declined the action1399* - "cancel": User dismissed without making an explicit choice1400*/1401action: "accept" | "decline" | "cancel";14021403/**1404* The submitted form data, only present when action is "accept".1405* Contains values matching the requested schema.1406*/1407content?: { [key: string]: string | number | boolean };1408}14091410/* Client messages */1411export type ClientRequest =1412| PingRequest1413| InitializeRequest1414| CompleteRequest1415| SetLevelRequest1416| GetPromptRequest1417| ListPromptsRequest1418| ListResourcesRequest1419| ListResourceTemplatesRequest1420| ReadResourceRequest1421| SubscribeRequest1422| UnsubscribeRequest1423| CallToolRequest1424| ListToolsRequest;14251426export type ClientNotification =1427| CancelledNotification1428| ProgressNotification1429| InitializedNotification1430| RootsListChangedNotification;14311432export type ClientResult =1433| EmptyResult1434| CreateMessageResult1435| ListRootsResult1436| ElicitResult;14371438/* Server messages */1439export type ServerRequest =1440| PingRequest1441| CreateMessageRequest1442| ListRootsRequest1443| ElicitRequest;14441445export type ServerNotification =1446| CancelledNotification1447| ProgressNotification1448| LoggingMessageNotification1449| ResourceUpdatedNotification1450| ResourceListChangedNotification1451| ToolListChangedNotification1452| PromptListChangedNotification;14531454export type ServerResult =1455| EmptyResult1456| InitializeResult1457| CompleteResult1458| GetPromptResult1459| ListPromptsResult1460| ListResourceTemplatesResult1461| ListResourcesResult1462| ReadResourceResult1463| CallToolResult1464| ListToolsResult;1465}146614671468