Skip to content

Commit 0e230f2

Browse files
committed
docs: add Tasks section to Chinese README
1 parent 75fa052 commit 0e230f2

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/readme/README.zh-cn.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [补全](#补全)
3232
- [通知](#通知)
3333
- [订阅](#订阅)
34+
- [任务](#任务长时间运行的工具调用)
3435
- [示例](#示例)
3536
- [OAuth 支持](#oauth-支持)
3637
- [相关资源](#相关资源)
@@ -954,6 +955,26 @@ impl ClientHandler for MyClient {
954955

955956
---
956957

958+
## 任务(长时间运行的工具调用)
959+
960+
`rmcp` 支持 SEP-1319 中定义的[基于任务的工具调用](https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks)流程。为工具添加 `execution(task_support = "required" | "optional")` 注解,并在 `ServerHandler` 实现上添加 `#[task_handler]` —— `enqueue_task``tasks/list``tasks/get``tasks/result``tasks/cancel` 将在 `OperationProcessor` 之上自动生成。
961+
962+
```rust, ignore
963+
#[tool(
964+
description = "Sum two numbers after a 2-second delay",
965+
execution(task_support = "required")
966+
)]
967+
async fn slow_sum(/* ... */) -> Result<CallToolResult, McpError> { /* ... */ }
968+
969+
#[tool_handler]
970+
#[task_handler]
971+
impl ServerHandler for TaskDemo {}
972+
```
973+
974+
完整的端到端示例请参阅 [`servers_task_stdio`](../../examples/servers/src/task_stdio.rs) 及对应的 [`clients_task_stdio`](../../examples/clients/src/task_stdio.rs)
975+
976+
---
977+
957978
## 示例
958979

959980
查看 [examples](../../examples/README.md)

0 commit comments

Comments
 (0)