最新资讯
bloomberg.com 科技股抛售后,Anthropic IPO 估值承压 dev.to 当“按设计工作”成为问题:Claude Code 与 .NET 用户机密 dev.to 用代理修复 3500 个 Sonar 问题花 44 美元,让结果可信花 520 美元 dev.to 底层陷阱:为何企业 AI 使用率跑赢其 EBIT 影响 thenewstack.io Cursor 推出全托管应用部署,对标 Lovable 与 Replit techrepublic.com METR 评估显示 Anthropic 模型进展近乎翻倍,IT 采购方需关注什么 bloomberg.com Nvidia AI 芯片出口成为民主党国会关注目标 computerworld.com Meta 撤回争议性企业 AI 条款 bloomberg.com 台积电据报考虑生产先进 AI 存储芯片 www.infoq.com Yelp 为 AI Assistant 融合原生与服务器驱动 UI computerworld.com 英国监管机构:企业须为自家 AI 代理的错误负责 siliconangle.com Atomicwork 推出面向企业 IT 与安全的认证 AI 同事市场
多元动态
登录 注册
行业动态 dev.to · @quintetkit

我设了 500ms 超时,结果等了 28 小时

原文 我的收藏

作者记录 MCP 服务器配置中 timeout 字段的踩坑:设置 500 毫秒会被忽略,回退到 MCP_TOOL_TIMEOUT,未设置时默认约 28 小时。文中提到 v2.1.162 之前低于 1000 的值会被向下取整为 1 秒,行为已改变而配置未变。另有三点细节:timeout 是每次工具调用的硬性墙钟上限,服务端进度通知不会延长它;至少 1000 的 timeout 同时作为空闲超时下限;stdio 和 WebSocket 服务器没有逐请求计时器;无 type 的 url 被当作 stdio 服务器。

AI推荐理由 作者以亲身踩坑记录 MCP 服务器配置中 timeout 字段的行为变化:低于 1000 的毫秒值被忽略,回退到 MCP_TOOL_TIMEOUT,未设置时默认约 28 小时;并指出 v2.1.162 之前低于 1000 会被向下取整为 1 秒。文中还给出三条相关细节:timeout 是每次工具调用的硬性墙钟上限、服务端进度通知不会延长它、至少 1000 的 timeout 同时充当空闲超时下限、stdio 与 WebSocket 服务器没有逐请求计时器、无 type 的 url 被当作 stdio 服务器。这些是具体且可验证的配置行为差异,对使用 MCP 的开发者有实际排错价值;但属于个人博客经验,未附官方文档链接或版本发布说明,且默认 28 小时的来源未给出依据,需读者自行核实。

72

正文

I had an MCP server that occasionally hung, so I gave it a short leash: { "mcpServers": { "flaky": { "type": "http", "url": "...", "timeout": 500 } } } Enter fullscreen mode Exit fullscreen mode timeout is in milliseconds, so that reads as half a second. Values below 1000 are ignored. The call falls through to MCP_TOOL_TIMEOUT, and if that is unset, to its default — about 28 hours. I had written the tightest limit I could and produced the loosest one available. Before v2.1.162 a value under 1000 was floored to one second, which is the behaviour I had in my head. It changed, and nothing in my configuration changed with it. Three related things I only learned by reading the whole section: timeout is a hard wall-clock limit per tool call. Progress notifications from the server do not extend it A timeout of at least 1000 also acts as a floor on the idle timeout — calls are never aborted for idleness sooner than that stdio and WebSocket servers have no per-request timer at all A url with no type is read as a stdio server { "mcpServers": { "example": { "url": "https://mcp.example.com/mcp" } } } Enter fullscreen mode Exit fullscreen mode There is no defaulting to http. An entry with no type is a stdio server, stdio requires command, and so the server is skipped as a configuration error: MCP server "example" has a "url" but no "type"; add "type": "http" (or "sse" / "ws") to this entry Enter fullscreen mode Exit fullscreen mode That message exists from v2.1.202. Before it, the same mistake reported command: expected string, received undefined — you wrote a url and were told about a command, which is a long way from the cause. Under --output-format stream-json it also appears in the system/init event's mcp_server_errors, so a script can detect that a server never loaded. That is the only machine-readable path I have found for it. A cloned repository cannot approve its own servers This one cost me the most time, because it looks like a permissions bug. Servers from .mcp.json need approval. You can commit enableAllProjectMcpServers or enabledMcpjsonServers to the project's .claude/settings.json — and in an untrusted folder they are ignored. The server sits at ⏸ Pending approval, never connected, never health-checked. Which is correct, and obvious once stated: a repository that could approve its own MCP servers would be a way to run code on anyone who clones it. Three sources of approval still apply in an untrusted folder: your own ~/.claude/settings.json, managed settings, and settings passed with --settings. The pattern across all of these Every one of them is a configuration that loads. No error, no warning you would notice, and a running system that is doing something other than what the file says. timeout: 500 is the sharpest example: the file says half a second, the system says a day and change, and both are working as designed. What I want from a configuration checker, having been on the wrong end of these, is not more rules. It is that the ones it does have never fire on something correct — because the reason I stopped reading startup output in the first place was that nothing there had ever mattered, and by the time something did, I had already trained myself past it. npx @quintetkit/ccheck Enter fullscreen mode Exit fullscreen mode error .mcp.json:3 Server "example" has a `url` but no `type`. Add `"type": "http"` (or "sse" / "ws"). warn .mcp.json:9 Server "flaky": `timeout: 500` is in milliseconds; values below 1000 are ignored. Enter fullscreen mode Exit fullscreen mode The full set, including the required field per transport: https://quintetkit.github.io/en/reference/claude-code-mcp-json.html I publish the configuration for splitting Claude Code into separate personas — Architect, Coder, Reviewer, Conflict Resolver — under MIT. Copy it, run ./setup.sh, and it works. It does not depend on your tech stack. https://github.com/quintetkit/quartet I built one real tool using nothing but this workflow. Every Issue, PR, review and merge is still there. The parts that went wrong were not deleted. https://github.com/quintetkit/mdlinkcheck The version that adds a UI Designer persona, review criteria, a per-Issue parallel execution script and a 11-chapter guide is on the product page. The full kit — five personas, the scripts and the complete guide — is available here. https://quintetkit.gumroad.com/l/quintet

来源报道 · 1 篇 · 以下链接均前往原始媒体

quintetkit 我设了 500ms 超时,结果等了 28 小时 09-12 · 原文发布
← 返回精选动态 原文

更多内容