Persistent MCP task stores can leave zombie tasks after restarts
A Juejin author built a file-based MCP TaskStore that persists each task as JSON and compared three restart policies after forcibly killing the service. The zombie policy left tasks reporting “working” until TTL expiry, fail marked them failed, and resume restarted work from the beginning without checkpoints, potentially repeating side effects. The article also recommends using lastUpdatedAt as a possible staleness signal and splitting long work into shorter tool calls where practical.
The experiments show that persisting MCP task status does not preserve execution, making restart policy, idempotency and checkpoints critical for durable AI tool workflows.
上一篇的结尾我写了一句话:InMemoryTaskStore 重启即丢,任务原语只解决「怎么问」,不解决「问的东西还在不在」。
那自然的下一步就是:自己写一个落盘的 store。
我花了一个下午写完了,六个方法、一个任务一个 JSON 文件、原子写。重启之后 tasks/get 照样能返回任务,状态是 working。我以为成了。
然后我发现这个任务永远不会结束。
不是慢,是永远不会。没有报错,没有超时,tasks/get 每隔一秒老老实实返回一次 working,状态消息停在「正在读取笔记」,一直到 TTL 把记录清掉为止。
状态存下来了,执行没存下来。 这两件事在代码里只差几行,但在语义上差了一整个分布式任务系统。