- 1. 什么是模式参考?
- 2. 如何使用本文档
- 3. 目录速查
- 4. JSON-RPC
- 5. 通用类型
- 6. 内容
- 7. completion/complete
- 8. elicitation/create
- 6.1 ElicitRequest
- 6.2 ElicitRequestParams
- 6.3 ElicitResult
- 6.4 BooleanSchema
- 6.5 ElicitRequestFormParams
- 6.6 ElicitRequestURLParams
- 6.7 EnumSchema
- 6.8 LegacyTitledEnumSchema
- 6.9 MultiSelectEnumSchema
- 6.10 NumberSchema
- 6.11 PrimitiveSchemaDefinition
- 6.12 SingleSelectEnumSchema
- 6.13 StringSchema
- 6.14 TitledMultiSelectEnumSchema
- 6.15 TitledSingleSelectEnumSchema
- 6.16 UntitledMultiSelectEnumSchema
- 6.17 UntitledSingleSelectEnumSchema
- 9. initialize
- 10. logging/setLevel
- 11. notifications/cancelled
- 12. notifications/initialized
- 13. notifications/tasks/status
- 14. notifications/message
- 15. notifications/progress
- 16. notifications/prompts/list_changed
- 17. notifications/resources/list_changed
- 18. notifications/resources/updated
- 19. notifications/roots/list_changed
- 20. notifications/tools/list_changed
- 21. notifications/elicitation/complete
- 22. ping
- 23. tasks/get
- 24. tasks/result
- 25. tasks/list
- 26. tasks/cancel
- 27. prompts/get
- 28. prompts/list
- 29. resources/list
- 30. resources/read
- 31. resources/subscribe
- 32. resources/templates/list
- 33. resources/unsubscribe
- 34. roots/list
- 35. sampling/createMessage
- 36. tools/call
- 37. tools/list
1. 什么是模式参考? #
模式参考(Schema Reference)是 MCP 协议中所有数据类型和接口的完整定义文档。当你需要精确了解某个请求/响应的字段、类型或约束时,可在此查阅。
协议版本:2025-11-25
| 通俗理解 | 说明 |
|---|---|
| 类型手册 | 类似编程语言的 API 文档,列出每个结构的字段与含义 |
| 按需查阅 | 不必通读,需要时按目录跳转到对应章节 |
| 与教程互补 | 想了解「怎么用」请看各功能教程;想了解「长什么样」请看本文 |
2. 如何使用本文档 #
- 新手:先学 基础协议、工具、提示 等教程,遇到具体字段再回查本文
- 实现者:按方法名(如
tools/call、prompts/list)或类型名(如Tool、ContentBlock)定位 - 速查:见下方目录,点击跳转到对应章节
3. 目录速查 #
| 章节 | 内容 |
|---|---|
| §4 JSON-RPC | 请求、响应、通知的基础结构 |
| §5 通用类型 | Annotations、Error、Icon、Cursor 等 |
| §6 内容 | TextContent、ImageContent、ResourceLink 等 |
| §7 completion/complete | 补全请求与结果 |
| §8 elicitation/create | 引导表单 |
| §9 initialize | 初始化与能力协商 |
| §10 logging/setLevel | 日志级别 |
| §11–21 notifications/* | 各类通知 |
| §22 ping | 心跳 |
| §23–26 tasks/* | 任务相关 |
| §27–28 prompts/* | 提示相关 |
| §29–33 resources/* | 资源相关 |
| §34 roots/list | 根目录 |
| §35 sampling/createMessage | 采样 |
| §36–37 tools/* | 工具相关 |
4. JSON-RPC #
4.1 JSONRPCErrorResponse #
interface JSONRPCErrorResponse {
[jsonrpc](#jsonrpcerrorresponse-jsonrpc): “2.0”;
[id](#jsonrpcerrorresponse-id)?: [RequestId](#requestid);
[error](#jsonrpcerrorresponse-error): [Error](#error);
}表示请求发生错误的响应。
4.2 JSONRPCMessage #
JSONRPCMessage: [JSONRPCRequest](#jsonrpcrequest) | [JSONRPCNotification](#jsonrpcnotification) | [JSONRPCResponse](#jsonrpcresponse)指可从线路解码或编码发送的任何有效 JSON-RPC 对象。
4.3 JSONRPCNotification #
interface JSONRPCNotification {
[method](#jsonrpcnotification-method): string;
[params](#jsonrpcnotification-params)?: { $$key: string$$: any };
[jsonrpc](#jsonrpcnotification-jsonrpc): “2.0”;
}不期望响应的通知。
4.4 JSONRPCRequest #
interface JSONRPCRequest {
[method](#jsonrpcrequest-method): string;
[params](#jsonrpcrequest-params)?: { $$key: string$$: any };
[jsonrpc](#jsonrpcrequest-jsonrpc): “2.0”;
[id](#jsonrpcrequest-id): [RequestId](#requestid);
}期望响应的请求。
4.5 JSONRPCResponse #
JSONRPCResponse: [JSONRPCResultResponse](#jsonrpcresultresponse) | [JSONRPCErrorResponse](#jsonrpcerrorresponse)对请求的响应,包含结果或错误。
4.6 JSONRPCResultResponse #
interface JSONRPCResultResponse {
[jsonrpc](#jsonrpcresultresponse-jsonrpc): “2.0”;
[id](#jsonrpcresultresponse-id): [RequestId](#requestid);
[result](#jsonrpcresultresponse-result): [Result](#result);
}5. 通用类型 #
5.1 Annotations #
interface Annotations {
[audience](#annotations-audience)?: [Role](#role)$$$$;
[priority](#annotations-priority)?: number;
[lastModified](#annotations-lastmodified)?: string;
}客户端的可选注解。客户端可使用注解来告知对象的使用或显示方式
audience?: Role$$$$
描述此对象或数据的预期受众。
可包含多个值 ,表示内容对多类受众有用 (如 [“user”, “assistant”]).
priority?: number
描述此数据对操作服务端的重要程度。
1 表示「最重要」,数据实质为必需;0 表示「最不重要」,数据完全可选。
lastModified?: string
资源最后修改的时刻,采用 ISO 8601 格式字符串。
应为 ISO 8601 格式字符串 (如 "2025-01-12T15:00:58Z")。
示例:打开文件中的最后活动时间戳、资源附加时的时间戳等。
5.2 Cursor #
Cursor: string
用于表示分页游标的不透明令牌。
5.3 EmptyResult #
EmptyResult: [Result](#result)表示成功但不携带数据的响应。
5.4 Error #
interface Error {
[code](#error-code): number;
[message](#error-message): string;
[data](#error-data)?: unknown;
}code: number
发生的错误类型。
message: string
错误的简短描述。消息应限制为简洁的单句。
data?: unknown
有关错误的附加信息。此成员的值由发送方定义(如详细错误信息、嵌套错误等)。
5.5 Icon #
interface Icon {
[src](#icon-src): string;
[mimeType](#icon-mimetype)?: string;
[sizes](#icon-sizes)?: string$$$$;
[theme](#icon-theme)?: “light” | “dark”;
}可在用户界面中显示的可选尺寸图标。
src: string
指向图标资源的标准 URI。可以是 HTTP/HTTPS URL 或带有 Base64 编码图像数据的 data: URI。
消费者应采取步骤确保提供图标的 URL 来自与客户端/服务端相同的域或可信域。
消费者在使用 SVG 时应采取适当预防措施,因其可能包含可执行 JavaScript。
mimeType?: string
当源 MIME 类型缺失或通用时的可选 MIME 类型覆盖。例如:“image/png”、“image/jpeg” 或 “image/svg+xml”。
sizes?: string$$$$
指定图标可用尺寸的可选字符串数组。每个字符串应为 WxH 格式(例如 “48x48”、“96x96”)或对 SVG 等可缩放格式使用 “any”。
如未提供,客户端应假定图标可在任意尺寸使用。
theme?: “light” | “dark”
此图标设计主题的可选说明符。light 表示图标设计用于浅色背景,dark 表示图标设计用于深色背景。
如未提供,客户端应假定图标可用于任意主题。
5.6 LoggingLevel #
LoggingLevel:
| “debug”
| “info”
| “notice”
| “warning”
| “error”
| “critical”
| “alert”
| “emergency”日志消息的严重程度。
这些映射到 RFC-5424 中规定的 syslog 消息严重程度:
https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
5.7 ProgressToken #
ProgressToken: string | number
进度令牌,用于将进度通知与原始请求关联。
5.8 RequestId #
RequestId: string | number
JSON-RPC 中请求的唯一标识 ID。
5.9 Result #
interface Result {
[\_meta](#result-_meta)?: { $$key: string$$: unknown };
$$key: string$$: unknown;
}_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
5.10 Role #
Role: “user” | “assistant”对话中消息和数据的发送者或接收者。
6. 内容 #
6.1 AudioContent #
interface AudioContent {
[type](#audiocontent-type): “audio”;
[data](#audiocontent-data): string;
[mimeType](#audiocontent-mimetype): string;
[annotations](#audiocontent-annotations)?: [Annotations](#annotations);
[\_meta](#audiocontent-_meta)?: { $$key: string$$: unknown };
}提供给 LLM 或来自 LLM 的音频。
type: “audio”
data: string
Base64 编码的音频数据。
mimeType: string
音频的 MIME 类型。不同提供者可能支持不同的音频类型。
annotations?: Annotations
客户端的可选注解。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
6.2 BlobResourceContents #
interface BlobResourceContents {
uri: string;
mimeType?: string;
_meta?: { $$key: string$$: unknown };
blob: string;
}
uri: string
此资源的 URI。
继承自 ResourceContents.uri
mimeType?: string
此资源的 MIME 类型(如已知)。
继承自 ResourceContents.mimeType
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 ResourceContents._meta
blob: string
表示项目二进制数据的 Base64 编码字符串。
6.3 ContentBlock #
ContentBlock:
| [TextContent](#textcontent)
| [ImageContent](#imagecontent)
| [AudioContent](#audiocontent)
| [ResourceLink](#resourcelink)
| [EmbeddedResource](#embeddedresource)6.4 EmbeddedResource #
interface EmbeddedResource {
type: “resource”;
resource: TextResourceContents | BlobResourceContents;
annotations?: Annotations;
_meta?: { $$key: string$$: unknown };
}
嵌入到提示或工具调用结果中的资源内容。
由客户端决定如何最佳呈现嵌入资源以服务于 LLM 和/或用户。
type: “resource”
resource: TextResourceContents | BlobResourceContents
annotations?: Annotations
客户端的可选注解。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
6.5 ImageContent #
interface ImageContent {
[type](#imagecontent-type): “image”;
[data](#imagecontent-data): string;
[mimeType](#imagecontent-mimetype): string;
[annotations](#imagecontent-annotations)?: [Annotations](#annotations);
[\_meta](#imagecontent-_meta)?: { $$key: string$$: unknown };
}提供给 LLM 或来自 LLM 的图像。
type: “image”
data: string
Base64 编码的图像数据。
mimeType: string
图像的 MIME 类型。不同提供者可能支持不同的图像类型。
annotations?: Annotations
客户端的可选注解。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
6.6 ResourceLink #
interface ResourceLink {
[icons](#resourcelink-icons)?: [Icon](#icon)$$$$;
[name](#resourcelink-name): string;
[title](#resourcelink-title)?: string;
[uri](#resourcelink-uri): string;
[description](#resourcelink-description)?: string;
[mimeType](#resourcelink-mimetype)?: string;
[annotations](#resourcelink-annotations)?: [Annotations](#annotations);
[size](#resourcelink-size)?: number;
[\_meta](#resourcelink-_meta)?: { $$key: string$$: unknown };
[type](#resourcelink-type): “resource\_link”;
}服务端能够读取的资源,包含在提示或工具调用结果中。
注意:工具返回的资源链接不保证会出现在 resources/list 请求的结果中。
icons?: Icon$$$$
客户端可在用户界面中显示的可选尺寸图标集。
支持渲染图标的客户端必须至少支持以下 MIME 类型:
image/png- PNG 图像(安全、通用兼容)image/jpeg(及image/jpg)- JPEG 图像(安全、通用兼容)
支持渲染图标的客户端还应支持:
image/svg+xml- SVG 图像(可缩放,需注意安全)image/webp- WebP 图像(现代、高效格式)
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
uri: string
此资源的 URI。
description?: string
描述此资源所表示的内容。
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.
继承自 Resource.description
mimeType?: string
此资源的 MIME 类型(如已知)。
annotations?: Annotations
客户端的可选注解。
继承自 Resource.annotations
size?: number
原始资源内容的字节大小(即 base64 编码或任何分词之前),如已知。
主机可用于显示文件大小并估算上下文窗口使用量。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
type: “resource_link”
6.7 TextContent #
interface TextContent {
[type](#textcontent-type): “text”;
[text](#textcontent-text): string;
[annotations](#textcontent-annotations)?: [Annotations](#annotations);
[\_meta](#textcontent-_meta)?: { $$key: string$$: unknown };
}提供给 LLM 或来自 LLM 的文本。
type: “text”
text: string
消息的文本内容。
annotations?: Annotations
客户端的可选注解。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
6.8 TextResourceContents #
interface TextResourceContents {
[uri](#textresourcecontents-uri): string;
[mimeType](#textresourcecontents-mimetype)?: string;
[\_meta](#textresourcecontents-_meta)?: { $$key: string$$: unknown };
[text](#textresourcecontents-text): string;
}uri: string
此资源的 URI。
继承自 ResourceContents.uri
mimeType?: string
此资源的 MIME 类型(如已知)。
继承自 ResourceContents.mimeType
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 ResourceContents._meta
text: string
项的文本。仅当项实际上可以表示为文本(非二进制数据)时才必须设置。
7. completion/complete #
5.1 CompleteRequest #
interface CompleteRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “completion/complete”;
params: CompleteRequestParams;
}
客户端向服务端发出的请求,用于请求补全选项。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “completion/complete”
params: CompleteRequestParams
5.2 CompleteRequestParams #
interface CompleteRequestParams {
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
ref: PromptReference | ResourceTemplateReference;
argument: { name: string; value: string };
context?: { arguments?: { $$key: string$$: string } };
}
completion/complete 请求的参数。
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 RequestParams._meta
ref: PromptReference | ResourceTemplateReference
argument: { name: string; value: string }
参数的信息
类型声明
name: string
参数名称
value: string
用于补全匹配的参数值。
context?: { arguments?: { $$key: string$$: string } }
补全的额外可选上下文
类型声明
Optionalarguments?: { $$key: string$$: string }URI 模板或提示中已解析的变量。
5.3 CompleteResult #
interface CompleteResult {
_meta?: { $$key: string$$: unknown };
completion: { values: string$$$$; total?: number; hasMore?: boolean };
$$key: string$$: unknown;
}
服务器对 completion/complete 请求的响应
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
completion: { values: string$$$$; total?: number; hasMore?: boolean }
类型声明
values: string$$$$
补全值数组,不得超过 100 项。
Optionaltotal?: number可用补全选项总数,可超过响应中实际返回的数量。
OptionalhasMore?: boolean表示除当前响应外是否还有更多补全选项,即使总数未知。
5.4 PromptReference #
interface PromptReference {
name: string;
title?: string;
type: “ref/prompt”;
}
标识一个 prompt。
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
继承自 BaseMetadata.name
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
继承自 BaseMetadata.title
type: “ref/prompt”
5.5 ResourceTemplateReference #
interface ResourceTemplateReference {
type: “ref/resource”;
uri: string;
}
对资源或资源模板定义的引用。
type: “ref/resource”
uri: string
资源的 URI 或 URI 模板。
8. elicitation/create #
6.1 ElicitRequest #
interface ElicitRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “elicitation/create”;
params: ElicitRequestParams;
}
服务器通过客户端向用户请求额外信息的请求。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “elicitation/create”
params: ElicitRequestParams
6.2 ElicitRequestParams #
ElicitRequestParams: ElicitRequestFormParams | ElicitRequestURLParams
通过客户端向用户请求额外信息的参数。
6.3 ElicitResult #
interface ElicitResult {
_meta?: { $$key: string$$: unknown };
action: “accept” | “decline” | “cancel”;
content?: { $$key: string$$: string | number | boolean | string$$$$ };
$$key: string$$: unknown;
}
客户端对 elicitation 请求的响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
action: “accept” | “decline” | “cancel”
用户对 elicitation 的响应操作。
- “accept”: User submitted the form/confirmed the action
- “decline”: User explicitly decline the action
- “cancel”: User dismissed without making an explicit choice
content?: { $$key: string$$: string | number | boolean | string$$$$ }
提交的表单数据,仅在 action 为 “accept” 且 mode 为 “form” 时存在。包含与请求 schema 匹配的值。带外模式响应中省略。
6.4 BooleanSchema #
interface BooleanSchema {
type: “boolean”;
title?: string;
description?: string;
default?: boolean;
}
type: “boolean”
title?: string
description?: string
default?: boolean
6.5 ElicitRequestFormParams #
interface ElicitRequestFormParams {
task?: TaskMetadata;
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
mode?: “form”;
message: string;
requestedSchema: {
$schema?: string;
type: “object”;
properties: { $$key: string$$: PrimitiveSchemaDefinition };
required?: string$$$$;
};
}
通过客户端表单向用户请求非敏感信息的参数。
task?: TaskMetadata
若指定,调用方请求此请求的任务增强执行。请求将立即返回 CreateTaskResult,实际结果可稍后通过 tasks/result 获取。
任务增强需经能力协商——接收方必须在其能力中声明对特定请求类型的任务增强支持。
继承自 TaskAugmentedRequestParams.task
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 TaskAugmentedRequestParams._meta
mode?: “form”
elicitation 模式。
message: string
向用户展示的消息,描述正在请求的信息。
requestedSchema: { $schema?: string; type: “object”; properties: { $$key: string$$: PrimitiveSchemaDefinition }; required?: string$$$$; }
JSON Schema 的受限子集,仅允许顶层属性,无嵌套。
6.6 ElicitRequestURLParams #
interface ElicitRequestURLParams {
task?: TaskMetadata;
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
mode: “url”;
message: string;
elicitationId: string;
url: string;
}
通过客户端 URL 向用户请求信息的参数。
task?: TaskMetadata
若指定,调用方请求此请求的任务增强执行。请求将立即返回 CreateTaskResult,实际结果可稍后通过 tasks/result 获取。
任务增强需经能力协商——接收方必须在其能力中声明对特定请求类型的任务增强支持。
继承自 TaskAugmentedRequestParams.task
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 TaskAugmentedRequestParams._meta
mode: “url”
elicitation 模式。
message: string
向用户展示的消息,解释为何需要此交互。
elicitationId: string
elicitation 的 ID,在服务器上下文中必须唯一。客户端必须将此 ID 视为不透明值。
url: string
用户应导航到的 URL。
6.7 EnumSchema #
EnumSchema:
| SingleSelectEnumSchema
| MultiSelectEnumSchema
| LegacyTitledEnumSchema
6.8 LegacyTitledEnumSchema #
interface LegacyTitledEnumSchema {
type: “string”;
title?: string;
description?: string;
enum: string$$$$;
enumNames?: string$$$$;
default?: string;
}
请改用 TitledSingleSelectEnumSchema。此接口将在未来版本中移除。
type: “string”
title?: string
description?: string
enum: string$$$$
enumNames?: string$$$$
(Legacy) Display names for enum values. Non-standard according to JSON schema 2020-12.
default?: string
6.9 MultiSelectEnumSchema #
MultiSelectEnumSchema:
| UntitledMultiSelectEnumSchema
| TitledMultiSelectEnumSchema
6.10 NumberSchema #
interface NumberSchema {
type: “number” | “integer”;
title?: string;
description?: string;
minimum?: number;
maximum?: number;
default?: number;
}
type: “number” | “integer”
title?: string
description?: string
minimum?: number
maximum?: number
default?: number
6.11 PrimitiveSchemaDefinition #
PrimitiveSchemaDefinition:
| StringSchema
| NumberSchema
| BooleanSchema
| EnumSchema
仅允许无嵌套对象或数组的原始类型的受限 schema 定义。
6.12 SingleSelectEnumSchema #
SingleSelectEnumSchema:
| UntitledSingleSelectEnumSchema
| TitledSingleSelectEnumSchema
6.13 StringSchema #
interface StringSchema {
type: “string”;
title?: string;
description?: string;
minLength?: number;
maxLength?: number;
format?: “uri” | “email” | “date” | “date-time”;
default?: string;
}
type: “string”
title?: string
description?: string
minLength?: number
maxLength?: number
format?: “uri” | “email” | “date” | “date-time”
default?: string
6.14 TitledMultiSelectEnumSchema #
interface TitledMultiSelectEnumSchema {
type: “array”;
title?: string;
description?: string;
minItems?: number;
maxItems?: number;
items: { anyOf: { const: string; title: string }$$$$ };
default?: string$$$$;
}
带每个选项显示标题的多选枚举 schema。
type: “array”
title?: string
枚举字段的可选标题。
description?: string
枚举字段的可选描述。
minItems?: number
最少选择的项目数。
maxItems?: number
最多选择的项目数。
items: { anyOf: { const: string; title: string }$$$$ }
带枚举选项和显示标签的数组项模式。
类型声明
anyOf: { const: string; title: string }$$$$
带值和显示标签的枚举选项数组。
default?: string$$$$
可选默认值。
6.15 TitledSingleSelectEnumSchema #
interface TitledSingleSelectEnumSchema {
type: “string”;
title?: string;
description?: string;
oneOf: { const: string; title: string }$$$$;
default?: string;
}
带每个选项显示标题的单选枚举 schema。
type: “string”
title?: string
枚举字段的可选标题。
description?: string
枚举字段的可选描述。
oneOf: { const: string; title: string }$$$$
带值和显示标签的枚举选项数组。
类型声明
const: string
The enum value.
title: string
Display label for this option.
default?: string
可选默认值。
6.16 UntitledMultiSelectEnumSchema #
interface UntitledMultiSelectEnumSchema {
type: “array”;
title?: string;
description?: string;
minItems?: number;
maxItems?: number;
items: { type: “string”; enum: string$$$$ };
default?: string$$$$;
}
无选项显示标题的多选枚举 schema。
type: “array”
title?: string
枚举字段的可选标题。
description?: string
枚举字段的可选描述。
minItems?: number
最少选择的项目数。
maxItems?: number
最多选择的项目数。
items: { type: “string”; enum: string$$$$ }
数组项的模式。
类型声明
type: “string”
enum: string$$$$
可供选择的枚举值数组。
default?: string$$$$
可选默认值。
6.17 UntitledSingleSelectEnumSchema #
interface UntitledSingleSelectEnumSchema {
type: “string”;
title?: string;
description?: string;
enum: string$$$$;
default?: string;
}
无选项显示标题的单选枚举 schema。
type: “string”
title?: string
枚举字段的可选标题。
description?: string
枚举字段的可选描述。
enum: string$$$$
可供选择的枚举值数组。
default?: string
可选默认值。
9. initialize #
7.1 InitializeRequest #
interface InitializeRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “initialize”;
params: InitializeRequestParams;
}
客户端首次连接时向服务器发送此请求,请求其开始初始化。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “initialize”
params: InitializeRequestParams
7.2 InitializeRequestParams #
interface InitializeRequestParams {
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
protocolVersion: string;
capabilities: ClientCapabilities;
clientInfo: Implementation;
}
initialize 请求的参数。
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 RequestParams._meta
protocolVersion: string
客户端支持的 Model Context Protocol 最新版本。客户端也可选择支持旧版本。
capabilities: ClientCapabilities
clientInfo: Implementation
7.3 InitializeResult #
interface InitializeResult {
_meta?: { $$key: string$$: unknown };
protocolVersion: string;
capabilities: ServerCapabilities;
serverInfo: Implementation;
instructions?: string;
$$key: string$$: unknown;
}
收到客户端的 initialize 请求后,服务器发送此响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
protocolVersion: string
服务器希望使用的 Model Context Protocol 版本。可能与客户端请求的版本不一致。若客户端无法支持此版本,必须断开连接。
capabilities: ServerCapabilities
serverInfo: Implementation
instructions?: string
描述如何使用服务器及其功能的说明。
客户端可使用此字段提升 LLM 对可用工具、资源等的理解。可将其视为对模型的“提示”。例如,此信息可添加到系统 prompt 中。
7.4 ClientCapabilities #
interface ClientCapabilities {
experimental?: { $$key: string$$: object };
roots?: { listChanged?: boolean };
sampling?: { context?: object; tools?: object };
elicitation?: { form?: object; url?: object };
tasks?: {
list?: object;
cancel?: object;
requests?: {
sampling?: { createMessage?: object };
elicitation?: { create?: object };
};
};
}
客户端可能支持的能力。已知能力在此 schema 中定义,但非封闭集合:任何客户端均可定义自己的附加能力。
experimental?: { $$key: string$$: object }
客户端支持的实验性、非标准能力。
roots?: { listChanged?: boolean }
若客户端支持列出根则存在。
类型声明
OptionallistChanged?: booleanWhether the client supports notifications for changes to the roots list.
sampling?: { context?: object; tools?: object }
若客户端支持从 LLM 采样则存在。
类型声明
Optionalcontext?: objectWhether the client supports context inclusion via includeContext parameter. If not declared, servers SHOULD only use
includeContext: “none”(or omit it).Optionaltools?: objectWhether the client supports tool use via tools and toolChoice parameters.
elicitation?: { form?: object; url?: object }
若客户端支持来自服务器的 elicitation 则存在。
tasks?: { list?: object; cancel?: object; requests?: { sampling?: { createMessage?: object }; elicitation?: { create?: object }; }; }
若客户端支持任务增强请求则存在。
类型声明
Optionallist?: objectWhether this client supports tasks/list.
Optionalcancel?: objectWhether this client supports tasks/cancel.
Optionalrequests?: { sampling?: { createMessage?: object }; elicitation?: { create?: object } }Specifies which request types can be augmented with tasks.
Optionalsampling?: { createMessage?: object }Task support for sampling-related requests.
OptionalcreateMessage?: objectWhether the client supports task-augmented sampling/createMessage requests.
Optionalelicitation?: { create?: object }Task support for elicitation-related requests.
Optionalcreate?: objectWhether the client supports task-augmented elicitation/create requests.
7.5 Implementation #
interface Implementation {
icons?: Icon$$$$;
name: string;
title?: string;
version: string;
description?: string;
websiteUrl?: string;
}
描述 MCP 实现。
icons?: Icon$$$$
客户端可在用户界面中显示的可选尺寸图标集。
支持渲染图标的客户端必须至少支持以下 MIME 类型:
image/png- PNG 图像(安全、通用兼容)image/jpeg(及image/jpg)- JPEG 图像(安全、通用兼容)
支持渲染图标的客户端还应支持:
image/svg+xml- SVG 图像(可缩放,需注意安全)image/webp- WebP 图像(现代、高效格式)
继承自 Icons.icons
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
继承自 BaseMetadata.name
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
继承自 BaseMetadata.title
version: string
description?: string
此实现功能的可选人类可读描述。
客户端或服务器可使用此字段提供其用途和能力的上下文。例如,服务器可描述其提供的资源或工具类型,客户端可描述其预期用例。
websiteUrl?: string
此实现网站的可选 URL。
7.6 ServerCapabilities #
interface ServerCapabilities {
experimental?: { $$key: string$$: object };
logging?: object;
completions?: object;
prompts?: { listChanged?: boolean };
resources?: { subscribe?: boolean; listChanged?: boolean };
tools?: { listChanged?: boolean };
tasks?: {
list?: object;
cancel?: object;
requests?: { tools?: { call?: object } };
};
}
服务器可能支持的能力。已知能力在此 schema 中定义,但非封闭集合:任何服务器均可定义自己的附加能力。
experimental?: { $$key: string$$: object }
服务端支持的实验性、非标准能力。
logging?: object
若服务器支持向客户端发送日志消息则存在。
completions?: object
若服务器支持参数自动补全建议则存在。
prompts?: { listChanged?: boolean }
若服务端提供任何提示模板则存在。
类型声明
OptionallistChanged?: booleanWhether this server supports notifications for changes to the prompt list.
resources?: { subscribe?: boolean; listChanged?: boolean }
若服务端提供任何可读资源则存在。
类型声明
Optionalsubscribe?: booleanWhether this server supports subscribing to resource updates.
OptionallistChanged?: booleanWhether this server supports notifications for changes to the resource list.
tools?: { listChanged?: boolean }
若服务端提供任何可调用工具则存在。
类型声明
OptionallistChanged?: booleanWhether this server supports notifications for changes to the tool list.
tasks?: { list?: object; cancel?: object; requests?: { tools?: { call?: object } }; }
若服务端支持任务增强请求则存在。
类型声明
Optionallist?: objectWhether this server supports tasks/list.
Optionalcancel?: objectWhether this server supports tasks/cancel.
Optionalrequests?: { tools?: { call?: object } }Specifies which request types can be augmented with tasks.
Optionaltools?: { call?: object }Task support for tool-related requests.
Optionalcall?: objectWhether the server supports task-augmented tools/call requests.
10. logging/setLevel #
8.1 SetLevelRequest #
interface SetLevelRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “logging/setLevel”;
params: SetLevelRequestParams;
}
A request from the client to the server, to enable or adjust logging.
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “logging/setLevel”
params: SetLevelRequestParams
8.2 SetLevelRequestParams #
interface SetLevelRequestParams {
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
level: LoggingLevel;
}
logging/setLevel 请求的参数。
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 RequestParams._meta
level: LoggingLevel
客户端希望从服务器接收的日志级别。服务器应将此级别及更高级别(即更严重)的所有日志作为 notifications/message 发送给客户端。
11. notifications/cancelled #
9.1 CancelledNotification #
interface CancelledNotification {
jsonrpc: “2.0”;
method: “notifications/cancelled”;
params: CancelledNotificationParams;
}
任一方均可发送此通知以表示正在取消先前发出的请求。
请求通常仍应在进行中,但由于通信延迟,此通知可能在请求已完成后才到达。
此通知表示结果将不被使用,因此任何相关处理应停止。
A client MUST NOT attempt to cancel its initialize request.
任务取消请使用 tasks/cancel 请求而非此通知。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/cancelled”
Overrides JSONRPCNotification.method
params: CancelledNotificationParams
Overrides JSONRPCNotification.params
9.2 CancelledNotificationParams #
interface CancelledNotificationParams {
_meta?: { $$key: string$$: unknown };
requestId?: RequestId;
reason?: string;
}
notifications/cancelled 通知的参数。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 NotificationParams._meta
requestId?: RequestId
要取消的请求的 ID。
必须与先前在同一方向发出的请求的 ID 对应。取消非任务请求时必须提供。不得用于取消任务(请改用 tasks/cancel 请求)。
reason?: string
描述取消原因的可选字符串。可记录或呈现给用户。
12. notifications/initialized #
10.1 InitializedNotification #
interface InitializedNotification {
jsonrpc: “2.0”;
method: “notifications/initialized”;
params?: NotificationParams;
}
此通知在初始化完成后从客户端发送到服务端。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/initialized”
Overrides JSONRPCNotification.method
params?: NotificationParams
Overrides JSONRPCNotification.params
13. notifications/tasks/status #
11.1 TaskStatusNotification #
interface TaskStatusNotification {
jsonrpc: “2.0”;
method: “notifications/tasks/status”;
params: TaskStatusNotificationParams;
}
接收方向请求方发送的可选通知,告知任务状态已变更。接收方无义务发送这些通知。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/tasks/status”
Overrides JSONRPCNotification.method
params: TaskStatusNotificationParams
Overrides JSONRPCNotification.params
11.2 TaskStatusNotificationParams #
TaskStatusNotificationParams: NotificationParams & Task
notifications/tasks/status 通知的参数。
14. notifications/message #
12.1 LoggingMessageNotification #
interface LoggingMessageNotification {
jsonrpc: “2.0”;
method: “notifications/message”;
params: LoggingMessageNotificationParams;
}
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.
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/message”
Overrides JSONRPCNotification.method
params: LoggingMessageNotificationParams
Overrides JSONRPCNotification.params
12.2 LoggingMessageNotificationParams #
interface LoggingMessageNotificationParams {
_meta?: { $$key: string$$: unknown };
level: LoggingLevel;
logger?: string;
data: unknown;
}
notifications/message 通知的参数。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 NotificationParams._meta
level: LoggingLevel
此日志消息的严重程度。
logger?: string
发出此消息的记录器的可选名称。
data: unknown
要记录的数据,如字符串消息或对象。此处允许任何可 JSON 序列化的类型。
15. notifications/progress #
13.1 ProgressNotification #
interface ProgressNotification {
jsonrpc: “2.0”;
method: “notifications/progress”;
params: ProgressNotificationParams;
}
用于通知接收方长时间运行请求进度更新的带外通知。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/progress”
Overrides JSONRPCNotification.method
params: ProgressNotificationParams
Overrides JSONRPCNotification.params
13.2 ProgressNotificationParams #
interface ProgressNotificationParams {
_meta?: { $$key: string$$: unknown };
progressToken: ProgressToken;
progress: number;
total?: number;
message?: string;
}
notifications/progress 通知的参数。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 NotificationParams._meta
progressToken: ProgressToken
初始请求中给出的进度令牌,用于将此通知与正在进行的请求关联。
progress: number
迄今为止的进度。每次取得进展时应增加,即使总数未知。
total?: number
要处理的项总数(或所需的总进度),如已知。
message?: string
描述当前进度的可选消息。
16. notifications/prompts/list_changed #
14.1 PromptListChangedNotification #
interface PromptListChangedNotification {
jsonrpc: “2.0”;
method: “notifications/prompts/list_changed”;
params?: NotificationParams;
}
服务端向客户端的可选通知,告知其提供的提示列表已更改。服务端可在客户端未事先订阅的情况下发出。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/prompts/list_changed”
Overrides JSONRPCNotification.method
params?: NotificationParams
Overrides JSONRPCNotification.params
17. notifications/resources/list_changed #
15.1 ResourceListChangedNotification #
interface ResourceListChangedNotification {
jsonrpc: “2.0”;
method: “notifications/resources/list_changed”;
params?: NotificationParams;
}
服务端向客户端的可选通知,告知其可读取的资源列表已更改。服务端可在客户端未事先订阅的情况下发出。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/resources/list_changed”
Overrides JSONRPCNotification.method
params?: NotificationParams
Overrides JSONRPCNotification.params
18. notifications/resources/updated #
16.1 ResourceUpdatedNotification #
interface ResourceUpdatedNotification {
jsonrpc: “2.0”;
method: “notifications/resources/updated”;
params: ResourceUpdatedNotificationParams;
}
A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/resources/updated”
Overrides JSONRPCNotification.method
params: ResourceUpdatedNotificationParams
Overrides JSONRPCNotification.params
16.2 ResourceUpdatedNotificationParams #
interface ResourceUpdatedNotificationParams {
_meta?: { $$key: string$$: unknown };
uri: string;
}
notifications/resources/updated 通知的参数。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 NotificationParams._meta
uri: string
已更新资源的 URI。可能是客户端实际订阅资源的子资源。
19. notifications/roots/list_changed #
17.1 RootsListChangedNotification #
interface RootsListChangedNotification {
jsonrpc: “2.0”;
method: “notifications/roots/list_changed”;
params?: NotificationParams;
}
A notification from the client to the server, informing it that the list of roots has changed. This notification should be sent whenever the client adds, removes, or modifies any root. The server should then request an updated list of roots using the ListRootsRequest.
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/roots/list_changed”
Overrides JSONRPCNotification.method
params?: NotificationParams
Overrides JSONRPCNotification.params
20. notifications/tools/list_changed #
18.1 ToolListChangedNotification #
interface ToolListChangedNotification {
jsonrpc: “2.0”;
method: “notifications/tools/list_changed”;
params?: NotificationParams;
}
服务端向客户端的可选通知,告知其提供的工具列表已更改。服务端可在客户端未事先订阅的情况下发出。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/tools/list_changed”
Overrides JSONRPCNotification.method
params?: NotificationParams
Overrides JSONRPCNotification.params
21. notifications/elicitation/complete #
19.1 ElicitationCompleteNotification #
interface ElicitationCompleteNotification {
jsonrpc: “2.0”;
method: “notifications/elicitation/complete”;
params: { elicitationId: string };
}
服务端向客户端的可选通知,告知带外引导请求已完成。
jsonrpc: “2.0”
继承自 JSONRPCNotification.jsonrpc
method: “notifications/elicitation/complete”
Overrides JSONRPCNotification.method
params: { elicitationId: string }
类型声明
elicitationId: string
The ID of the elicitation that completed.
Overrides JSONRPCNotification.params
22. ping #
20.1 PingRequest #
interface PingRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “ping”;
params?: RequestParams;
}
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.
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “ping”
params?: RequestParams
tasks
20.2 CreateTaskResult #
interface CreateTaskResult {
_meta?: { $$key: string$$: unknown };
task: Task;
$$key: string$$: unknown;
}
A response to a task-augmented request.
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
task: Task
20.3 RelatedTaskMetadata #
interface RelatedTaskMetadata {
taskId: string;
}
用于将消息与任务关联的元数据。将其包含在 _meta 字段的 io.modelcontextprotocol/related-task 键下。
taskId: string
此消息关联的任务标识符。
20.4 Task #
interface Task {
taskId: string;
status: TaskStatus;
statusMessage?: string;
createdAt: string;
lastUpdatedAt: string;
ttl: number | null;
pollInterval?: number;
}
与任务关联的数据。
taskId: string
任务标识符。
status: TaskStatus
当前任务状态。
statusMessage?: string
描述当前任务状态的可选人类可读消息。可为任何状态提供上下文,包括:
- Reasons for “cancelled” status
- Summaries for “completed” status
- Diagnostic information for “failed” status (如 error details, what went wrong)
createdAt: string
ISO 8601 timestamp when the task was created.
lastUpdatedAt: string
ISO 8601 timestamp when the task was last updated.
ttl: number | null
自创建起的实际保留时长(毫秒),null 表示无限制。
pollInterval?: number
建议的轮询间隔(毫秒)。
20.5 TaskMetadata #
interface TaskMetadata {
ttl?: number;
}
用于以任务执行增强请求的元数据。将其包含在请求参数的 task 字段中。
ttl?: number
自创建起保留任务的请求时长(毫秒)。
20.6 TaskStatus #
TaskStatus: “working” | “input_required” | “completed” | “failed” | “cancelled”
任务的状态。
23. tasks/get #
21.1 GetTaskRequest #
interface GetTaskRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “tasks/get”;
params: { taskId: string };
}
A request to retrieve the state of a task.
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “tasks/get”
params: { taskId: string }
类型声明
taskId: string
The task identifier to query.
21.2 GetTaskResult #
tasks/get 请求的响应。
24. tasks/result #
22.1 GetTaskPayloadRequest #
interface GetTaskPayloadRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “tasks/result”;
params: { taskId: string };
}
A request to retrieve the result of a completed task.
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “tasks/result”
params: { taskId: string }
类型声明
taskId: string
The task identifier to retrieve results for.
22.2 GetTaskPayloadResult #
interface GetTaskPayloadResult {
_meta?: { $$key: string$$: unknown };
$$key: string$$: unknown;
}
tasks/result 请求的响应。结构与原始请求的结果类型匹配。例如,tools/call 任务将返回 CallToolResult 结构。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
25. tasks/list #
23.1 ListTasksRequest #
interface ListTasksRequest {
jsonrpc: “2.0”;
id: RequestId;
params?: PaginatedRequestParams;
method: “tasks/list”;
}
A request to retrieve a list of tasks.
jsonrpc: “2.0”
继承自 PaginatedRequest.jsonrpc
id: RequestId
继承自 PaginatedRequest.id
params?: PaginatedRequestParams
继承自 PaginatedRequest.params
method: “tasks/list”
Overrides PaginatedRequest.method
23.2 ListTasksResult #
interface ListTasksResult {
_meta?: { $$key: string$$: unknown };
nextCursor?: string;
tasks: Task$$$$;
$$key: string$$: unknown;
}
tasks/list 请求的响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 PaginatedResult._meta
nextCursor?: string
表示最后一个返回结果之后分页位置的不透明令牌。若存在,则可能有更多结果可用。
继承自 PaginatedResult.nextCursor
tasks: Task$$$$
26. tasks/cancel #
24.1 CancelTaskRequest #
interface CancelTaskRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “tasks/cancel”;
params: { taskId: string };
}
A request to cancel a task.
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “tasks/cancel”
params: { taskId: string }
类型声明
taskId: string
The task identifier to cancel.
24.2 CancelTaskResult #
CancelTaskResult: Result & Task
tasks/cancel 请求的响应。
27. prompts/get #
25.1 GetPromptRequest #
interface GetPromptRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “prompts/get”;
params: GetPromptRequestParams;
}
客户端用于获取服务端提供的提示。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “prompts/get”
params: GetPromptRequestParams
25.2 GetPromptRequestParams #
interface GetPromptRequestParams {
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
name: string;
arguments?: { $$key: string$$: string };
}
prompts/get 请求的参数。
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 RequestParams._meta
name: string
提示或提示模板的名称。
arguments?: { $$key: string$$: string }
用于提示模板化的参数。
25.3 GetPromptResult #
interface GetPromptResult {
_meta?: { $$key: string$$: unknown };
description?: string;
messages: PromptMessage$$$$;
$$key: string$$: unknown;
}
服务端对客户端 prompts/get 请求的响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
description?: string
提示的可选描述。
messages: PromptMessage$$$$
25.4 PromptMessage #
interface PromptMessage {
role: Role;
content: ContentBlock;
}
描述作为提示一部分返回的消息。
与 SamplingMessage 类似,但还支持嵌入 MCP 服务端的资源。
role: Role
content: ContentBlock
28. prompts/list #
26.1 ListPromptsRequest #
interface ListPromptsRequest {
jsonrpc: “2.0”;
id: RequestId;
params?: PaginatedRequestParams;
method: “prompts/list”;
}
从客户端发送以请求服务端拥有的提示和提示模板列表。
jsonrpc: “2.0”
继承自 PaginatedRequest.jsonrpc
id: RequestId
继承自 PaginatedRequest.id
params?: PaginatedRequestParams
继承自 PaginatedRequest.params
method: “prompts/list”
Overrides PaginatedRequest.method
26.2 ListPromptsResult #
interface ListPromptsResult {
_meta?: { $$key: string$$: unknown };
nextCursor?: string;
prompts: Prompt$$$$;
$$key: string$$: unknown;
}
服务端对客户端 prompts/list 请求的响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 PaginatedResult._meta
nextCursor?: string
表示最后一个返回结果之后分页位置的不透明令牌。若存在,则可能有更多结果可用。
继承自 PaginatedResult.nextCursor
prompts: Prompt$$$$
26.3 Prompt #
interface Prompt {
icons?: Icon$$$$;
name: string;
title?: string;
description?: string;
arguments?: PromptArgument$$$$;
_meta?: { $$key: string$$: unknown };
}
A prompt or prompt template that the server offers.
icons?: Icon$$$$
客户端可在用户界面中显示的可选尺寸图标集。
支持渲染图标的客户端必须至少支持以下 MIME 类型:
image/png- PNG 图像(安全、通用兼容)image/jpeg(及image/jpg)- JPEG 图像(安全、通用兼容)
支持渲染图标的客户端还应支持:
image/svg+xml- SVG 图像(可缩放,需注意安全)image/webp- WebP 图像(现代、高效格式)
继承自 Icons.icons
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
继承自 BaseMetadata.name
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
继承自 BaseMetadata.title
description?: string
描述此提示所提供内容的可选描述
arguments?: PromptArgument$$$$
A list of arguments to use for templating the prompt.
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
26.4 PromptArgument #
interface PromptArgument {
name: string;
title?: string;
description?: string;
required?: boolean;
}
描述提示可接受的参数。
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
继承自 BaseMetadata.name
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
继承自 BaseMetadata.title
description?: string
A human-readable description of the argument.
required?: boolean
此参数是否必须提供。
29. resources/list #
27.1 ListResourcesRequest #
interface ListResourcesRequest {
jsonrpc: “2.0”;
id: RequestId;
params?: PaginatedRequestParams;
method: “resources/list”;
}
从客户端发送以请求服务端拥有的资源列表。
jsonrpc: “2.0”
继承自 PaginatedRequest.jsonrpc
id: RequestId
继承自 PaginatedRequest.id
params?: PaginatedRequestParams
继承自 PaginatedRequest.params
method: “resources/list”
Overrides PaginatedRequest.method
27.2 ListResourcesResult #
interface ListResourcesResult {
_meta?: { $$key: string$$: unknown };
nextCursor?: string;
resources: Resource$$$$;
$$key: string$$: unknown;
}
服务端对客户端 resources/list 请求的响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 PaginatedResult._meta
nextCursor?: string
表示最后一个返回结果之后分页位置的不透明令牌。若存在,则可能有更多结果可用。
继承自 PaginatedResult.nextCursor
resources: Resource$$$$
27.3 Resource #
interface Resource {
icons?: Icon$$$$;
name: string;
title?: string;
uri: string;
description?: string;
mimeType?: string;
annotations?: Annotations;
size?: number;
_meta?: { $$key: string$$: unknown };
}
A known resource that the server is capable of reading.
icons?: Icon$$$$
客户端可在用户界面中显示的可选尺寸图标集。
支持渲染图标的客户端必须至少支持以下 MIME 类型:
image/png- PNG 图像(安全、通用兼容)image/jpeg(及image/jpg)- JPEG 图像(安全、通用兼容)
支持渲染图标的客户端还应支持:
image/svg+xml- SVG 图像(可缩放,需注意安全)image/webp- WebP 图像(现代、高效格式)
继承自 Icons.icons
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
继承自 BaseMetadata.name
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
继承自 BaseMetadata.title
uri: string
此资源的 URI。
description?: string
描述此资源所表示的内容。
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.
mimeType?: string
此资源的 MIME 类型(如已知)。
annotations?: Annotations
客户端的可选注解。
size?: number
原始资源内容的字节大小(即 base64 编码或任何分词之前),如已知。
主机可用于显示文件大小并估算上下文窗口使用量。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
30. resources/read #
28.1 ReadResourceRequest #
interface ReadResourceRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “resources/read”;
params: ReadResourceRequestParams;
}
从客户端发送到服务端,以读取特定资源 URI。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “resources/read”
params: ReadResourceRequestParams
28.2 ReadResourceRequestParams #
interface ReadResourceRequestParams {
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
uri: string;
}
resources/read 请求的参数。
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 ResourceRequestParams._meta
uri: string
The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
继承自 ResourceRequestParams.uri
28.3 ReadResourceResult #
interface ReadResourceResult {
_meta?: { $$key: string$$: unknown };
contents: (TextResourceContents | BlobResourceContents)$$$$;
$$key: string$$: unknown;
}
服务端对客户端 resources/read 请求的响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
contents: (TextResourceContents | BlobResourceContents)$$$$
31. resources/subscribe #
29.1 SubscribeRequest #
interface SubscribeRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “resources/subscribe”;
params: SubscribeRequestParams;
}
从客户端发送以在特定资源更改时向服务端请求 resources/updated 通知。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “resources/subscribe”
params: SubscribeRequestParams
29.2 SubscribeRequestParams #
interface SubscribeRequestParams {
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
uri: string;
}
resources/subscribe 请求的参数。
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 ResourceRequestParams._meta
uri: string
The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
继承自 ResourceRequestParams.uri
32. resources/templates/list #
30.1 ListResourceTemplatesRequest #
interface ListResourceTemplatesRequest {
jsonrpc: “2.0”;
id: RequestId;
params?: PaginatedRequestParams;
method: “resources/templates/list”;
}
从客户端发送以请求服务端拥有的资源模板列表。
jsonrpc: “2.0”
继承自 PaginatedRequest.jsonrpc
id: RequestId
继承自 PaginatedRequest.id
params?: PaginatedRequestParams
继承自 PaginatedRequest.params
method: “resources/templates/list”
Overrides PaginatedRequest.method
30.2 ListResourceTemplatesResult #
interface ListResourceTemplatesResult {
_meta?: { $$key: string$$: unknown };
nextCursor?: string;
resourceTemplates: ResourceTemplate$$$$;
$$key: string$$: unknown;
}
服务端对客户端 resources/templates/list 请求的响应。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 PaginatedResult._meta
nextCursor?: string
表示最后一个返回结果之后分页位置的不透明令牌。若存在,则可能有更多结果可用。
继承自 PaginatedResult.nextCursor
resourceTemplates: ResourceTemplate$$$$
30.3 ResourceTemplate #
interface ResourceTemplate {
icons?: Icon$$$$;
name: string;
title?: string;
uriTemplate: string;
description?: string;
mimeType?: string;
annotations?: Annotations;
_meta?: { $$key: string$$: unknown };
}
A template description for resources available on the server.
icons?: Icon$$$$
客户端可在用户界面中显示的可选尺寸图标集。
支持渲染图标的客户端必须至少支持以下 MIME 类型:
image/png- PNG 图像(安全、通用兼容)image/jpeg(及image/jpg)- JPEG 图像(安全、通用兼容)
支持渲染图标的客户端还应支持:
image/svg+xml- SVG 图像(可缩放,需注意安全)image/webp- WebP 图像(现代、高效格式)
继承自 Icons.icons
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
继承自 BaseMetadata.name
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
继承自 BaseMetadata.title
uriTemplate: string
A URI template (according to RFC 6570) that can be used to construct resource URIs.
description?: string
A description of what this template is for.
客户端可使用此字段提升 LLM 对可用资源的理解。可将其视为对模型的“提示”。
mimeType?: string
The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
annotations?: Annotations
客户端的可选注解。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
33. resources/unsubscribe #
31.1 UnsubscribeRequest #
interface UnsubscribeRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “resources/unsubscribe”;
params: UnsubscribeRequestParams;
}
从客户端发送以向服务端请求取消 resources/updated 通知。应在先前的 resources/subscribe 请求之后进行。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “resources/unsubscribe”
params: UnsubscribeRequestParams
31.2 UnsubscribeRequestParams #
interface UnsubscribeRequestParams {
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
uri: string;
}
resources/unsubscribe 请求的参数。
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 ResourceRequestParams._meta
uri: string
The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
继承自 ResourceRequestParams.uri
34. roots/list #
32.1 ListRootsRequest #
interface ListRootsRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “roots/list”;
params?: RequestParams;
}
从服务端发送以向客户端请求根 URI 列表。根允许服务端请求要操作的特定目录或文件。根的常见示例是提供服务端应操作的一组仓库或目录。
当服务端需要了解文件系统结构或访问客户端有权限读取的特定位置时,通常使用此请求。
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “roots/list”
params?: RequestParams
32.2 ListRootsResult #
interface ListRootsResult {
_meta?: { $$key: string$$: unknown };
roots: Root$$$$;
$$key: string$$: unknown;
}
客户端对 roots/list 请求的响应。结果包含 Root 对象数组,每个表示服务器可操作的根目录或文件。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
roots: Root$$$$
32.3 Root #
interface Root {
uri: string;
name?: string;
_meta?: { $$key: string$$: unknown };
}
表示服务端可操作的根目录或文件。
uri: string
The URI identifying the root. This must start with file:// for now. This restriction may be relaxed in future versions of the protocol to allow other URI schemes.
name?: string
根的可选名称。可用于为根提供人类可读的标识符,可能有助于显示或在应用其他部分引用根。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
35. sampling/createMessage #
33.1 CreateMessageRequest #
interface CreateMessageRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “sampling/createMessage”;
params: CreateMessageRequestParams;
}
A request from the server to sample an LLM via the client. 客户端 has full discretion over which model to select. 客户端 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.
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “sampling/createMessage”
params: CreateMessageRequestParams
33.2 CreateMessageRequestParams #
interface CreateMessageRequestParams {
task?: TaskMetadata;
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
messages: SamplingMessage$$$$;
modelPreferences?: ModelPreferences;
systemPrompt?: string;
includeContext?: “none” | “thisServer” | “allServers”;
temperature?: number;
maxTokens: number;
stopSequences?: string$$$$;
metadata?: object;
tools?: Tool$$$$;
toolChoice?: ToolChoice;
}
sampling/createMessage 请求的参数。
task?: TaskMetadata
若指定,调用方请求此请求的任务增强执行。请求将立即返回 CreateTaskResult,实际结果可稍后通过 tasks/result 获取。
任务增强需经能力协商——接收方必须在其能力中声明对特定请求类型的任务增强支持。
继承自 TaskAugmentedRequestParams.task
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 TaskAugmentedRequestParams._meta
messages: SamplingMessage$$$$
modelPreferences?: ModelPreferences
The server’s preferences for which model to select. 客户端 MAY ignore these preferences.
systemPrompt?: string
服务端希望用于采样的可选系统提示。客户端可以修改或省略此提示。
includeContext?: “none” | “thisServer” | “allServers”
A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. 客户端 MAY ignore this request.
Default is “none”. Values “thisServer” and “allServers” are soft-deprecated. Servers SHOULD only use these values if the client declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
temperature?: number
maxTokens: number
请求采样的最大 token 数(以防止失控补全)。
客户端可以选择采样少于请求最大值的 token 数。
stopSequences?: string$$$$
metadata?: object
传递给 LLM 提供者的可选元数据。此元数据的格式由提供者特定。
tools?: Tool$$$$
模型在生成期间可能使用的工具。若提供此字段但未声明 ClientCapabilities.sampling.tools,客户端必须返回错误。
toolChoice?: ToolChoice
Controls how the model uses tools. 客户端 MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. Default is { mode: “auto” }.
33.3 CreateMessageResult #
interface CreateMessageResult {
_meta?: { $$key: string$$: unknown };
model: string;
stopReason?: string;
role: Role;
content: SamplingMessageContentBlock | SamplingMessageContentBlock$$$$;
$$key: string$$: unknown;
}
客户端’s response to a sampling/createMessage request from the server. 客户端 should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
model: string
生成消息的模型名称。
stopReason?: string
采样停止的原因,如已知。
标准值:
- “endTurn”: Natural end of the assistant’s turn
- “stopSequence”: A stop sequence was encountered
- “maxTokens”: Maximum token limit was reached
- “toolUse”: The model wants to use one or more tools
此字段为开放字符串,以允许提供者特定的停止原因。
role: Role
继承自 SamplingMessage.role
content: SamplingMessageContentBlock | SamplingMessageContentBlock$$$$
33.4 ModelHint #
interface ModelHint {
name?: string;
}
用于模型选择的提示。
此处未声明的键目前由规范留作未指定,由客户端解释。
name?: string
A hint for a model name.
客户端应将其视为模型名称的子字符串;例如:
claude-3-5-sonnetshould matchclaude-3-5-sonnet-20241022sonnetshould matchclaude-3-5-sonnet-20241022,claude-3-sonnet-20240229, etc.claudeshould match any Claude model
客户端 MAY also map the string to a different provider’s model name or a different model family, as long as it fills a similar niche; for example:
gemini-1.5-flashcould matchclaude-3-haiku-20240307
33.5 ModelPreferences #
interface ModelPreferences {
hints?: ModelHint$$$$;
costPriority?: number;
speedPriority?: number;
intelligencePriority?: number;
}
The server’s preferences for model selection, requested of the client during sampling.
Because LLMs can vary along multiple dimensions, choosing the “best” model is rarely straightforward. Different models excel in different areas—some are faster but less capable, others are more capable but more expensive, and so on. This interface allows servers to express their priorities across multiple dimensions to help clients make an appropriate selection for their use case.
These preferences are always advisory. 客户端 MAY ignore them. It is also up to the client to decide how to interpret these preferences and how to balance them against other considerations.
hints?: ModelHint$$$$
Optional hints to use for model selection.
If multiple hints are specified, the client MUST evaluate them in order (such that the first match is taken).
客户端 SHOULD prioritize these hints over the numeric priorities, but MAY still use the priorities to select from ambiguous matches.
costPriority?: number
How much to prioritize cost when selecting a model. A value of 0 means cost is not important, while a value of 1 means cost is the most important factor.
speedPriority?: number
How much to prioritize sampling speed (latency) when selecting a model. A value of 0 means speed is not important, while a value of 1 means speed is the most important factor.
intelligencePriority?: number
How much to prioritize intelligence and capabilities when selecting a model. A value of 0 means intelligence is not important, while a value of 1 means intelligence is the most important factor.
33.6 SamplingMessage #
interface SamplingMessage {
role: Role;
content: SamplingMessageContentBlock | SamplingMessageContentBlock$$$$;
_meta?: { $$key: string$$: unknown };
}
Describes a message issued to or received from an LLM API.
role: Role
content: SamplingMessageContentBlock | SamplingMessageContentBlock$$$$
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
33.7 SamplingMessageContentBlock #
SamplingMessageContentBlock:
| TextContent
| ImageContent
| AudioContent
| ToolUseContent
| ToolResultContent
33.8 ToolChoice #
interface ToolChoice {
mode?: “none” | “required” | “auto”;
}
Controls tool selection behavior for sampling requests.
mode?: “none” | “required” | “auto”
Controls the tool use ability of the model:
- “auto”: Model decides whether to use tools (default)
- “required”: Model MUST use at least one tool before completing
- “none”: Model MUST NOT use any tools
33.9 ToolResultContent #
interface ToolResultContent {
type: “tool_result”;
toolUseId: string;
content: ContentBlock$$$$;
structuredContent?: { $$key: string$$: unknown };
isError?: boolean;
_meta?: { $$key: string$$: unknown };
}
The result of a tool use, provided by the user back to the assistant.
type: “tool_result”
toolUseId: string
The ID of the tool use this result corresponds to.
This MUST match the ID from a previous ToolUseContent.
content: ContentBlock$$$$
The unstructured result content of the tool use.
This has the same format as CallToolResult.content and can include text, images, audio, resource links, and embedded resources.
structuredContent?: { $$key: string$$: unknown }
An optional structured result object.
If the tool defined an outputSchema, this SHOULD conform to that schema.
isError?: boolean
Whether the tool use resulted in an error.
If true, the content typically describes the error that occurred. Default: false
_meta?: { $$key: string$$: unknown }
Optional metadata about the tool result. Clients SHOULD preserve this field when including tool results in subsequent sampling requests to enable caching optimizations.
有关 _meta 用法的说明,请参阅 通用字段:_meta。
33.10 ToolUseContent #
interface ToolUseContent {
type: “tool_use”;
id: string;
name: string;
input: { $$key: string$$: unknown };
_meta?: { $$key: string$$: unknown };
}
A request from the assistant to call a tool.
type: “tool_use”
id: string
A unique identifier for this tool use.
This ID is used to match tool results to their corresponding tool uses.
name: string
The name of the tool to call.
input: { $$key: string$$: unknown }
The arguments to pass to the tool, conforming to the tool’s input schema.
_meta?: { $$key: string$$: unknown }
Optional metadata about the tool use. Clients SHOULD preserve this field when including tool uses in subsequent sampling requests to enable caching optimizations.
有关 _meta 用法的说明,请参阅 通用字段:_meta。
36. tools/call #
34.1 CallToolRequest #
interface CallToolRequest {
jsonrpc: “2.0”;
id: RequestId;
method: “tools/call”;
params: CallToolRequestParams;
}
Used by the client to invoke a tool provided by the server.
jsonrpc: “2.0”
id: RequestId
继承自 JSONRPCRequest.id
method: “tools/call”
params: CallToolRequestParams
34.2 CallToolRequestParams #
interface CallToolRequestParams {
task?: TaskMetadata;
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown };
name: string;
arguments?: { $$key: string$$: unknown };
}
Parameters for a tools/call request.
task?: TaskMetadata
若指定,调用方请求此请求的任务增强执行。请求将立即返回 CreateTaskResult,实际结果可稍后通过 tasks/result 获取。
任务增强需经能力协商——接收方必须在其能力中声明对特定请求类型的任务增强支持。
继承自 TaskAugmentedRequestParams.task
_meta?: { progressToken?: ProgressToken; $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
类型声明
$$key: string$$: unknown
OptionalprogressToken?: ProgressToken若指定,调用方请求此请求的带外进度通知(通过 notifications/progress)。该值为不透明令牌,将附加到后续通知中。接收方不强制提供此类通知。
继承自 TaskAugmentedRequestParams._meta
name: string
The name of the tool.
arguments?: { $$key: string$$: unknown }
Arguments to use for the tool call.
34.3 CallToolResult #
interface CallToolResult {
_meta?: { $$key: string$$: unknown };
content: ContentBlock$$$$;
structuredContent?: { $$key: string$$: unknown };
isError?: boolean;
$$key: string$$: unknown;
}
The server’s response to a tool call.
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
content: ContentBlock$$$$
表示工具调用非结构化结果的内容对象列表。
structuredContent?: { $$key: string$$: unknown }
可选的 JSON 对象,表示工具调用的结构化结果。
isError?: boolean
Whether the tool call ended in an error.
If not set, this is assumed to be false (the call was successful).
Any errors that originate from the tool SHOULD be reported inside the result object, with isError set to true, not as an MCP protocol-level error response. Otherwise, the LLM would not be able to see that an error occurred and self-correct.
However, any errors in finding the tool, an error indicating that the server does not support tool calls, or any other exceptional conditions, should be reported as an MCP error response.
37. tools/list #
35.1 ListToolsRequest #
interface ListToolsRequest {
jsonrpc: “2.0”;
id: RequestId;
params?: PaginatedRequestParams;
method: “tools/list”;
}
Sent from the client to request a list of tools the server has.
jsonrpc: “2.0”
继承自 PaginatedRequest.jsonrpc
id: RequestId
继承自 PaginatedRequest.id
params?: PaginatedRequestParams
继承自 PaginatedRequest.params
method: “tools/list”
Overrides PaginatedRequest.method
35.2 ListToolsResult #
interface ListToolsResult {
_meta?: { $$key: string$$: unknown };
nextCursor?: string;
tools: Tool$$$$;
$$key: string$$: unknown;
}
The server’s response to a tools/list request from the client.
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
继承自 PaginatedResult._meta
nextCursor?: string
表示最后一个返回结果之后分页位置的不透明令牌。若存在,则可能有更多结果可用。
继承自 PaginatedResult.nextCursor
tools: Tool$$$$
35.3 Tool #
interface Tool {
icons?: Icon$$$$;
name: string;
title?: string;
description?: string;
inputSchema: {
$schema?: string;
type: “object”;
properties?: { $$key: string$$: object };
required?: string$$$$;
};
execution?: ToolExecution;
outputSchema?: {
$schema?: string;
type: “object”;
properties?: { $$key: string$$: object };
required?: string$$$$;
};
annotations?: ToolAnnotations;
_meta?: { $$key: string$$: unknown };
}
客户端可调用的工具定义。
icons?: Icon$$$$
客户端可在用户界面中显示的可选尺寸图标集。
支持渲染图标的客户端必须至少支持以下 MIME 类型:
image/png- PNG 图像(安全、通用兼容)image/jpeg(及image/jpg)- JPEG 图像(安全、通用兼容)
支持渲染图标的客户端还应支持:
image/svg+xml- SVG 图像(可缩放,需注意安全)image/webp- WebP 图像(现代、高效格式)
继承自 Icons.icons
name: string
用于程序或逻辑标识,在旧规范中或当 title 缺失时也可作为显示名。
继承自 BaseMetadata.name
title?: string
用于 UI 和最终用户场景——优化为人类可读且易于理解,即使不熟悉领域术语的人也能理解。
如未提供,应使用 name 进行显示(工具除外,若存在则 annotations.title 应优先于 name)。
继承自 BaseMetadata.title
description?: string
A human-readable description of the tool.
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.
inputSchema: { $schema?: string; type: “object”; properties?: { $$key: string$$: object }; required?: string$$$$; }
A JSON Schema object defining the expected parameters for the tool.
execution?: ToolExecution
与此工具执行相关的属性。
outputSchema?: { $schema?: string; type: “object”; properties?: { $$key: string$$: object }; required?: string$$$$; }
An optional JSON Schema object defining the structure of the tool’s output returned in the structuredContent field of a CallToolResult.
Defaults to JSON Schema 2020-12 when no explicit $schema is provided. Currently restricted to type: “object” at the root level.
annotations?: ToolAnnotations
可选的额外工具信息。
显示名优先级:title > annotations.title > name。
_meta?: { $$key: string$$: unknown }
有关 _meta 用法的说明,请参阅 通用字段:_meta。
35.4 ToolAnnotations #
interface ToolAnnotations {
title?: string;
readOnlyHint?: boolean;
destructiveHint?: boolean;
idempotentHint?: boolean;
openWorldHint?: boolean;
}
向客户端描述工具的附加属性。
注意:ToolAnnotations 中的所有属性均为提示。不保证能忠实描述工具行为(包括 title 等描述性属性)。
客户端绝不应基于从未受信任服务端收到的 ToolAnnotations 做出工具使用决策。
title?: string
工具的人类可读标题。
readOnlyHint?: boolean
若为 true,表示工具不修改其环境。
默认:false
destructiveHint?: boolean
若为 true,表示工具可能对其环境执行破坏性更新。若为 false,表示工具仅执行增量更新。
(此属性仅在 readOnlyHint == false 时有意义)
默认:true
idempotentHint?: boolean
若为 true,表示使用相同参数重复调用工具不会对其环境产生额外影响。
(此属性仅在 readOnlyHint == false 时有意义)
默认:false
openWorldHint?: boolean
若为 true,表示此工具可能与外部实体的「开放世界」交互。若为 false,表示工具的交互域是封闭的。例如,网络搜索工具的世界是开放的,而记忆工具的世界则不是。
默认:true
35.5 ToolExecution #
interface ToolExecution {
taskSupport?: “forbidden” | “optional” | “required”;
}
与工具执行相关的属性。
taskSupport?: “forbidden” | “optional” | “required”
表示此工具是否支持任务增强执行。这允许客户端通过轮询任务系统处理长时间运行的操作。
- “forbidden”: 工具不支持任务增强执行(缺失时默认)
- “optional”: 工具可能支持任务增强执行
- “required”: 工具需要任务增强执行
默认:"forbidden"