> ## 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.

# 发现

<div id="enable-section-numbers" />

`server/discover` 允许客户端在发送任何其他请求之前，查询服务器支持的协议版本、
能力和标识。服务器 **必须** 实现它。

## 请求

除标准 `_meta` 外，请求不携带任何主体参数：

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "discover-1",
  "method": "server/discover",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": {
        "name": "ExampleClient",
        "version": "1.0.0"
      },
      "io.modelcontextprotocol/clientCapabilities": {}
    }
  }
}
```

## 响应

服务器会返回其支持的协议版本、能力和
标识。此操作支持 [缓存](/specification/draft/server/utilities/caching)。

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "discover-1",
  "result": {
    "resultType": "complete",
    "supportedVersions": ["2026-07-28"],
    "capabilities": {
      "tools": {},
      "resources": {}
    },
    "serverInfo": {
      "name": "ExampleServer",
      "version": "1.0.0"
    },
    "instructions": "该服务器提供天气和资源工具。",
    "ttlMs": 3600000,
    "cacheScope": "public"
  }
}
```

## 何时调用

对于客户端来说，调用 `server/discover` 是可选的——客户端可以内联发起任何
RPC，并在服务器不支持请求的版本时处理
[`UnsupportedProtocolVersionError`](/specification/draft/schema#unsupportedprotocolversionerror)。
不过，`server/discover`
在以下两种场景中很有用：

* **展示服务器信息。** 虽然客户端不需要调用
  `server/discover` 就能使用服务器，但它是一次性获取
  服务器标识、能力和支持版本的便捷方式。例如，客户端可以根据
  单个 `server/discover` 响应展示服务器支持的能力，而不必分别通过
  `tools/list`、`prompts/list` 和 `resources/list` 请求进行探测。
* **stdio 向后兼容探测。** 在 stdio 中，没有按请求划分的
  HTTP 状态码可用于驱动回退。支持现代（按请求 `_meta`）和旧版（`initialize` 握手）服务器的客户端 **SHOULD**
  先发送 `server/discover`；有关回退规则，请参见
  [stdio: 向后兼容](/specification/draft/basic/transports/stdio#backward-compatibility)。

有关完整的版本选择流程，请参见 [协议版本协商](/specification/draft/basic/versioning#protocol-version-negotiation)。
有关为未知方法返回的 HTTP 特定状态码，请参见传输中的
[协议版本标头](/specification/draft/basic/transports/streamable-http#protocol-version-header)
部分。

## 数据类型

### DiscoverResult

发现结果包括：

* `supportedVersions`：服务器支持的协议版本。客户端应
  为后续请求选择其中之一。
* `capabilities`：服务器支持的能力（tools、resources、prompts
  等）
* `serverInfo`：服务器软件的名称和版本
* `instructions`：可选的自然语言指导，供 LLM 了解如何有效使用
  此服务器
