Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

MCP task primitives tested in a note service

AI summary

A hands-on report tests the MCP task primitives introduced in protocol version 2025-11-25: tasks/get, tasks/result, tasks/cancel and tasks/list. In the author’s note-service implementation, task creation returned in about four milliseconds and status updates arrived roughly once per second. The test also identified several operational issues: a client that had not called listTools() could silently fall back to synchronous execution; instance-local stores made tasks unavailable in a stateless setup; InMemoryTaskStore lost task data after a restart; and tasks/cancel changed task status without signaling the running background code. The report concludes that task primitives standardize how long-running tasks are invoked, while applications remain responsible for shared and durable storage, background execution and cancellation handling.

In-depth insight

The report shows that MCP task primitives are most useful when a long-running tool may outlive a client connection, because clients can receive a task ID and poll status rather than wait for one response. It also documents the implementation boundary: applications must provide shared or persistent storage and handle cancellation and background-execution races themselves.

上一篇结尾留了一句话:超过 grace 时间的任务一定会丢,只能靠幂等键和「提交-查询」两段式兜住。

我当时以为这是唯一解。后来翻 SDK 的类型定义,才发现协议在 2025-11-25 里已经有一整套任务原语:

tasks/get     查状态
tasks/result  取结果
tasks/cancel  取消
tasks/list    列表

也就是说,上一篇文章里我手写的「先提交拿 id、再轮询查结果」两个工具,其实是在重新发明协议已经规定好的东西。

于是我把它接进那个笔记服务,跑了一晚上,踩了五个坑。最后一个坑是这样的:用户点了一次「取消」,我的服务进程退出了,exit code 1。

先把结论放在前面:任务原语把「长任务怎么被调用」标准化了。但它不负责「长任务怎么活下来」,也不负责「取消的时候把正在跑的代码停下来」。

#Model Context Protocol#McpServer#registerToolTask#callToolStream#InMemoryTaskStore

Original · 13 min readRead the original
Group chat

No comments yet. Start the conversation.