> ## 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" />

Model Context Protocol (MCP) 支持通过通知消息对长时间运行的操作进行可选进度跟踪。
任一方都可以发送进度通知，以提供操作状态更新。

## 进度流程

当一方希望\_接收\_某个请求的进度更新时，会在请求元数据中包含 `progressToken`。

* 进度令牌 **MUST** 是字符串或整数值
* 进度令牌可以由发送方以任何方式选择，但在所有活动请求中 **MUST** 唯一。

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "some_method",
  "params": {
    "_meta": {
      "progressToken": "abc123"
    }
  }
}
```

随后接收方 **MAY** 发送包含以下内容的进度通知：

* 原始进度令牌
* 到目前为止的当前进度值
* 可选的 `total` 值
* 可选的 `message` 值

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "notifications/progress",
  "params": {
    "progressToken": "abc123",
    "progress": 50,
    "total": 100,
    "message": "Reticulating splines..."
  }
}
```

* 即使 `total` 未知，`progress` 值也 **MUST** 随每次通知递增。
* `progress` 和 `total` 值 **MAY** 为浮点数。
* `message` 字段 **SHOULD** 提供相关的人类可读进度信息。

## 行为要求

1. 进度通知 **MUST** 只引用满足以下条件的令牌：
   * 由活动请求提供
   * 与进行中的操作相关联

2. 进度请求的接收方 **MAY**：
   * 选择不发送任何进度通知
   * 以其认为合适的任何频率发送通知
   * 如果 `total` 值未知，则省略它

```mermaid theme={null}
sequenceDiagram
    participant Sender
    participant Receiver

    Note over Sender,Receiver: Request with progress token
    Sender->>Receiver: Method request with progressToken

    Note over Sender,Receiver: Progress updates
    Receiver-->>Sender: Progress notification (0.2/1.0)
    Receiver-->>Sender: Progress notification (0.6/1.0)
    Receiver-->>Sender: Progress notification (1.0/1.0)

    Note over Sender,Receiver: Operation complete
    Receiver->>Sender: Method response
```

## 实现说明

* 发送方和接收方 **SHOULD** 跟踪活动进度令牌
* 双方 **SHOULD** 实现速率限制以防止泛洪
* 进度通知 **MUST** 在完成后停止
