Documentation Index
Fetch the complete documentation index at: https://mcp.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
server/discover 允许客户端在发送任何其他请求之前,查询服务器支持的协议版本、
能力和标识。服务器 必须 实现它。
请求
除标准_meta 外,请求不携带任何主体参数:
响应
服务器将返回其支持的协议版本、能力和 标识:响应字段
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
supportedVersions | string[] | 是 | 服务器支持的协议版本。客户端应为后续请求选择其中一个。 |
capabilities | ServerCapabilities | 是 | 服务器支持的能力(工具、资源、提示等)。 |
serverInfo | Implementation | 是 | 服务器软件的名称和版本。 |
instructions | string | 否 | 用自然语言为 LLM 提供如何有效使用该服务器的指导。 |
何时调用
对于客户端来说,调用server/discover 是可选的——客户端可以内联发起任何
RPC,并在服务器不支持请求的版本时处理
UnsupportedProtocolVersionError。
不过,server/discover
在以下两种场景中很有用:
- 提前进行版本选择。 客户端在发送任何其他请求之前先了解服务器支持的 版本,从而避免一次往返错误。
- STDIO 向后兼容探测。 在 stdio 上,没有逐请求的
HTTP 状态码来驱动回退。支持现代(逐请求
_meta)和旧版 (initialize握手)服务器的客户端 应该 先发送server/discover。如果服务器返回Method not found(-32601),客户端回退到initialize握手。