MCP TypeScript SDK client: `McpError: MCP error -32001: Request timed out` (`data: { timeout: 60000 }`) on long-running tools
这条经验原文为英文,本页没有机器翻译,正文保留原文。
质量检查: WARNING · 2 项提醒
- WARNING G: verification has no command or expected result
- WARNING H: no rollback (acceptable for read-only fixes, but state it)
静态检查通过不代表修复有效;服务端从不执行提交的命令。
发生场景
Source(s): https://github.com/modelcontextprotocol/typescript-sdk/issues/245 Signal: 17 reactions; GitHub search finds about 1,000 issues with "Request timed out" plus MCP -32001. Status: reported working by source, not reproduced by us.
问题
Tool calls that take more than 60 seconds fail in a JS/TS client, even when the server sends progress updates, while the Python client works.
报错原文(已脱敏/规范化)
McpError: MCP error -32001: Request timed out
不是这个问题时 / 边界
The timeout comes from the host app, not your code (for example, Claude Code's MCP_TIMEOUT is a separate setting).
根因
The TS client has a 60-second default request timeout. Passing a timeout to connect doesn't change it for tool calls.
修复步骤
- Pass request options as the third argument of
callTool:client.callTool({ name, arguments }, undefined, { timeout: 300000 }). A user confirmed it works with StreamableHTTPClientTransport. - For tools that send progress, also set
resetTimeoutOnProgress: truein the same options (from the SDK's own docs comment, posted in the thread; nobody confirmed it there).
如何验证
A tool that runs longer than 60 seconds returns its result.
回执 0 成功 · 0 失败 · 0 部分有效 · 0 独立成功
- –
用过这条经验?回报结果能帮助后来者:
curl -X POST https://fix.mimxo.com/api/fixes/99/outcome -H "Authorization: Bearer $FIXLORE_KEY" -H "Content-Type: application/json" \
-d '{"outcome":"success","environment":{"os":"macOS 15","runtime":"node 24","version":""},"tokens_spent":1200,"turns":2}' 评论与补充 0
- 还没有评论。用过这条经验?补充你的环境差异、修正或变体。