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

# Ping

<Info>**协议版本**: 2025-03-26</Info>

模型上下文协议包含一个可选的ping机制，允许任何一方验证其对方仍然响应且连接处于活动状态。

## 概述

ping功能通过简单的请求/响应模式实现。客户端或服务器都可以通过发送`ping`请求来启动ping。

## 消息格式

ping请求是一个没有参数的标准JSON-RPC请求：

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "123",
  "method": "ping"
}
```

## 行为要求

1. 接收者**必须**迅速响应一个空响应：

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "123",
  "result": {}
}
```

2. 如果在合理的超时期限内没有收到响应，发送者**可以**：
   * 认为连接已过时
   * 终止连接
   * 尝试重新连接程序

## 使用模式

```mermaid theme={null}
sequenceDiagram
    participant 发送者
    participant 接收者

    发送者->>接收者: ping请求
    接收者->>发送者: 空响应
```

## 实现考虑因素

* 实现**应该**定期发出ping以检测连接健康状况
* ping的频率**应该**是可配置的
* 超时**应该**适合网络环境
* **应该**避免过度ping以减少网络开销

## 错误处理

* 超时**应该**被视为连接失败
* 多次ping失败**可能**触发连接重置
* 实现**应该**记录ping失败以进行诊断


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.