Path: blob/main/src/vs/workbench/contrib/mcp/common/modelContextProtocol.ts
5260 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/* JSON-RPC types */3031/**32* Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.33*34* @category JSON-RPC35*/36export type JSONRPCMessage =37| JSONRPCRequest38| JSONRPCNotification39| JSONRPCResponse;4041/** @internal */42export const LATEST_PROTOCOL_VERSION = "2025-11-25";43/** @internal */44export const JSONRPC_VERSION = "2.0";4546/**47* Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions.48*49* Certain key names are reserved by MCP for protocol-level metadata; implementations MUST NOT make assumptions about values at these keys. Additionally, specific schema definitions may reserve particular names for purpose-specific metadata, as declared in those definitions.50*51* Valid keys have two segments:52*53* **Prefix:**54* - Optional - if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`).55* - Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`).56* - Any prefix consisting of zero or more labels, followed by `modelcontextprotocol` or `mcp`, followed by any label, is **reserved** for MCP use. For example: `modelcontextprotocol.io/`, `mcp.dev/`, `api.modelcontextprotocol.org/`, and `tools.mcp.com/` are all reserved.57*58* **Name:**59* - Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`).60* - Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`).61*62* @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details.63* @category Common Types64*/65export type MetaObject = Record<string, unknown>;6667/**68* Extends {@link MetaObject} with additional request-specific fields. All key naming rules from `MetaObject` apply.69*70* @see {@link MetaObject} for key naming rules and reserved prefixes.71* @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details.72* @category Common Types73*/74export interface RequestMetaObject extends MetaObject {75/**76* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by {@link ProgressNotification | 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.77*/78progressToken?: ProgressToken;79}8081/**82* A progress token, used to associate progress notifications with the original request.83*84* @category Common Types85*/86export type ProgressToken = string | number;8788/**89* An opaque token used to represent a cursor for pagination.90*91* @category Common Types92*/93export type Cursor = string;9495/**96* Common params for any task-augmented request.97*98* @internal99*/100export interface TaskAugmentedRequestParams extends RequestParams {101/**102* If specified, the caller is requesting task-augmented execution for this request.103* The request will return a {@link CreateTaskResult} immediately, and the actual result can be104* retrieved later via {@link GetTaskPayloadRequest | tasks/result}.105*106* Task augmentation is subject to capability negotiation - receivers MUST declare support107* for task augmentation of specific request types in their capabilities.108*/109task?: TaskMetadata;110}111112/**113* Common params for any request.114*115* @category Common Types116*/117export interface RequestParams {118_meta?: RequestMetaObject;119}120121/** @internal */122export interface Request {123method: string;124// Allow unofficial extensions of `Request.params` without impacting `RequestParams`.125// eslint-disable-next-line @typescript-eslint/no-explicit-any126params?: { [key: string]: any };127}128129/**130* Common params for any notification.131*132* @category Common Types133*/134export interface NotificationParams {135_meta?: MetaObject;136}137138/** @internal */139export interface Notification {140method: string;141// Allow unofficial extensions of `Notification.params` without impacting `NotificationParams`.142// eslint-disable-next-line @typescript-eslint/no-explicit-any143params?: { [key: string]: any };144}145146/**147* Common result fields.148*149* @category Common Types150*/151export interface Result {152_meta?: MetaObject;153[key: string]: unknown;154}155156/**157* @category Errors158*/159export interface Error {160/**161* The error type that occurred.162*/163code: number;164/**165* A short description of the error. The message SHOULD be limited to a concise single sentence.166*/167message: string;168/**169* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).170*/171data?: unknown;172}173174/**175* A uniquely identifying ID for a request in JSON-RPC.176*177* @category Common Types178*/179export type RequestId = string | number;180181/**182* A request that expects a response.183*184* @category JSON-RPC185*/186export interface JSONRPCRequest extends Request {187jsonrpc: typeof JSONRPC_VERSION;188id: RequestId;189}190191/**192* A notification which does not expect a response.193*194* @category JSON-RPC195*/196export interface JSONRPCNotification extends Notification {197jsonrpc: typeof JSONRPC_VERSION;198}199200/**201* A successful (non-error) response to a request.202*203* @category JSON-RPC204*/205export interface JSONRPCResultResponse {206jsonrpc: typeof JSONRPC_VERSION;207id: RequestId;208result: Result;209}210211/**212* A response to a request that indicates an error occurred.213*214* @category JSON-RPC215*/216export interface JSONRPCErrorResponse {217jsonrpc: typeof JSONRPC_VERSION;218id?: RequestId;219error: Error;220}221222/**223* A response to a request, containing either the result or error.224*225* @category JSON-RPC226*/227export type JSONRPCResponse = JSONRPCResultResponse | JSONRPCErrorResponse;228229// Standard JSON-RPC error codes230export const PARSE_ERROR = -32700;231export const INVALID_REQUEST = -32600;232export const METHOD_NOT_FOUND = -32601;233export const INVALID_PARAMS = -32602;234export const INTERNAL_ERROR = -32603;235236/**237* A JSON-RPC error indicating that invalid JSON was received by the server. This error is returned when the server cannot parse the JSON text of a message.238*239* @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}240*241* @example Invalid JSON242* {@includeCode ./examples/ParseError/invalid-json.json}243*244* @category Errors245*/246export interface ParseError extends Error {247code: typeof PARSE_ERROR;248}249250/**251* A JSON-RPC error indicating that the request is not a valid request object. This error is returned when the message structure does not conform to the JSON-RPC 2.0 specification requirements for a request (e.g., missing required fields like `jsonrpc` or `method`, or using invalid types for these fields).252*253* @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}254*255* @category Errors256*/257export interface InvalidRequestError extends Error {258code: typeof INVALID_REQUEST;259}260261/**262* A JSON-RPC error indicating that the requested method does not exist or is not available.263*264* In MCP, this error is returned when a request is made for a method that requires a capability that has not been declared. This can occur in either direction:265*266* - A server returning this error when the client requests a capability it doesn't support (e.g., requesting completions when the `completions` capability was not advertised)267* - A client returning this error when the server requests a capability it doesn't support (e.g., requesting roots when the client did not declare the `roots` capability)268*269* @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}270*271* @example Roots not supported272* {@includeCode ./examples/MethodNotFoundError/roots-not-supported.json}273*274* @category Errors275*/276export interface MethodNotFoundError extends Error {277code: typeof METHOD_NOT_FOUND;278}279280/**281* A JSON-RPC error indicating that the method parameters are invalid or malformed.282*283* In MCP, this error is returned in various contexts when request parameters fail validation:284*285* - **Tools**: Unknown tool name or invalid tool arguments286* - **Prompts**: Unknown prompt name or missing required arguments287* - **Pagination**: Invalid or expired cursor values288* - **Logging**: Invalid log level289* - **Tasks**: Invalid or nonexistent task ID, invalid cursor, or attempting to cancel a task already in a terminal status290* - **Elicitation**: Server requests an elicitation mode not declared in client capabilities291* - **Sampling**: Missing tool result or tool results mixed with other content292*293* @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}294*295* @example Unknown tool296* {@includeCode ./examples/InvalidParamsError/unknown-tool.json}297*298* @example Invalid tool arguments299* {@includeCode ./examples/InvalidParamsError/invalid-tool-arguments.json}300*301* @example Unknown prompt302* {@includeCode ./examples/InvalidParamsError/unknown-prompt.json}303*304* @example Invalid cursor305* {@includeCode ./examples/InvalidParamsError/invalid-cursor.json}306*307* @category Errors308*/309export interface InvalidParamsError extends Error {310code: typeof INVALID_PARAMS;311}312313/**314* A JSON-RPC error indicating that an internal error occurred on the receiver. This error is returned when the receiver encounters an unexpected condition that prevents it from fulfilling the request.315*316* @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}317*318* @example Unexpected error319* {@includeCode ./examples/InternalError/unexpected-error.json}320*321* @category Errors322*/323export interface InternalError extends Error {324code: typeof INTERNAL_ERROR;325}326327// Implementation-specific JSON-RPC error codes [-32000, -32099]328/** @internal */329export const URL_ELICITATION_REQUIRED = -32042;330331/**332* An error response that indicates that the server requires the client to provide additional information via an elicitation request.333*334* @example Authorization required335* {@includeCode ./examples/URLElicitationRequiredError/authorization-required.json}336*337* @internal338*/339export interface URLElicitationRequiredError extends Omit<340JSONRPCErrorResponse,341"error"342> {343error: Error & {344code: typeof URL_ELICITATION_REQUIRED;345data: {346elicitations: ElicitRequestURLParams[];347[key: string]: unknown;348};349};350}351352/* Empty result */353/**354* A result that indicates success but carries no data.355*356* @category Common Types357*/358export type EmptyResult = Result;359360/* Cancellation */361/**362* Parameters for a `notifications/cancelled` notification.363*364* @example User-requested cancellation365* {@includeCode ./examples/CancelledNotificationParams/user-requested-cancellation.json}366*367* @category `notifications/cancelled`368*/369export interface CancelledNotificationParams extends NotificationParams {370/**371* The ID of the request to cancel.372*373* This MUST correspond to the ID of a request previously issued in the same direction.374* This MUST be provided for cancelling non-task requests.375* This MUST NOT be used for cancelling tasks (use the {@link CancelTaskRequest | tasks/cancel} request instead).376*/377requestId?: RequestId;378379/**380* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.381*/382reason?: string;383}384385/**386* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.387*388* 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.389*390* This notification indicates that the result will be unused, so any associated processing SHOULD cease.391*392* A client MUST NOT attempt to cancel its `initialize` request.393*394* For task cancellation, use the {@link CancelTaskRequest | tasks/cancel} request instead of this notification.395*396* @example User-requested cancellation397* {@includeCode ./examples/CancelledNotification/user-requested-cancellation.json}398*399* @category `notifications/cancelled`400*/401export interface CancelledNotification extends JSONRPCNotification {402method: "notifications/cancelled";403params: CancelledNotificationParams;404}405406/* Initialization */407/**408* Parameters for an `initialize` request.409*410* @example Full client capabilities411* {@includeCode ./examples/InitializeRequestParams/full-client-capabilities.json}412*413* @category `initialize`414*/415export interface InitializeRequestParams extends RequestParams {416/**417* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.418*/419protocolVersion: string;420capabilities: ClientCapabilities;421clientInfo: Implementation;422}423424/**425* This request is sent from the client to the server when it first connects, asking it to begin initialization.426*427* @example Initialize request428* {@includeCode ./examples/InitializeRequest/initialize-request.json}429*430* @category `initialize`431*/432export interface InitializeRequest extends JSONRPCRequest {433method: "initialize";434params: InitializeRequestParams;435}436437/**438* The result returned by the server for an {@link InitializeRequest | initialize} request.439*440* @example Full server capabilities441* {@includeCode ./examples/InitializeResult/full-server-capabilities.json}442*443* @category `initialize`444*/445export interface InitializeResult extends Result {446/**447* 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.448*/449protocolVersion: string;450capabilities: ServerCapabilities;451serverInfo: Implementation;452453/**454* Instructions describing how to use the server and its features.455*456* 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.457*/458instructions?: string;459}460461/**462* A successful response from the server for a {@link InitializeRequest | initialize} request.463*464* @example Initialize result response465* {@includeCode ./examples/InitializeResultResponse/initialize-result-response.json}466*467* @category `initialize`468*/469export interface InitializeResultResponse extends JSONRPCResultResponse {470result: InitializeResult;471}472473/**474* This notification is sent from the client to the server after initialization has finished.475*476* @example Initialized notification477* {@includeCode ./examples/InitializedNotification/initialized-notification.json}478*479* @category `notifications/initialized`480*/481export interface InitializedNotification extends JSONRPCNotification {482method: "notifications/initialized";483params?: NotificationParams;484}485486/**487* 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.488*489* @category `initialize`490*/491export interface ClientCapabilities {492/**493* Experimental, non-standard capabilities that the client supports.494*/495experimental?: { [key: string]: object };496/**497* Present if the client supports listing roots.498*499* @example Roots - minimum baseline support500* {@includeCode ./examples/ClientCapabilities/roots-minimum-baseline-support.json}501*502* @example Roots - list changed notifications503* {@includeCode ./examples/ClientCapabilities/roots-list-changed-notifications.json}504*/505roots?: {506/**507* Whether the client supports notifications for changes to the roots list.508*/509listChanged?: boolean;510};511/**512* Present if the client supports sampling from an LLM.513*514* @example Sampling - minimum baseline support515* {@includeCode ./examples/ClientCapabilities/sampling-minimum-baseline-support.json}516*517* @example Sampling - tool use support518* {@includeCode ./examples/ClientCapabilities/sampling-tool-use-support.json}519*520* @example Sampling - context inclusion support (soft-deprecated)521* {@includeCode ./examples/ClientCapabilities/sampling-context-inclusion-support-soft-deprecated.json}522*/523sampling?: {524/**525* Whether the client supports context inclusion via `includeContext` parameter.526* If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).527*/528context?: object;529/**530* Whether the client supports tool use via `tools` and `toolChoice` parameters.531*/532tools?: object;533};534/**535* Present if the client supports elicitation from the server.536*537* @example Elicitation - form and URL mode support538* {@includeCode ./examples/ClientCapabilities/elicitation-form-and-url-mode-support.json}539*540* @example Elicitation - form mode only (implicit)541* {@includeCode ./examples/ClientCapabilities/elicitation-form-only-implicit.json}542*/543elicitation?: { form?: object; url?: object };544545/**546* Present if the client supports task-augmented requests.547*/548tasks?: {549/**550* Whether this client supports {@link ListTasksRequest | tasks/list}.551*/552list?: object;553/**554* Whether this client supports {@link CancelTaskRequest | tasks/cancel}.555*/556cancel?: object;557/**558* Specifies which request types can be augmented with tasks.559*/560requests?: {561/**562* Task support for sampling-related requests.563*/564sampling?: {565/**566* Whether the client supports task-augmented `sampling/createMessage` requests.567*/568createMessage?: object;569};570/**571* Task support for elicitation-related requests.572*/573elicitation?: {574/**575* Whether the client supports task-augmented {@link ElicitRequest | elicitation/create} requests.576*/577create?: object;578};579};580};581/**582* Optional MCP extensions that the client supports. Keys are extension identifiers583* (e.g., "io.modelcontextprotocol/oauth-client-credentials"), and values are584* per-extension settings objects. An empty object indicates support with no settings.585*586* @example Extensions - UI extension with MIME type support587* {@includeCode ./examples/ClientCapabilities/extensions-ui-mime-types.json}588*/589extensions?: { [key: string]: object };590}591592/**593* 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.594*595* @category `initialize`596*/597export interface ServerCapabilities {598/**599* Experimental, non-standard capabilities that the server supports.600*/601experimental?: { [key: string]: object };602/**603* Present if the server supports sending log messages to the client.604*605* @example Logging - minimum baseline support606* {@includeCode ./examples/ServerCapabilities/logging-minimum-baseline-support.json}607*/608logging?: object;609/**610* Present if the server supports argument autocompletion suggestions.611*612* @example Completions - minimum baseline support613* {@includeCode ./examples/ServerCapabilities/completions-minimum-baseline-support.json}614*/615completions?: object;616/**617* Present if the server offers any prompt templates.618*619* @example Prompts - minimum baseline support620* {@includeCode ./examples/ServerCapabilities/prompts-minimum-baseline-support.json}621*622* @example Prompts - list changed notifications623* {@includeCode ./examples/ServerCapabilities/prompts-list-changed-notifications.json}624*/625prompts?: {626/**627* Whether this server supports notifications for changes to the prompt list.628*/629listChanged?: boolean;630};631/**632* Present if the server offers any resources to read.633*634* @example Resources - minimum baseline support635* {@includeCode ./examples/ServerCapabilities/resources-minimum-baseline-support.json}636*637* @example Resources - subscription to individual resource updates (only)638* {@includeCode ./examples/ServerCapabilities/resources-subscription-to-individual-resource-updates-only.json}639*640* @example Resources - list changed notifications (only)641* {@includeCode ./examples/ServerCapabilities/resources-list-changed-notifications-only.json}642*643* @example Resources - all notifications644* {@includeCode ./examples/ServerCapabilities/resources-all-notifications.json}645*/646resources?: {647/**648* Whether this server supports subscribing to resource updates.649*/650subscribe?: boolean;651/**652* Whether this server supports notifications for changes to the resource list.653*/654listChanged?: boolean;655};656/**657* Present if the server offers any tools to call.658*659* @example Tools - minimum baseline support660* {@includeCode ./examples/ServerCapabilities/tools-minimum-baseline-support.json}661*662* @example Tools - list changed notifications663* {@includeCode ./examples/ServerCapabilities/tools-list-changed-notifications.json}664*/665tools?: {666/**667* Whether this server supports notifications for changes to the tool list.668*/669listChanged?: boolean;670};671/**672* Present if the server supports task-augmented requests.673*/674tasks?: {675/**676* Whether this server supports {@link ListTasksRequest | tasks/list}.677*/678list?: object;679/**680* Whether this server supports {@link CancelTaskRequest | tasks/cancel}.681*/682cancel?: object;683/**684* Specifies which request types can be augmented with tasks.685*/686requests?: {687/**688* Task support for tool-related requests.689*/690tools?: {691/**692* Whether the server supports task-augmented {@link CallToolRequest | tools/call} requests.693*/694call?: object;695};696};697};698/**699* Optional MCP extensions that the server supports. Keys are extension identifiers700* (e.g., "io.modelcontextprotocol/apps"), and values are per-extension settings701* objects. An empty object indicates support with no settings.702*703* @example Extensions - UI extension support704* {@includeCode ./examples/ServerCapabilities/extensions-ui.json}705*/706extensions?: { [key: string]: object };707}708709/**710* An optionally-sized icon that can be displayed in a user interface.711*712* @category Common Types713*/714export interface Icon {715/**716* A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a717* `data:` URI with Base64-encoded image data.718*719* Consumers SHOULD take steps to ensure URLs serving icons are from the720* same domain as the client/server or a trusted domain.721*722* Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain723* executable JavaScript.724*725* @format uri726*/727src: string;728729/**730* Optional MIME type override if the source MIME type is missing or generic.731* For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`.732*/733mimeType?: string;734735/**736* Optional array of strings that specify sizes at which the icon can be used.737* Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.738*739* If not provided, the client should assume that the icon can be used at any size.740*/741sizes?: string[];742743/**744* Optional specifier for the theme this icon is designed for. `"light"` indicates745* the icon is designed to be used with a light background, and `"dark"` indicates746* the icon is designed to be used with a dark background.747*748* If not provided, the client should assume the icon can be used with any theme.749*/750theme?: "light" | "dark";751}752753/**754* Base interface to add `icons` property.755*756* @internal757*/758export interface Icons {759/**760* Optional set of sized icons that the client can display in a user interface.761*762* Clients that support rendering icons MUST support at least the following MIME types:763* - `image/png` - PNG images (safe, universal compatibility)764* - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)765*766* Clients that support rendering icons SHOULD also support:767* - `image/svg+xml` - SVG images (scalable but requires security precautions)768* - `image/webp` - WebP images (modern, efficient format)769*/770icons?: Icon[];771}772773/**774* Base interface for metadata with name (identifier) and title (display name) properties.775*776* @internal777*/778export interface BaseMetadata {779/**780* Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).781*/782name: string;783784/**785* Intended for UI and end-user contexts - optimized to be human-readable and easily understood,786* even by those unfamiliar with domain-specific terminology.787*788* If not provided, the name should be used for display (except for {@link Tool},789* where `annotations.title` should be given precedence over using `name`,790* if present).791*/792title?: string;793}794795/**796* Describes the MCP implementation.797*798* @category `initialize`799*/800export interface Implementation extends BaseMetadata, Icons {801/**802* The version of this implementation.803*/804version: string;805806/**807* An optional human-readable description of what this implementation does.808*809* This can be used by clients or servers to provide context about their purpose810* and capabilities. For example, a server might describe the types of resources811* or tools it provides, while a client might describe its intended use case.812*/813description?: string;814815/**816* An optional URL of the website for this implementation.817*818* @format uri819*/820websiteUrl?: string;821}822823/* Ping */824/**825* 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.826*827* @example Ping request828* {@includeCode ./examples/PingRequest/ping-request.json}829*830* @category `ping`831*/832export interface PingRequest extends JSONRPCRequest {833method: "ping";834params?: RequestParams;835}836837/**838* A successful response for a {@link PingRequest | ping} request.839*840* @example Ping result response841* {@includeCode ./examples/PingResultResponse/ping-result-response.json}842*843* @category `ping`844*/845export interface PingResultResponse extends JSONRPCResultResponse {846result: EmptyResult;847}848849/* Progress notifications */850851/**852* Parameters for a {@link ProgressNotification | notifications/progress} notification.853*854* @example Progress message855* {@includeCode ./examples/ProgressNotificationParams/progress-message.json}856*857* @category `notifications/progress`858*/859export interface ProgressNotificationParams extends NotificationParams {860/**861* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.862*/863progressToken: ProgressToken;864/**865* The progress thus far. This should increase every time progress is made, even if the total is unknown.866*867* @TJS-type number868*/869progress: number;870/**871* Total number of items to process (or total progress required), if known.872*873* @TJS-type number874*/875total?: number;876/**877* An optional message describing the current progress.878*/879message?: string;880}881882/**883* An out-of-band notification used to inform the receiver of a progress update for a long-running request.884*885* @example Progress message886* {@includeCode ./examples/ProgressNotification/progress-message.json}887*888* @category `notifications/progress`889*/890export interface ProgressNotification extends JSONRPCNotification {891method: "notifications/progress";892params: ProgressNotificationParams;893}894895/* Pagination */896/**897* Common params for paginated requests.898*899* @example List request with cursor900* {@includeCode ./examples/PaginatedRequestParams/list-with-cursor.json}901*902* @category Common Types903*/904export interface PaginatedRequestParams extends RequestParams {905/**906* An opaque token representing the current pagination position.907* If provided, the server should return results starting after this cursor.908*/909cursor?: Cursor;910}911912/** @internal */913export interface PaginatedRequest extends JSONRPCRequest {914params?: PaginatedRequestParams;915}916917/** @internal */918export interface PaginatedResult extends Result {919/**920* An opaque token representing the pagination position after the last returned result.921* If present, there may be more results available.922*/923nextCursor?: Cursor;924}925926/* Resources */927/**928* Sent from the client to request a list of resources the server has.929*930* @example List resources request931* {@includeCode ./examples/ListResourcesRequest/list-resources-request.json}932*933* @category `resources/list`934*/935export interface ListResourcesRequest extends PaginatedRequest {936method: "resources/list";937}938939/**940* The result returned by the server for a {@link ListResourcesRequest | resources/list} request.941*942* @example Resources list with cursor943* {@includeCode ./examples/ListResourcesResult/resources-list-with-cursor.json}944*945* @category `resources/list`946*/947export interface ListResourcesResult extends PaginatedResult {948resources: Resource[];949}950951/**952* A successful response from the server for a {@link ListResourcesRequest | resources/list} request.953*954* @example List resources result response955* {@includeCode ./examples/ListResourcesResultResponse/list-resources-result-response.json}956*957* @category `resources/list`958*/959export interface ListResourcesResultResponse extends JSONRPCResultResponse {960result: ListResourcesResult;961}962963/**964* Sent from the client to request a list of resource templates the server has.965*966* @example List resource templates request967* {@includeCode ./examples/ListResourceTemplatesRequest/list-resource-templates-request.json}968*969* @category `resources/templates/list`970*/971export interface ListResourceTemplatesRequest extends PaginatedRequest {972method: "resources/templates/list";973}974975/**976* The result returned by the server for a {@link ListResourceTemplatesRequest | resources/templates/list} request.977*978* @example Resource templates list979* {@includeCode ./examples/ListResourceTemplatesResult/resource-templates-list.json}980*981* @category `resources/templates/list`982*/983export interface ListResourceTemplatesResult extends PaginatedResult {984resourceTemplates: ResourceTemplate[];985}986987/**988* A successful response from the server for a {@link ListResourceTemplatesRequest | resources/templates/list} request.989*990* @example List resource templates result response991* {@includeCode ./examples/ListResourceTemplatesResultResponse/list-resource-templates-result-response.json}992*993* @category `resources/templates/list`994*/995export interface ListResourceTemplatesResultResponse extends JSONRPCResultResponse {996result: ListResourceTemplatesResult;997}998999/**1000* Common params for resource-related requests.1001*1002* @internal1003*/1004export interface ResourceRequestParams extends RequestParams {1005/**1006* The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.1007*1008* @format uri1009*/1010uri: string;1011}10121013/**1014* Parameters for a `resources/read` request.1015*1016* @category `resources/read`1017*/1018export interface ReadResourceRequestParams extends ResourceRequestParams { }10191020/**1021* Sent from the client to the server, to read a specific resource URI.1022*1023* @example Read resource request1024* {@includeCode ./examples/ReadResourceRequest/read-resource-request.json}1025*1026* @category `resources/read`1027*/1028export interface ReadResourceRequest extends JSONRPCRequest {1029method: "resources/read";1030params: ReadResourceRequestParams;1031}10321033/**1034* The result returned by the server for a {@link ReadResourceRequest | resources/read} request.1035*1036* @example File resource contents1037* {@includeCode ./examples/ReadResourceResult/file-resource-contents.json}1038*1039* @category `resources/read`1040*/1041export interface ReadResourceResult extends Result {1042contents: (TextResourceContents | BlobResourceContents)[];1043}10441045/**1046* A successful response from the server for a {@link ReadResourceRequest | resources/read} request.1047*1048* @example Read resource result response1049* {@includeCode ./examples/ReadResourceResultResponse/read-resource-result-response.json}1050*1051* @category `resources/read`1052*/1053export interface ReadResourceResultResponse extends JSONRPCResultResponse {1054result: ReadResourceResult;1055}10561057/**1058* 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.1059*1060* @example Resources list changed1061* {@includeCode ./examples/ResourceListChangedNotification/resources-list-changed.json}1062*1063* @category `notifications/resources/list_changed`1064*/1065export interface ResourceListChangedNotification extends JSONRPCNotification {1066method: "notifications/resources/list_changed";1067params?: NotificationParams;1068}10691070/**1071* Parameters for a `resources/subscribe` request.1072*1073* @example Subscribe to file resource1074* {@includeCode ./examples/SubscribeRequestParams/subscribe-to-file-resource.json}1075*1076* @category `resources/subscribe`1077*/1078export interface SubscribeRequestParams extends ResourceRequestParams { }10791080/**1081* Sent from the client to request {@link ResourceUpdatedNotification | resources/updated} notifications from the server whenever a particular resource changes.1082*1083* @example Subscribe request1084* {@includeCode ./examples/SubscribeRequest/subscribe-request.json}1085*1086* @category `resources/subscribe`1087*/1088export interface SubscribeRequest extends JSONRPCRequest {1089method: "resources/subscribe";1090params: SubscribeRequestParams;1091}10921093/**1094* A successful response from the server for a {@link SubscribeRequest | resources/subscribe} request.1095*1096* @example Subscribe result response1097* {@includeCode ./examples/SubscribeResultResponse/subscribe-result-response.json}1098*1099* @category `resources/subscribe`1100*/1101export interface SubscribeResultResponse extends JSONRPCResultResponse {1102result: EmptyResult;1103}11041105/**1106* Parameters for a `resources/unsubscribe` request.1107*1108* @category `resources/unsubscribe`1109*/1110export interface UnsubscribeRequestParams extends ResourceRequestParams { }11111112/**1113* Sent from the client to request cancellation of {@link ResourceUpdatedNotification | resources/updated} notifications from the server. This should follow a previous {@link SubscribeRequest | resources/subscribe} request.1114*1115* @example Unsubscribe request1116* {@includeCode ./examples/UnsubscribeRequest/unsubscribe-request.json}1117*1118* @category `resources/unsubscribe`1119*/1120export interface UnsubscribeRequest extends JSONRPCRequest {1121method: "resources/unsubscribe";1122params: UnsubscribeRequestParams;1123}11241125/**1126* A successful response from the server for a {@link UnsubscribeRequest | resources/unsubscribe} request.1127*1128* @example Unsubscribe result response1129* {@includeCode ./examples/UnsubscribeResultResponse/unsubscribe-result-response.json}1130*1131* @category `resources/unsubscribe`1132*/1133export interface UnsubscribeResultResponse extends JSONRPCResultResponse {1134result: EmptyResult;1135}11361137/**1138* Parameters for a `notifications/resources/updated` notification.1139*1140* @example File resource updated1141* {@includeCode ./examples/ResourceUpdatedNotificationParams/file-resource-updated.json}1142*1143* @category `notifications/resources/updated`1144*/1145export interface ResourceUpdatedNotificationParams extends NotificationParams {1146/**1147* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.1148*1149* @format uri1150*/1151uri: string;1152}11531154/**1155* 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 {@link SubscribeRequest | resources/subscribe} request.1156*1157* @example File resource updated notification1158* {@includeCode ./examples/ResourceUpdatedNotification/file-resource-updated-notification.json}1159*1160* @category `notifications/resources/updated`1161*/1162export interface ResourceUpdatedNotification extends JSONRPCNotification {1163method: "notifications/resources/updated";1164params: ResourceUpdatedNotificationParams;1165}11661167/**1168* A known resource that the server is capable of reading.1169*1170* @example File resource with annotations1171* {@includeCode ./examples/Resource/file-resource-with-annotations.json}1172*1173* @category `resources/list`1174*/1175export interface Resource extends BaseMetadata, Icons {1176/**1177* The URI of this resource.1178*1179* @format uri1180*/1181uri: string;11821183/**1184* A description of what this resource represents.1185*1186* 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.1187*/1188description?: string;11891190/**1191* The MIME type of this resource, if known.1192*/1193mimeType?: string;11941195/**1196* Optional annotations for the client.1197*/1198annotations?: Annotations;11991200/**1201* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.1202*1203* This can be used by Hosts to display file sizes and estimate context window usage.1204*/1205size?: number;12061207_meta?: MetaObject;1208}12091210/**1211* A template description for resources available on the server.1212*1213* @category `resources/templates/list`1214*/1215export interface ResourceTemplate extends BaseMetadata, Icons {1216/**1217* A URI template (according to RFC 6570) that can be used to construct resource URIs.1218*1219* @format uri-template1220*/1221uriTemplate: string;12221223/**1224* A description of what this template is for.1225*1226* 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.1227*/1228description?: string;12291230/**1231* 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.1232*/1233mimeType?: string;12341235/**1236* Optional annotations for the client.1237*/1238annotations?: Annotations;12391240_meta?: MetaObject;1241}12421243/**1244* The contents of a specific resource or sub-resource.1245*1246* @internal1247*/1248export interface ResourceContents {1249/**1250* The URI of this resource.1251*1252* @format uri1253*/1254uri: string;1255/**1256* The MIME type of this resource, if known.1257*/1258mimeType?: string;12591260_meta?: MetaObject;1261}12621263/**1264* @example Text file contents1265* {@includeCode ./examples/TextResourceContents/text-file-contents.json}1266*1267* @category Content1268*/1269export interface TextResourceContents extends ResourceContents {1270/**1271* The text of the item. This must only be set if the item can actually be represented as text (not binary data).1272*/1273text: string;1274}12751276/**1277* @example Image file contents1278* {@includeCode ./examples/BlobResourceContents/image-file-contents.json}1279*1280* @category Content1281*/1282export interface BlobResourceContents extends ResourceContents {1283/**1284* A base64-encoded string representing the binary data of the item.1285*1286* @format byte1287*/1288blob: string;1289}12901291/* Prompts */1292/**1293* Sent from the client to request a list of prompts and prompt templates the server has.1294*1295* @example List prompts request1296* {@includeCode ./examples/ListPromptsRequest/list-prompts-request.json}1297*1298* @category `prompts/list`1299*/1300export interface ListPromptsRequest extends PaginatedRequest {1301method: "prompts/list";1302}13031304/**1305* The result returned by the server for a {@link ListPromptsRequest | prompts/list} request.1306*1307* @example Prompts list with cursor1308* {@includeCode ./examples/ListPromptsResult/prompts-list-with-cursor.json}1309*1310* @category `prompts/list`1311*/1312export interface ListPromptsResult extends PaginatedResult {1313prompts: Prompt[];1314}13151316/**1317* A successful response from the server for a {@link ListPromptsRequest | prompts/list} request.1318*1319* @example List prompts result response1320* {@includeCode ./examples/ListPromptsResultResponse/list-prompts-result-response.json}1321*1322* @category `prompts/list`1323*/1324export interface ListPromptsResultResponse extends JSONRPCResultResponse {1325result: ListPromptsResult;1326}13271328/**1329* Parameters for a `prompts/get` request.1330*1331* @example Get code review prompt1332* {@includeCode ./examples/GetPromptRequestParams/get-code-review-prompt.json}1333*1334* @category `prompts/get`1335*/1336export interface GetPromptRequestParams extends RequestParams {1337/**1338* The name of the prompt or prompt template.1339*/1340name: string;1341/**1342* Arguments to use for templating the prompt.1343*/1344arguments?: { [key: string]: string };1345}13461347/**1348* Used by the client to get a prompt provided by the server.1349*1350* @example Get prompt request1351* {@includeCode ./examples/GetPromptRequest/get-prompt-request.json}1352*1353* @category `prompts/get`1354*/1355export interface GetPromptRequest extends JSONRPCRequest {1356method: "prompts/get";1357params: GetPromptRequestParams;1358}13591360/**1361* The result returned by the server for a {@link GetPromptRequest | prompts/get} request.1362*1363* @example Code review prompt1364* {@includeCode ./examples/GetPromptResult/code-review-prompt.json}1365*1366* @category `prompts/get`1367*/1368export interface GetPromptResult extends Result {1369/**1370* An optional description for the prompt.1371*/1372description?: string;1373messages: PromptMessage[];1374}13751376/**1377* A successful response from the server for a {@link GetPromptRequest | prompts/get} request.1378*1379* @example Get prompt result response1380* {@includeCode ./examples/GetPromptResultResponse/get-prompt-result-response.json}1381*1382* @category `prompts/get`1383*/1384export interface GetPromptResultResponse extends JSONRPCResultResponse {1385result: GetPromptResult;1386}13871388/**1389* A prompt or prompt template that the server offers.1390*1391* @category `prompts/list`1392*/1393export interface Prompt extends BaseMetadata, Icons {1394/**1395* An optional description of what this prompt provides1396*/1397description?: string;13981399/**1400* A list of arguments to use for templating the prompt.1401*/1402arguments?: PromptArgument[];14031404_meta?: MetaObject;1405}14061407/**1408* Describes an argument that a prompt can accept.1409*1410* @category `prompts/list`1411*/1412export interface PromptArgument extends BaseMetadata {1413/**1414* A human-readable description of the argument.1415*/1416description?: string;1417/**1418* Whether this argument must be provided.1419*/1420required?: boolean;1421}14221423/**1424* The sender or recipient of messages and data in a conversation.1425*1426* @category Common Types1427*/1428export type Role = "user" | "assistant";14291430/**1431* Describes a message returned as part of a prompt.1432*1433* This is similar to {@link SamplingMessage}, but also supports the embedding of1434* resources from the MCP server.1435*1436* @category `prompts/get`1437*/1438export interface PromptMessage {1439role: Role;1440content: ContentBlock;1441}14421443/**1444* A resource that the server is capable of reading, included in a prompt or tool call result.1445*1446* Note: resource links returned by tools are not guaranteed to appear in the results of {@link ListResourcesRequest | resources/list} requests.1447*1448* @example File resource link1449* {@includeCode ./examples/ResourceLink/file-resource-link.json}1450*1451* @category Content1452*/1453export interface ResourceLink extends Resource {1454type: "resource_link";1455}14561457/**1458* The contents of a resource, embedded into a prompt or tool call result.1459*1460* It is up to the client how best to render embedded resources for the benefit1461* of the LLM and/or the user.1462*1463* @example Embedded file resource with annotations1464* {@includeCode ./examples/EmbeddedResource/embedded-file-resource-with-annotations.json}1465*1466* @category Content1467*/1468export interface EmbeddedResource {1469type: "resource";1470resource: TextResourceContents | BlobResourceContents;14711472/**1473* Optional annotations for the client.1474*/1475annotations?: Annotations;14761477_meta?: MetaObject;1478}1479/**1480* 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.1481*1482* @example Prompts list changed1483* {@includeCode ./examples/PromptListChangedNotification/prompts-list-changed.json}1484*1485* @category `notifications/prompts/list_changed`1486*/1487export interface PromptListChangedNotification extends JSONRPCNotification {1488method: "notifications/prompts/list_changed";1489params?: NotificationParams;1490}14911492/* Tools */1493/**1494* Sent from the client to request a list of tools the server has.1495*1496* @example List tools request1497* {@includeCode ./examples/ListToolsRequest/list-tools-request.json}1498*1499* @category `tools/list`1500*/1501export interface ListToolsRequest extends PaginatedRequest {1502method: "tools/list";1503}15041505/**1506* The result returned by the server for a {@link ListToolsRequest | tools/list} request.1507*1508* @example Tools list with cursor1509* {@includeCode ./examples/ListToolsResult/tools-list-with-cursor.json}1510*1511* @category `tools/list`1512*/1513export interface ListToolsResult extends PaginatedResult {1514tools: Tool[];1515}15161517/**1518* A successful response from the server for a {@link ListToolsRequest | tools/list} request.1519*1520* @example List tools result response1521* {@includeCode ./examples/ListToolsResultResponse/list-tools-result-response.json}1522*1523* @category `tools/list`1524*/1525export interface ListToolsResultResponse extends JSONRPCResultResponse {1526result: ListToolsResult;1527}15281529/**1530* The result returned by the server for a {@link CallToolRequest | tools/call} request.1531*1532* @example Result with unstructured text1533* {@includeCode ./examples/CallToolResult/result-with-unstructured-text.json}1534*1535* @example Result with structured content1536* {@includeCode ./examples/CallToolResult/result-with-structured-content.json}1537*1538* @example Invalid tool input error1539* {@includeCode ./examples/CallToolResult/invalid-tool-input-error.json}1540*1541* @category `tools/call`1542*/1543export interface CallToolResult extends Result {1544/**1545* A list of content objects that represent the unstructured result of the tool call.1546*/1547content: ContentBlock[];15481549/**1550* An optional JSON object that represents the structured result of the tool call.1551*/1552structuredContent?: { [key: string]: unknown };15531554/**1555* Whether the tool call ended in an error.1556*1557* If not set, this is assumed to be false (the call was successful).1558*1559* Any errors that originate from the tool SHOULD be reported inside the result1560* object, with `isError` set to true, _not_ as an MCP protocol-level error1561* response. Otherwise, the LLM would not be able to see that an error occurred1562* and self-correct.1563*1564* However, any errors in _finding_ the tool, an error indicating that the1565* server does not support tool calls, or any other exceptional conditions,1566* should be reported as an MCP error response.1567*/1568isError?: boolean;1569}15701571/**1572* A successful response from the server for a {@link CallToolRequest | tools/call} request.1573*1574* @example Call tool result response1575* {@includeCode ./examples/CallToolResultResponse/call-tool-result-response.json}1576*1577* @category `tools/call`1578*/1579export interface CallToolResultResponse extends JSONRPCResultResponse {1580result: CallToolResult;1581}15821583/**1584* Parameters for a `tools/call` request.1585*1586* @example `get_weather` tool call params1587* {@includeCode ./examples/CallToolRequestParams/get-weather-tool-call-params.json}1588*1589* @example Tool call params with progress token1590* {@includeCode ./examples/CallToolRequestParams/tool-call-params-with-progress-token.json}1591*1592* @category `tools/call`1593*/1594export interface CallToolRequestParams extends TaskAugmentedRequestParams {1595/**1596* The name of the tool.1597*/1598name: string;1599/**1600* Arguments to use for the tool call.1601*/1602arguments?: { [key: string]: unknown };1603}16041605/**1606* Used by the client to invoke a tool provided by the server.1607*1608* @example Call tool request1609* {@includeCode ./examples/CallToolRequest/call-tool-request.json}1610*1611* @category `tools/call`1612*/1613export interface CallToolRequest extends JSONRPCRequest {1614method: "tools/call";1615params: CallToolRequestParams;1616}16171618/**1619* 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.1620*1621* @example Tools list changed1622* {@includeCode ./examples/ToolListChangedNotification/tools-list-changed.json}1623*1624* @category `notifications/tools/list_changed`1625*/1626export interface ToolListChangedNotification extends JSONRPCNotification {1627method: "notifications/tools/list_changed";1628params?: NotificationParams;1629}16301631/**1632* Additional properties describing a {@link Tool} to clients.1633*1634* NOTE: all properties in `ToolAnnotations` are **hints**.1635* They are not guaranteed to provide a faithful description of1636* tool behavior (including descriptive properties like `title`).1637*1638* Clients should never make tool use decisions based on `ToolAnnotations`1639* received from untrusted servers.1640*1641* @category `tools/list`1642*/1643export interface ToolAnnotations {1644/**1645* A human-readable title for the tool.1646*/1647title?: string;16481649/**1650* If true, the tool does not modify its environment.1651*1652* Default: false1653*/1654readOnlyHint?: boolean;16551656/**1657* If true, the tool may perform destructive updates to its environment.1658* If false, the tool performs only additive updates.1659*1660* (This property is meaningful only when `readOnlyHint == false`)1661*1662* Default: true1663*/1664destructiveHint?: boolean;16651666/**1667* If true, calling the tool repeatedly with the same arguments1668* will have no additional effect on its environment.1669*1670* (This property is meaningful only when `readOnlyHint == false`)1671*1672* Default: false1673*/1674idempotentHint?: boolean;16751676/**1677* If true, this tool may interact with an "open world" of external1678* entities. If false, the tool's domain of interaction is closed.1679* For example, the world of a web search tool is open, whereas that1680* of a memory tool is not.1681*1682* Default: true1683*/1684openWorldHint?: boolean;1685}16861687/**1688* Execution-related properties for a tool.1689*1690* @category `tools/list`1691*/1692export interface ToolExecution {1693/**1694* Indicates whether this tool supports task-augmented execution.1695* This allows clients to handle long-running operations through polling1696* the task system.1697*1698* - `"forbidden"`: Tool does not support task-augmented execution (default when absent)1699* - `"optional"`: Tool may support task-augmented execution1700* - `"required"`: Tool requires task-augmented execution1701*1702* Default: `"forbidden"`1703*/1704taskSupport?: "forbidden" | "optional" | "required";1705}17061707/**1708* Definition for a tool the client can call.1709*1710* @example With default 2020-12 input schema1711* {@includeCode ./examples/Tool/with-default-2020-12-input-schema.json}1712*1713* @example With explicit draft-07 input schema1714* {@includeCode ./examples/Tool/with-explicit-draft-07-input-schema.json}1715*1716* @example With no parameters1717* {@includeCode ./examples/Tool/with-no-parameters.json}1718*1719* @example With output schema for structured content1720* {@includeCode ./examples/Tool/with-output-schema-for-structured-content.json}1721*1722* @category `tools/list`1723*/1724export interface Tool extends BaseMetadata, Icons {1725/**1726* A human-readable description of the tool.1727*1728* 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.1729*/1730description?: string;17311732/**1733* A JSON Schema object defining the expected parameters for the tool.1734*/1735inputSchema: {1736$schema?: string;1737type: "object";1738properties?: { [key: string]: object };1739required?: string[];1740};17411742/**1743* Execution-related properties for this tool.1744*/1745execution?: ToolExecution;17461747/**1748* An optional JSON Schema object defining the structure of the tool's output returned in1749* the structuredContent field of a {@link CallToolResult}.1750*1751* Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.1752* Currently restricted to `type: "object"` at the root level.1753*/1754outputSchema?: {1755$schema?: string;1756type: "object";1757properties?: { [key: string]: object };1758required?: string[];1759};17601761/**1762* Optional additional tool information.1763*1764* Display name precedence order is: `title`, `annotations.title`, then `name`.1765*/1766annotations?: ToolAnnotations;17671768_meta?: MetaObject;1769}17701771/* Tasks */17721773/**1774* The status of a task.1775*1776* @category `tasks`1777*/1778export type TaskStatus =1779| "working" // The request is currently being processed1780| "input_required" // The task is waiting for input (e.g., elicitation or sampling)1781| "completed" // The request completed successfully and results are available1782| "failed" // The associated request did not complete successfully. For tool calls specifically, this includes cases where the tool call result has `isError` set to true.1783| "cancelled"; // The request was cancelled before completion17841785/**1786* Metadata for augmenting a request with task execution.1787* Include this in the `task` field of the request parameters.1788*1789* @category `tasks`1790*/1791export interface TaskMetadata {1792/**1793* Requested duration in milliseconds to retain task from creation.1794*/1795ttl?: number;1796}17971798/**1799* Metadata for associating messages with a task.1800* Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.1801*1802* @category `tasks`1803*/1804export interface RelatedTaskMetadata {1805/**1806* The task identifier this message is associated with.1807*/1808taskId: string;1809}18101811/**1812* Data associated with a task.1813*1814* @category `tasks`1815*/1816export interface Task {1817/**1818* The task identifier.1819*/1820taskId: string;18211822/**1823* Current task state.1824*/1825status: TaskStatus;18261827/**1828* Optional human-readable message describing the current task state.1829* This can provide context for any status, including:1830* - Reasons for "cancelled" status1831* - Summaries for "completed" status1832* - Diagnostic information for "failed" status (e.g., error details, what went wrong)1833*/1834statusMessage?: string;18351836/**1837* ISO 8601 timestamp when the task was created.1838*/1839createdAt: string;18401841/**1842* ISO 8601 timestamp when the task was last updated.1843*/1844lastUpdatedAt: string;18451846/**1847* Actual retention duration from creation in milliseconds, null for unlimited.1848*/1849ttl: number | null;18501851/**1852* Suggested polling interval in milliseconds.1853*/1854pollInterval?: number;1855}18561857/**1858* The result returned for a task-augmented request.1859*1860* @category `tasks`1861*/1862export interface CreateTaskResult extends Result {1863task: Task;1864}18651866/**1867* A successful response for a task-augmented request.1868*1869* @category `tasks`1870*/1871export interface CreateTaskResultResponse extends JSONRPCResultResponse {1872result: CreateTaskResult;1873}18741875/**1876* A request to retrieve the state of a task.1877*1878* @category `tasks/get`1879*/1880export interface GetTaskRequest extends JSONRPCRequest {1881method: "tasks/get";1882params: {1883/**1884* The task identifier to query.1885*/1886taskId: string;1887};1888}18891890/**1891* The result returned for a {@link GetTaskRequest | tasks/get} request.1892*1893* @category `tasks/get`1894*/1895export type GetTaskResult = Result & Task;18961897/**1898* A successful response for a {@link GetTaskRequest | tasks/get} request.1899*1900* @category `tasks/get`1901*/1902export interface GetTaskResultResponse extends JSONRPCResultResponse {1903result: GetTaskResult;1904}19051906/**1907* A request to retrieve the result of a completed task.1908*1909* @category `tasks/result`1910*/1911export interface GetTaskPayloadRequest extends JSONRPCRequest {1912method: "tasks/result";1913params: {1914/**1915* The task identifier to retrieve results for.1916*/1917taskId: string;1918};1919}19201921/**1922* The result returned for a {@link GetTaskPayloadRequest | tasks/result} request.1923* The structure matches the result type of the original request.1924* For example, a {@link CallToolRequest | tools/call} task would return the {@link CallToolResult} structure.1925*1926* @category `tasks/result`1927*/1928export interface GetTaskPayloadResult extends Result {1929[key: string]: unknown;1930}19311932/**1933* A successful response for a {@link GetTaskPayloadRequest | tasks/result} request.1934*1935* @category `tasks/result`1936*/1937export interface GetTaskPayloadResultResponse extends JSONRPCResultResponse {1938result: GetTaskPayloadResult;1939}19401941/**1942* A request to cancel a task.1943*1944* @category `tasks/cancel`1945*/1946export interface CancelTaskRequest extends JSONRPCRequest {1947method: "tasks/cancel";1948params: {1949/**1950* The task identifier to cancel.1951*/1952taskId: string;1953};1954}19551956/**1957* The result returned for a {@link CancelTaskRequest | tasks/cancel} request.1958*1959* @category `tasks/cancel`1960*/1961export type CancelTaskResult = Result & Task;19621963/**1964* A successful response for a {@link CancelTaskRequest | tasks/cancel} request.1965*1966* @category `tasks/cancel`1967*/1968export interface CancelTaskResultResponse extends JSONRPCResultResponse {1969result: CancelTaskResult;1970}19711972/**1973* A request to retrieve a list of tasks.1974*1975* @category `tasks/list`1976*/1977export interface ListTasksRequest extends PaginatedRequest {1978method: "tasks/list";1979}19801981/**1982* The result returned for a {@link ListTasksRequest | tasks/list} request.1983*1984* @category `tasks/list`1985*/1986export interface ListTasksResult extends PaginatedResult {1987tasks: Task[];1988}19891990/**1991* A successful response for a {@link ListTasksRequest | tasks/list} request.1992*1993* @category `tasks/list`1994*/1995export interface ListTasksResultResponse extends JSONRPCResultResponse {1996result: ListTasksResult;1997}19981999/**2000* Parameters for a `notifications/tasks/status` notification.2001*2002* @category `notifications/tasks/status`2003*/2004export type TaskStatusNotificationParams = NotificationParams & Task;20052006/**2007* An optional notification from the receiver to the requestor, informing them that a task's status has changed. Receivers are not required to send these notifications.2008*2009* @category `notifications/tasks/status`2010*/2011export interface TaskStatusNotification extends JSONRPCNotification {2012method: "notifications/tasks/status";2013params: TaskStatusNotificationParams;2014}20152016/* Logging */20172018/**2019* Parameters for a `logging/setLevel` request.2020*2021* @example Set log level to "info"2022* {@includeCode ./examples/SetLevelRequestParams/set-log-level-to-info.json}2023*2024* @category `logging/setLevel`2025*/2026export interface SetLevelRequestParams extends RequestParams {2027/**2028* 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 {@link LoggingMessageNotification | notifications/message}.2029*/2030level: LoggingLevel;2031}20322033/**2034* A request from the client to the server, to enable or adjust logging.2035*2036* @example Set logging level request2037* {@includeCode ./examples/SetLevelRequest/set-logging-level-request.json}2038*2039* @category `logging/setLevel`2040*/2041export interface SetLevelRequest extends JSONRPCRequest {2042method: "logging/setLevel";2043params: SetLevelRequestParams;2044}20452046/**2047* A successful response from the server for a {@link SetLevelRequest | logging/setLevel} request.2048*2049* @example Set logging level result response2050* {@includeCode ./examples/SetLevelResultResponse/set-logging-level-result-response.json}2051*2052* @category `logging/setLevel`2053*/2054export interface SetLevelResultResponse extends JSONRPCResultResponse {2055result: EmptyResult;2056}20572058/**2059* Parameters for a `notifications/message` notification.2060*2061* @example Log database connection failed2062* {@includeCode ./examples/LoggingMessageNotificationParams/log-database-connection-failed.json}2063*2064* @category `notifications/message`2065*/2066export interface LoggingMessageNotificationParams extends NotificationParams {2067/**2068* The severity of this log message.2069*/2070level: LoggingLevel;2071/**2072* An optional name of the logger issuing this message.2073*/2074logger?: string;2075/**2076* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.2077*/2078data: unknown;2079}20802081/**2082* JSONRPCNotification of a log message passed from server to client. If no `logging/setLevel` request has been sent from the client, the server MAY decide which messages to send automatically.2083*2084* @example Log database connection failed2085* {@includeCode ./examples/LoggingMessageNotification/log-database-connection-failed.json}2086*2087* @category `notifications/message`2088*/2089export interface LoggingMessageNotification extends JSONRPCNotification {2090method: "notifications/message";2091params: LoggingMessageNotificationParams;2092}20932094/**2095* The severity of a log message.2096*2097* These map to syslog message severities, as specified in RFC-5424:2098* https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.12099*2100* @category Common Types2101*/2102export type LoggingLevel =2103| "debug"2104| "info"2105| "notice"2106| "warning"2107| "error"2108| "critical"2109| "alert"2110| "emergency";21112112/* Sampling */2113/**2114* Parameters for a `sampling/createMessage` request.2115*2116* @example Basic request2117* {@includeCode ./examples/CreateMessageRequestParams/basic-request.json}2118*2119* @example Request with tools2120* {@includeCode ./examples/CreateMessageRequestParams/request-with-tools.json}2121*2122* @example Follow-up request with tool results2123* {@includeCode ./examples/CreateMessageRequestParams/follow-up-with-tool-results.json}2124*2125* @category `sampling/createMessage`2126*/2127export interface CreateMessageRequestParams extends TaskAugmentedRequestParams {2128messages: SamplingMessage[];2129/**2130* The server's preferences for which model to select. The client MAY ignore these preferences.2131*/2132modelPreferences?: ModelPreferences;2133/**2134* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.2135*/2136systemPrompt?: string;2137/**2138* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.2139* The client MAY ignore this request.2140*2141* Default is `"none"`. Values `"thisServer"` and `"allServers"` are soft-deprecated. Servers SHOULD only use these values if the client2142* declares {@link ClientCapabilities.sampling.context}. These values may be removed in future spec releases.2143*/2144includeContext?: "none" | "thisServer" | "allServers";2145/**2146* @TJS-type number2147*/2148temperature?: number;2149/**2150* The requested maximum number of tokens to sample (to prevent runaway completions).2151*2152* The client MAY choose to sample fewer tokens than the requested maximum.2153*/2154maxTokens: number;2155stopSequences?: string[];2156/**2157* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.2158*/2159metadata?: object;2160/**2161* Tools that the model may use during generation.2162* The client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared.2163*/2164tools?: Tool[];2165/**2166* Controls how the model uses tools.2167* The client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared.2168* Default is `{ mode: "auto" }`.2169*/2170toolChoice?: ToolChoice;2171}21722173/**2174* Controls tool selection behavior for sampling requests.2175*2176* @category `sampling/createMessage`2177*/2178export interface ToolChoice {2179/**2180* Controls the tool use ability of the model:2181* - `"auto"`: Model decides whether to use tools (default)2182* - `"required"`: Model MUST use at least one tool before completing2183* - `"none"`: Model MUST NOT use any tools2184*/2185mode?: "auto" | "required" | "none";2186}21872188/**2189* 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.2190*2191* @example Sampling request2192* {@includeCode ./examples/CreateMessageRequest/sampling-request.json}2193*2194* @category `sampling/createMessage`2195*/2196export interface CreateMessageRequest extends JSONRPCRequest {2197method: "sampling/createMessage";2198params: CreateMessageRequestParams;2199}22002201/**2202* The result returned by the client for a {@link CreateMessageRequest | sampling/createMessage} request.2203* The client should inform the user before returning the sampled message, to allow them2204* to inspect the response (human in the loop) and decide whether to allow the server to see it.2205*2206* @example Text response2207* {@includeCode ./examples/CreateMessageResult/text-response.json}2208*2209* @example Tool use response2210* {@includeCode ./examples/CreateMessageResult/tool-use-response.json}2211*2212* @example Final response after tool use2213* {@includeCode ./examples/CreateMessageResult/final-response.json}2214*2215* @category `sampling/createMessage`2216*/2217export interface CreateMessageResult extends Result, SamplingMessage {2218/**2219* The name of the model that generated the message.2220*/2221model: string;22222223/**2224* The reason why sampling stopped, if known.2225*2226* Standard values:2227* - `"endTurn"`: Natural end of the assistant's turn2228* - `"stopSequence"`: A stop sequence was encountered2229* - `"maxTokens"`: Maximum token limit was reached2230* - `"toolUse"`: The model wants to use one or more tools2231*2232* This field is an open string to allow for provider-specific stop reasons.2233*/2234stopReason?: "endTurn" | "stopSequence" | "maxTokens" | "toolUse" | string;2235}22362237/**2238* A successful response from the client for a {@link CreateMessageRequest | sampling/createMessage} request.2239*2240* @example Sampling result response2241* {@includeCode ./examples/CreateMessageResultResponse/sampling-result-response.json}2242*2243* @category `sampling/createMessage`2244*/2245export interface CreateMessageResultResponse extends JSONRPCResultResponse {2246result: CreateMessageResult;2247}22482249/**2250* Describes a message issued to or received from an LLM API.2251*2252* @example Single content block2253* {@includeCode ./examples/SamplingMessage/single-content-block.json}2254*2255* @example Multiple content blocks2256* {@includeCode ./examples/SamplingMessage/multiple-content-blocks.json}2257*2258* @category `sampling/createMessage`2259*/2260export interface SamplingMessage {2261role: Role;2262content: SamplingMessageContentBlock | SamplingMessageContentBlock[];2263_meta?: MetaObject;2264}22652266/**2267* @category `sampling/createMessage`2268*/2269export type SamplingMessageContentBlock =2270| TextContent2271| ImageContent2272| AudioContent2273| ToolUseContent2274| ToolResultContent;22752276/**2277* Optional annotations for the client. The client can use annotations to inform how objects are used or displayed2278*2279* @category Common Types2280*/2281export interface Annotations {2282/**2283* Describes who the intended audience of this object or data is.2284*2285* It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).2286*/2287audience?: Role[];22882289/**2290* Describes how important this data is for operating the server.2291*2292* A value of 1 means "most important," and indicates that the data is2293* effectively required, while 0 means "least important," and indicates that2294* the data is entirely optional.2295*2296* @TJS-type number2297* @minimum 02298* @maximum 12299*/2300priority?: number;23012302/**2303* The moment the resource was last modified, as an ISO 8601 formatted string.2304*2305* Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z").2306*2307* Examples: last activity timestamp in an open file, timestamp when the resource2308* was attached, etc.2309*/2310lastModified?: string;2311}23122313/**2314* @category Content2315*/2316export type ContentBlock =2317| TextContent2318| ImageContent2319| AudioContent2320| ResourceLink2321| EmbeddedResource;23222323/**2324* Text provided to or from an LLM.2325*2326* @example Text content2327* {@includeCode ./examples/TextContent/text-content.json}2328*2329* @category Content2330*/2331export interface TextContent {2332type: "text";23332334/**2335* The text content of the message.2336*/2337text: string;23382339/**2340* Optional annotations for the client.2341*/2342annotations?: Annotations;23432344_meta?: MetaObject;2345}23462347/**2348* An image provided to or from an LLM.2349*2350* @example `image/png` content with annotations2351* {@includeCode ./examples/ImageContent/image-png-content-with-annotations.json}2352*2353* @category Content2354*/2355export interface ImageContent {2356type: "image";23572358/**2359* The base64-encoded image data.2360*2361* @format byte2362*/2363data: string;23642365/**2366* The MIME type of the image. Different providers may support different image types.2367*/2368mimeType: string;23692370/**2371* Optional annotations for the client.2372*/2373annotations?: Annotations;23742375_meta?: MetaObject;2376}23772378/**2379* Audio provided to or from an LLM.2380*2381* @example `audio/wav` content2382* {@includeCode ./examples/AudioContent/audio-wav-content.json}2383*2384* @category Content2385*/2386export interface AudioContent {2387type: "audio";23882389/**2390* The base64-encoded audio data.2391*2392* @format byte2393*/2394data: string;23952396/**2397* The MIME type of the audio. Different providers may support different audio types.2398*/2399mimeType: string;24002401/**2402* Optional annotations for the client.2403*/2404annotations?: Annotations;24052406_meta?: MetaObject;2407}24082409/**2410* A request from the assistant to call a tool.2411*2412* @example `get_weather` tool use2413* {@includeCode ./examples/ToolUseContent/get-weather-tool-use.json}2414*2415* @category `sampling/createMessage`2416*/2417export interface ToolUseContent {2418type: "tool_use";24192420/**2421* A unique identifier for this tool use.2422*2423* This ID is used to match tool results to their corresponding tool uses.2424*/2425id: string;24262427/**2428* The name of the tool to call.2429*/2430name: string;24312432/**2433* The arguments to pass to the tool, conforming to the tool's input schema.2434*/2435input: { [key: string]: unknown };24362437/**2438* Optional metadata about the tool use. Clients SHOULD preserve this field when2439* including tool uses in subsequent sampling requests to enable caching optimizations.2440*/2441_meta?: MetaObject;2442}24432444/**2445* The result of a tool use, provided by the user back to the assistant.2446*2447* @example `get_weather` tool result2448* {@includeCode ./examples/ToolResultContent/get-weather-tool-result.json}2449*2450* @category `sampling/createMessage`2451*/2452export interface ToolResultContent {2453type: "tool_result";24542455/**2456* The ID of the tool use this result corresponds to.2457*2458* This MUST match the ID from a previous {@link ToolUseContent}.2459*/2460toolUseId: string;24612462/**2463* The unstructured result content of the tool use.2464*2465* This has the same format as {@link CallToolResult.content} and can include text, images,2466* audio, resource links, and embedded resources.2467*/2468content: ContentBlock[];24692470/**2471* An optional structured result object.2472*2473* If the tool defined an {@link Tool.outputSchema}, this SHOULD conform to that schema.2474*/2475structuredContent?: { [key: string]: unknown };24762477/**2478* Whether the tool use resulted in an error.2479*2480* If true, the content typically describes the error that occurred.2481* Default: false2482*/2483isError?: boolean;24842485/**2486* Optional metadata about the tool result. Clients SHOULD preserve this field when2487* including tool results in subsequent sampling requests to enable caching optimizations.2488*/2489_meta?: MetaObject;2490}24912492/**2493* The server's preferences for model selection, requested of the client during sampling.2494*2495* Because LLMs can vary along multiple dimensions, choosing the "best" model is2496* rarely straightforward. Different models excel in different areas-some are2497* faster but less capable, others are more capable but more expensive, and so2498* on. This interface allows servers to express their priorities across multiple2499* dimensions to help clients make an appropriate selection for their use case.2500*2501* These preferences are always advisory. The client MAY ignore them. It is also2502* up to the client to decide how to interpret these preferences and how to2503* balance them against other considerations.2504*2505* @example With hints and priorities2506* {@includeCode ./examples/ModelPreferences/with-hints-and-priorities.json}2507*2508* @category `sampling/createMessage`2509*/2510export interface ModelPreferences {2511/**2512* Optional hints to use for model selection.2513*2514* If multiple hints are specified, the client MUST evaluate them in order2515* (such that the first match is taken).2516*2517* The client SHOULD prioritize these hints over the numeric priorities, but2518* MAY still use the priorities to select from ambiguous matches.2519*/2520hints?: ModelHint[];25212522/**2523* How much to prioritize cost when selecting a model. A value of 0 means cost2524* is not important, while a value of 1 means cost is the most important2525* factor.2526*2527* @TJS-type number2528* @minimum 02529* @maximum 12530*/2531costPriority?: number;25322533/**2534* How much to prioritize sampling speed (latency) when selecting a model. A2535* value of 0 means speed is not important, while a value of 1 means speed is2536* the most important factor.2537*2538* @TJS-type number2539* @minimum 02540* @maximum 12541*/2542speedPriority?: number;25432544/**2545* How much to prioritize intelligence and capabilities when selecting a2546* model. A value of 0 means intelligence is not important, while a value of 12547* means intelligence is the most important factor.2548*2549* @TJS-type number2550* @minimum 02551* @maximum 12552*/2553intelligencePriority?: number;2554}25552556/**2557* Hints to use for model selection.2558*2559* Keys not declared here are currently left unspecified by the spec and are up2560* to the client to interpret.2561*2562* @category `sampling/createMessage`2563*/2564export interface ModelHint {2565/**2566* A hint for a model name.2567*2568* The client SHOULD treat this as a substring of a model name; for example:2569* - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`2570* - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.2571* - `claude` should match any Claude model2572*2573* 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:2574* - `gemini-1.5-flash` could match `claude-3-haiku-20240307`2575*/2576name?: string;2577}25782579/* Autocomplete */2580/**2581* Parameters for a `completion/complete` request.2582*2583* @category `completion/complete`2584*2585* @example Prompt argument completion2586* {@includeCode ./examples/CompleteRequestParams/prompt-argument-completion.json}2587*2588* @example Prompt argument completion with context2589* {@includeCode ./examples/CompleteRequestParams/prompt-argument-completion-with-context.json}2590*/2591export interface CompleteRequestParams extends RequestParams {2592ref: PromptReference | ResourceTemplateReference;2593/**2594* The argument's information2595*/2596argument: {2597/**2598* The name of the argument2599*/2600name: string;2601/**2602* The value of the argument to use for completion matching.2603*/2604value: string;2605};26062607/**2608* Additional, optional context for completions2609*/2610context?: {2611/**2612* Previously-resolved variables in a URI template or prompt.2613*/2614arguments?: { [key: string]: string };2615};2616}26172618/**2619* A request from the client to the server, to ask for completion options.2620*2621* @example Completion request2622* {@includeCode ./examples/CompleteRequest/completion-request.json}2623*2624* @category `completion/complete`2625*/2626export interface CompleteRequest extends JSONRPCRequest {2627method: "completion/complete";2628params: CompleteRequestParams;2629}26302631/**2632* The result returned by the server for a {@link CompleteRequest | completion/complete} request.2633*2634* @category `completion/complete`2635*2636* @example Single completion value2637* {@includeCode ./examples/CompleteResult/single-completion-value.json}2638*2639* @example Multiple completion values with more available2640* {@includeCode ./examples/CompleteResult/multiple-completion-values-with-more-available.json}2641*/2642export interface CompleteResult extends Result {2643completion: {2644/**2645* An array of completion values. Must not exceed 100 items.2646*/2647values: string[];2648/**2649* The total number of completion options available. This can exceed the number of values actually sent in the response.2650*/2651total?: number;2652/**2653* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.2654*/2655hasMore?: boolean;2656};2657}26582659/**2660* A successful response from the server for a {@link CompleteRequest | completion/complete} request.2661*2662* @example Completion result response2663* {@includeCode ./examples/CompleteResultResponse/completion-result-response.json}2664*2665* @category `completion/complete`2666*/2667export interface CompleteResultResponse extends JSONRPCResultResponse {2668result: CompleteResult;2669}26702671/**2672* A reference to a resource or resource template definition.2673*2674* @category `completion/complete`2675*/2676export interface ResourceTemplateReference {2677type: "ref/resource";2678/**2679* The URI or URI template of the resource.2680*2681* @format uri-template2682*/2683uri: string;2684}26852686/**2687* Identifies a prompt.2688*2689* @category `completion/complete`2690*/2691export interface PromptReference extends BaseMetadata {2692type: "ref/prompt";2693}26942695/* Roots */2696/**2697* Sent from the server to request a list of root URIs from the client. Roots allow2698* servers to ask for specific directories or files to operate on. A common example2699* for roots is providing a set of repositories or directories a server should operate2700* on.2701*2702* This request is typically used when the server needs to understand the file system2703* structure or access specific locations that the client has permission to read from.2704*2705* @example List roots request2706* {@includeCode ./examples/ListRootsRequest/list-roots-request.json}2707*2708* @category `roots/list`2709*/2710export interface ListRootsRequest extends JSONRPCRequest {2711method: "roots/list";2712params?: RequestParams;2713}27142715/**2716* The result returned by the client for a {@link ListRootsRequest | roots/list} request.2717* This result contains an array of {@link Root} objects, each representing a root directory2718* or file that the server can operate on.2719*2720* @example Single root directory2721* {@includeCode ./examples/ListRootsResult/single-root-directory.json}2722*2723* @example Multiple root directories2724* {@includeCode ./examples/ListRootsResult/multiple-root-directories.json}2725*2726* @category `roots/list`2727*/2728export interface ListRootsResult extends Result {2729roots: Root[];2730}27312732/**2733* A successful response from the client for a {@link ListRootsRequest | roots/list} request.2734*2735* @example List roots result response2736* {@includeCode ./examples/ListRootsResultResponse/list-roots-result-response.json}2737*2738* @category `roots/list`2739*/2740export interface ListRootsResultResponse extends JSONRPCResultResponse {2741result: ListRootsResult;2742}27432744/**2745* Represents a root directory or file that the server can operate on.2746*2747* @example Project directory root2748* {@includeCode ./examples/Root/project-directory.json}2749*2750* @category `roots/list`2751*/2752export interface Root {2753/**2754* The URI identifying the root. This *must* start with `file://` for now.2755* This restriction may be relaxed in future versions of the protocol to allow2756* other URI schemes.2757*2758* @format uri2759*/2760uri: string;2761/**2762* An optional name for the root. This can be used to provide a human-readable2763* identifier for the root, which may be useful for display purposes or for2764* referencing the root in other parts of the application.2765*/2766name?: string;27672768_meta?: MetaObject;2769}27702771/**2772* A notification from the client to the server, informing it that the list of roots has changed.2773* This notification should be sent whenever the client adds, removes, or modifies any root.2774* The server should then request an updated list of roots using the {@link ListRootsRequest}.2775*2776* @example Roots list changed2777* {@includeCode ./examples/RootsListChangedNotification/roots-list-changed.json}2778*2779* @category `notifications/roots/list_changed`2780*/2781export interface RootsListChangedNotification extends JSONRPCNotification {2782method: "notifications/roots/list_changed";2783params?: NotificationParams;2784}27852786/**2787* The parameters for a request to elicit non-sensitive information from the user via a form in the client.2788*2789* @example Elicit single field2790* {@includeCode ./examples/ElicitRequestFormParams/elicit-single-field.json}2791*2792* @example Elicit multiple fields2793* {@includeCode ./examples/ElicitRequestFormParams/elicit-multiple-fields.json}2794*2795* @category `elicitation/create`2796*/2797export interface ElicitRequestFormParams extends TaskAugmentedRequestParams {2798/**2799* The elicitation mode.2800*/2801mode?: "form";28022803/**2804* The message to present to the user describing what information is being requested.2805*/2806message: string;28072808/**2809* A restricted subset of JSON Schema.2810* Only top-level properties are allowed, without nesting.2811*/2812requestedSchema: {2813$schema?: string;2814type: "object";2815properties: {2816[key: string]: PrimitiveSchemaDefinition;2817};2818required?: string[];2819};2820}28212822/**2823* The parameters for a request to elicit information from the user via a URL in the client.2824*2825* @example Elicit sensitive data2826* {@includeCode ./examples/ElicitRequestURLParams/elicit-sensitive-data.json}2827*2828* @category `elicitation/create`2829*/2830export interface ElicitRequestURLParams extends TaskAugmentedRequestParams {2831/**2832* The elicitation mode.2833*/2834mode: "url";28352836/**2837* The message to present to the user explaining why the interaction is needed.2838*/2839message: string;28402841/**2842* The ID of the elicitation, which must be unique within the context of the server.2843* The client MUST treat this ID as an opaque value.2844*/2845elicitationId: string;28462847/**2848* The URL that the user should navigate to.2849*2850* @format uri2851*/2852url: string;2853}28542855/**2856* The parameters for a request to elicit additional information from the user via the client.2857*2858* @category `elicitation/create`2859*/2860export type ElicitRequestParams =2861| ElicitRequestFormParams2862| ElicitRequestURLParams;28632864/**2865* A request from the server to elicit additional information from the user via the client.2866*2867* @example Elicitation request2868* {@includeCode ./examples/ElicitRequest/elicitation-request.json}2869*2870* @category `elicitation/create`2871*/2872export interface ElicitRequest extends JSONRPCRequest {2873method: "elicitation/create";2874params: ElicitRequestParams;2875}28762877/**2878* Restricted schema definitions that only allow primitive types2879* without nested objects or arrays.2880*2881* @category `elicitation/create`2882*/2883export type PrimitiveSchemaDefinition =2884| StringSchema2885| NumberSchema2886| BooleanSchema2887| EnumSchema;28882889/**2890* @example Email input schema2891* {@includeCode ./examples/StringSchema/email-input-schema.json}2892*2893* @category `elicitation/create`2894*/2895export interface StringSchema {2896type: "string";2897title?: string;2898description?: string;2899minLength?: number;2900maxLength?: number;2901format?: "email" | "uri" | "date" | "date-time";2902default?: string;2903}29042905/**2906* @example Number input schema2907* {@includeCode ./examples/NumberSchema/number-input-schema.json}2908*2909* @category `elicitation/create`2910*/2911export interface NumberSchema {2912type: "number" | "integer";2913title?: string;2914description?: string;2915minimum?: number;2916maximum?: number;2917default?: number;2918}29192920/**2921* @example Boolean input schema2922* {@includeCode ./examples/BooleanSchema/boolean-input-schema.json}2923*2924* @category `elicitation/create`2925*/2926export interface BooleanSchema {2927type: "boolean";2928title?: string;2929description?: string;2930default?: boolean;2931}29322933/**2934* Schema for single-selection enumeration without display titles for options.2935*2936* @example Color select schema2937* {@includeCode ./examples/UntitledSingleSelectEnumSchema/color-select-schema.json}2938*2939* @category `elicitation/create`2940*/2941export interface UntitledSingleSelectEnumSchema {2942type: "string";2943/**2944* Optional title for the enum field.2945*/2946title?: string;2947/**2948* Optional description for the enum field.2949*/2950description?: string;2951/**2952* Array of enum values to choose from.2953*/2954enum: string[];2955/**2956* Optional default value.2957*/2958default?: string;2959}29602961/**2962* Schema for single-selection enumeration with display titles for each option.2963*2964* @example Titled color select schema2965* {@includeCode ./examples/TitledSingleSelectEnumSchema/titled-color-select-schema.json}2966*2967* @category `elicitation/create`2968*/2969export interface TitledSingleSelectEnumSchema {2970type: "string";2971/**2972* Optional title for the enum field.2973*/2974title?: string;2975/**2976* Optional description for the enum field.2977*/2978description?: string;2979/**2980* Array of enum options with values and display labels.2981*/2982oneOf: Array<{2983/**2984* The enum value.2985*/2986const: string;2987/**2988* Display label for this option.2989*/2990title: string;2991}>;2992/**2993* Optional default value.2994*/2995default?: string;2996}29972998/**2999* @category `elicitation/create`3000*/3001// Combined single selection enumeration3002export type SingleSelectEnumSchema =3003| UntitledSingleSelectEnumSchema3004| TitledSingleSelectEnumSchema;30053006/**3007* Schema for multiple-selection enumeration without display titles for options.3008*3009* @example Color multi-select schema3010* {@includeCode ./examples/UntitledMultiSelectEnumSchema/color-multi-select-schema.json}3011*3012* @category `elicitation/create`3013*/3014export interface UntitledMultiSelectEnumSchema {3015type: "array";3016/**3017* Optional title for the enum field.3018*/3019title?: string;3020/**3021* Optional description for the enum field.3022*/3023description?: string;3024/**3025* Minimum number of items to select.3026*/3027minItems?: number;3028/**3029* Maximum number of items to select.3030*/3031maxItems?: number;3032/**3033* Schema for the array items.3034*/3035items: {3036type: "string";3037/**3038* Array of enum values to choose from.3039*/3040enum: string[];3041};3042/**3043* Optional default value.3044*/3045default?: string[];3046}30473048/**3049* Schema for multiple-selection enumeration with display titles for each option.3050*3051* @example Titled color multi-select schema3052* {@includeCode ./examples/TitledMultiSelectEnumSchema/titled-color-multi-select-schema.json}3053*3054* @category `elicitation/create`3055*/3056export interface TitledMultiSelectEnumSchema {3057type: "array";3058/**3059* Optional title for the enum field.3060*/3061title?: string;3062/**3063* Optional description for the enum field.3064*/3065description?: string;3066/**3067* Minimum number of items to select.3068*/3069minItems?: number;3070/**3071* Maximum number of items to select.3072*/3073maxItems?: number;3074/**3075* Schema for array items with enum options and display labels.3076*/3077items: {3078/**3079* Array of enum options with values and display labels.3080*/3081anyOf: Array<{3082/**3083* The constant enum value.3084*/3085const: string;3086/**3087* Display title for this option.3088*/3089title: string;3090}>;3091};3092/**3093* Optional default value.3094*/3095default?: string[];3096}30973098/**3099* @category `elicitation/create`3100*/3101// Combined multiple selection enumeration3102export type MultiSelectEnumSchema =3103| UntitledMultiSelectEnumSchema3104| TitledMultiSelectEnumSchema;31053106/**3107* Use {@link TitledSingleSelectEnumSchema} instead.3108* This interface will be removed in a future version.3109*3110* @category `elicitation/create`3111*/3112export interface LegacyTitledEnumSchema {3113type: "string";3114title?: string;3115description?: string;3116enum: string[];3117/**3118* (Legacy) Display names for enum values.3119* Non-standard according to JSON schema 2020-12.3120*/3121enumNames?: string[];3122default?: string;3123}31243125/**3126* @category `elicitation/create`3127*/3128// Union type for all enum schemas3129export type EnumSchema =3130| SingleSelectEnumSchema3131| MultiSelectEnumSchema3132| LegacyTitledEnumSchema;31333134/**3135* The result returned by the client for an {@link ElicitRequest | elicitation/create} request.3136*3137* @example Input single field3138* {@includeCode ./examples/ElicitResult/input-single-field.json}3139*3140* @example Input multiple fields3141* {@includeCode ./examples/ElicitResult/input-multiple-fields.json}3142*3143* @example Accept URL mode (no content)3144* {@includeCode ./examples/ElicitResult/accept-url-mode-no-content.json}3145*3146* @category `elicitation/create`3147*/3148export interface ElicitResult extends Result {3149/**3150* The user action in response to the elicitation.3151* - `"accept"`: User submitted the form/confirmed the action3152* - `"decline"`: User explicitly declined the action3153* - `"cancel"`: User dismissed without making an explicit choice3154*/3155action: "accept" | "decline" | "cancel";31563157/**3158* The submitted form data, only present when action is `"accept"` and mode was `"form"`.3159* Contains values matching the requested schema.3160* Omitted for out-of-band mode responses.3161*/3162content?: { [key: string]: string | number | boolean | string[] };3163}31643165/**3166* A successful response from the client for a {@link ElicitRequest | elicitation/create} request.3167*3168* @example Elicitation result response3169* {@includeCode ./examples/ElicitResultResponse/elicitation-result-response.json}3170*3171* @category `elicitation/create`3172*/3173export interface ElicitResultResponse extends JSONRPCResultResponse {3174result: ElicitResult;3175}31763177/**3178* An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request.3179*3180* @example Elicitation complete3181* {@includeCode ./examples/ElicitationCompleteNotification/elicitation-complete.json}3182*3183* @category `notifications/elicitation/complete`3184*/3185export interface ElicitationCompleteNotification extends JSONRPCNotification {3186method: "notifications/elicitation/complete";3187params: {3188/**3189* The ID of the elicitation that completed.3190*/3191elicitationId: string;3192};3193}31943195/* Client messages */3196/** @internal */3197export type ClientRequest =3198| PingRequest3199| InitializeRequest3200| CompleteRequest3201| SetLevelRequest3202| GetPromptRequest3203| ListPromptsRequest3204| ListResourcesRequest3205| ListResourceTemplatesRequest3206| ReadResourceRequest3207| SubscribeRequest3208| UnsubscribeRequest3209| CallToolRequest3210| ListToolsRequest3211| GetTaskRequest3212| GetTaskPayloadRequest3213| ListTasksRequest3214| CancelTaskRequest;32153216/** @internal */3217export type ClientNotification =3218| CancelledNotification3219| ProgressNotification3220| InitializedNotification3221| RootsListChangedNotification3222| TaskStatusNotification;32233224/** @internal */3225export type ClientResult =3226| EmptyResult3227| CreateMessageResult3228| ListRootsResult3229| ElicitResult3230| GetTaskResult3231| GetTaskPayloadResult3232| ListTasksResult3233| CancelTaskResult;32343235/* Server messages */3236/** @internal */3237export type ServerRequest =3238| PingRequest3239| CreateMessageRequest3240| ListRootsRequest3241| ElicitRequest3242| GetTaskRequest3243| GetTaskPayloadRequest3244| ListTasksRequest3245| CancelTaskRequest;32463247/** @internal */3248export type ServerNotification =3249| CancelledNotification3250| ProgressNotification3251| LoggingMessageNotification3252| ResourceUpdatedNotification3253| ResourceListChangedNotification3254| ToolListChangedNotification3255| PromptListChangedNotification3256| ElicitationCompleteNotification3257| TaskStatusNotification;32583259/** @internal */3260export type ServerResult =3261| EmptyResult3262| InitializeResult3263| CompleteResult3264| GetPromptResult3265| ListPromptsResult3266| ListResourceTemplatesResult3267| ListResourcesResult3268| ReadResourceResult3269| CallToolResult3270| CreateTaskResult3271| ListToolsResult3272| GetTaskResult3273| GetTaskPayloadResult3274| ListTasksResult3275| CancelTaskResult;3276}327732783279