Repository navigation
Description
Summary
On Windows, the graph_stats MCP tool (and the graphify://stats resource) can hang indefinitely when the server is run by an MCP host such as Claude Code. Root cause: graphify.export._git_head and graphify.watch._git_head run git rev-parse HEAD via subprocess.run(..., capture_output=True, timeout=3) without stdin=, so the git child inherits the server's stdin — the MCP stdio pipe. Under asyncio/libuv hosts that pipe is an overlapped-mode pipe, and git blocks on it.
prs.py already passes stdin=subprocess.DEVNULL to every gh/git call; these two call sites were missed.
Version: graphifyy 0.9.89, mcp 1.30.0, Python 3.12 (uv tool install), Windows 11, Git for Windows.
Observed
- Under a plain Python
mcpclient, the 3s timeout fires:graph_statstakes a constant 3.0s and theBuilt at commit:staleness line silently loses itsHEADcomparison (because_git_headreturnsNone). Measured on two graphs (5,497 and 22,709 nodes). - Under Claude Code (Windows), the kill-after-timeout never returns:
graph_statshung for 592s until the user interrupted. The host log then shows the correct result arriving asReceived a response for an unknown message ID. - Only graphs with a
built_at_committrigger it (the git call is skipped otherwise), which initially made it look like a "large graph" problem. - With
stdin=subprocess.DEVNULLadded: 0.03s, and the staleness line is correct (HEAD is fe5410b, graph built at abd900b: graph may be stale).
Reproduction
- Build a graph inside a git repo so
graph.jsoncarriesbuilt_at_commit. - Run
graphify-mcp --graph <that>/graph.jsonas an MCP server from an asyncio-based client on Windows (e.g.mcp.client.stdio.stdio_client). call_tool("graph_stats", {})→ 3.0s (timeout path). Under Claude Code → hangs.
In-process bisect: calling _git_head() from a plain script in the same interpreter takes 0.03s; the same call inside the running MCP server hits the timeout; injecting stdin=DEVNULL into that subprocess.run makes it 0.03s inside the server too. _filter_blank_stdin is not a factor (same result with it disabled).
Fix (two one-line changes)
--- a/graphify/export.py
+++ b/graphify/export.py
@@ def _git_head(cwd=None):
r = _sp.run(
- ["git", "rev-parse", "HEAD"], capture_output=True, text=True, timeout=3,
+ ["git", "rev-parse", "HEAD"], stdin=_sp.DEVNULL, capture_output=True, text=True, timeout=3,
cwd=str(cwd) if cwd is not None else None,
)Same change in graphify/watch.py _git_head. Any other subprocess.run reached from a tool handler without stdin= has the same exposure on Windows.
Related background on the general hazard: python/cpython bpo-44527 and alexalexalex222/frontend-design-loop-mcp#1 (same mechanism: child inherits the MCP stdio pipe, kill after timeout never returns).
Happy to open a PR with the two-line change if useful.
Activity
github-actions commentedon Oct 13, 2026
Thanks for opening this issue, @SagitariusAI. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
fix(mcp): don't hand git the server's stdin in _git_head (#4440)
ayushcodes10 commentedon Oct 16, 2026
Already fixed on v8: commit 9dfe132 (
fix(mcp): don't hand git the server's stdin in _git_head (#4440)) addsstdin=subprocess.DEVNULLto bothexport.pyandwatch.py's_git_head, matching the two line fix proposed here. Landed via #4441 (closed, not auto linked since it was cherry picked rather than merged through the PR button, same pattern as #2780/#2779, #4413/#4414, and #4435/#4442). Might be worth closing this one too.omsenjalia commentedon Oct 18, 2026
Fixed on v8 by 9dfe132:
_git_headin bothexport.pyandwatch.pynow passesstdin=subprocess.DEVNULL, andtests/test_git_head_stdin.pycovers it (passes on Windows). It was cherry-picked, so the issue didn't close automatically. Safe to close.omsenjalia commentedon Oct 18, 2026
This looks fixed on the
v8branch by 9dfe1325 (fix(mcp): don't hand git the server's stdin in _git_head (#4440)). Could a maintainer confirm and close?