> ## Documentation Index
> Fetch the complete documentation index at: https://mcp.developerdoc.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 发现

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

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

## 请求

除标准 `_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": "This server provides weather and resource utilities.",
    "ttlMs": 3600000,
    "cacheScope": "public"
  }
}
```

### 响应字段

| 字段                  | 类型                   | 必需  | 描述                            |
| ------------------- | -------------------- | --- | ----------------------------- |
| `supportedVersions` | `string[]`           | yes | 服务器支持的协议版本。客户端应为后续请求选择其中一个版本。 |
| `capabilities`      | `ServerCapabilities` | yes | 服务器支持的能力（工具、资源、提示等）。          |
| `serverInfo`        | `Implementation`     | yes | 服务器软件的名称和版本。                  |
| `instructions`      | `string`             | no  | 面向 LLM 的自然语言指引，说明如何有效使用此服务器。  |

## 何时调用

客户端调用 `server/discover` 是可选的；客户端可以直接内联调用任意 RPC，并在服务器不支持所请求版本时处理
[`UnsupportedProtocolVersionError`](/specification/draft/schema#unsupportedprotocolversionerror)。不过，`server/discover` 在两种场景中很有用：

* **前置版本选择。** 客户端在发送任何其他请求前获知服务器支持的版本，从而避免一次往返错误。
* **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)章节。
