mcp-use-hang-repro
Reproduces a race condition in mcp-use dev where tool results are dropped when the handler completes after the widget iframe loads.
README
Repro: widget tool result is dropped when the handler loses a race with the iframe load
In mcp-use dev, a tools/call that renders a widget can hang in the inspector: the server
finishes the call, but the result never reaches the client, which spins until its request
timeout (-32001). Whether it hangs depends on how long the tool handler takes — it's a
probabilistic race, not a fixed timeout.
Measured on the stock scaffold by sweeping the handler delay (DELAY_MS):
DELAY_MS |
worked |
|---|---|
| 0 | always |
| 100 | always |
| 150 | ~6 / 8 |
| 200 | ~50% |
| 250 | ~2 / 6 |
| 300 | never |
| 1000 | never |
| 2000 | never |
The probability of hanging climbs smoothly from ~150ms to ~300ms — a transition band, not a cliff. Reading: the tool result is racing the widget iframe finishing its load/connect (itself a variable ~150–300ms). If the handler returns before the iframe is done, the result is delivered; if it returns after, the result is dropped.
This is why it looks intermittent in a real server: a handler that hits an API/DB has jittery latency that lands in the transition band, so it hangs only some fraction of the time.
- Only in
mcp-use dev. A production build / deployed connector does not hang. - This project is the unmodified
create-mcp-use-app --template mcp-appsscaffold; the only change is making the stocksearch-tools2s delay configurable viaDELAY_MS.
Environment
- mcp-use: 1.33.0 (also seen on 1.30.0). macOS, Chrome.
Getting Started
npm install
npm run dev
Steps
DELAY_MS=2000 npm run dev # http://localhost:3000, opens the inspector
- Open the inspector, call
search-tools(args can be empty{}) → spins forever, eventually-32001. (At 2000ms it hangs every time.) - Restart with
DELAY_MS=0 npm run dev, call again → delivers instantly, every time. - To see the race, sweep
DELAY_MS=150 / 200 / 250(restart each time) and call the tool several times — it hangs a growing fraction of the time as the delay rises.
On hanging runs the widget iframe renders its skeleton (it received the tool input) but never the output (props).
Negative controls — Node clients do NOT reproduce it (so it's browser-specific)
These are MCP clients, so the dev server must already be running in another terminal.
DELAY_MS is a server setting (it controls the handler) — set it on npm run dev, not
on the script. Two terminals:
# terminal 1 — start the server at the hang-inducing delay, leave it running
DELAY_MS=2000 npm run dev
# terminal 2 — run a client against it
node repro.mjs # SDK client: pre-read widget, then tools/call + resources/read CONCURRENTLY
node repro-flood.mjs # SDK client: tools/call + a burst of widget asset fetches, concurrently
(If you see ECONNREFUSED ::1:3000, the dev server isn't running — start terminal 1 first.)
Both deliver the tool result fine even at DELAY_MS=2000 (the browser hangs every time at
that delay). A headless mcp-use client screenshot --tool search-tools also works. These
never load the widget iframe in a browser, so there's nothing for the result to race —
consistent with the race reading above.
Why (unconfirmed)
Browser-only + dev-only, probabilistic in a ~150–300ms band → looks like the result racing
something that completes when the widget iframe loads/connects, rather than a fixed timer or
plain connection contention. In mcp-use dev the iframe's assets are served from the same
origin (localhost:3000) by Vite; a deployed build serves prebuilt assets from a separate
CDN origin and doesn't hang. Exact mechanism unconfirmed.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。