Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

Windows:MCP 标准输入输出服务器(codegraph)在空闲 60 秒后断开连接 — Kiro 未检测到进程退出

Open 1737894252 opened this issue 1 month ago • 3 comments

Windows: MCP stdio server (codegraph) disconnects after 60s idle — Kiro does not detect process exit

Environment

Item Value
OS Windows 11
Kiro version ide 1.3.0
Node.js v24.18.1
npm 11.16.0
MCP server tested @colbymchenry/codegraph v1.6.2
Project size 25,639 Java files / 3.3 GB codegraph index

Summary

After connecting to a codegraph MCP server on Windows, the connection silently fails approximately 60 seconds after the last tool call. The MCP Server panel continues to show "connected" even though the underlying process has already been killed. All subsequent tool calls fail with "Not connected", with no logs generated anywhere.


Root Cause (Two Issues)

Issue 1 — codegraph watchdog kills idle process (codegraph bug / design flaw)

codegraph spawns a watchdog child process alongside the main server. The watchdog monitors stdin activity and kills the main process if no MCP requests arrive within 60 seconds:

// Watchdog parameters observed in process list:
const timeoutMs = 60000;   // 60 seconds of no stdin → kill
const capMs = 600000;      // hard cap 10 minutes

process.stdin.on('data', () => {
  clearTimeout(timer);
  timer = setTimeout(onTimeout, timeoutMs); // resets on each request
});
// If no request arrives within 60s → SIGKILL main process

This logic was designed to kill wedged (unresponsive) processes, but it incorrectly uses stdin silence as a proxy for "process is stuck". In MCP usage, 60 seconds of idle is normal — no requests simply means the user isn't actively querying.

Issue 2 — Kiro does not detect process exit (Kiro bug)

When codegraph is killed, Kiro:

  • Does not detect the process exit event
  • Does not update the MCP Server panel to show "disconnected"
  • Does not auto-restart the process
  • Continues to show "connected" indefinitely

This means users have no indication that the server is dead. Tool calls silently fail with "Not connected", and no MCP log entries are generated because the request never reaches the dispatch layer.


Steps to Reproduce

  1. Install codegraph globally:

    npm install -g @colbymchenry/codegraph
    
  2. Add to C:\Users\<user>\.kiro\settings\mcp.json:

    "codegraph": {
      "type": "stdio",
      "command": "codegraph",
      "args": ["serve", "--mcp"]
    }
    
  3. Connect via Command Palette → MCP → Reconnect MCP Servers → codegraph

  4. Verify it works — make one tool call successfully

  5. Wait 60+ seconds without making any tool calls

  6. Attempt another tool call

  7. Observe:

    • MCP Server panel still shows "connected"
    • Tool call fails with Not connected
    • No entries in MCP log
    • Get-CimInstance Win32_Process -Filter "name='node.exe'" shows no codegraph process running

Observed Behavior

Kiro connects → codegraph starts → tool calls work
       ↓
  60s with no MCP requests
       ↓
  watchdog kills codegraph process (SIGKILL)
       ↓
  Kiro does NOT detect exit → panel still shows "connected"
       ↓
  next tool call → "Not connected", no MCP log

Expected Behavior

  • Kiro should detect when a stdio MCP server process exits and update the panel status to "disconnected" immediately
  • Ideally, Kiro should auto-restart the process (or at minimum prompt the user to reconnect)

Workaround

Add CODEGRAPH_NO_WATCHDOG=1 to the MCP server env config to disable the watchdog:

"codegraph": {
  "type": "stdio",
  "command": "codegraph",
  "args": ["serve", "--mcp"],
  "env": {
    "CODEGRAPH_NO_WATCHDOG": "1"
  }
}

This prevents codegraph from killing itself on idle. After applying this, the process stays alive and connections remain stable.


Impact

Any user running codegraph MCP on Windows with a large project (slow queries or long idle periods) will hit this. The silent failure and stale "connected" UI state make it extremely difficult to diagnose without inspecting the process list manually.

1737894252 avatar Oct 15 '26 04:10 1737894252

Image

1737894252 avatar Oct 15 '26 04:10 1737894252

Thanks for opening this issue and providing such a thorough write-up, including the environment details, suspected root cause, and a working workaround — that's incredibly helpful! 🙌 We understand that MCP stdio servers using npm .cmd shims on Windows are failing to connect due to how the process spawning handles batch file wrappers. A maintainer will review this shortly. We really appreciate you taking the time to document this so well — it'll make diagnosing and addressing the issue much smoother!

github-actions[bot] avatar Oct 15 '26 04:10 github-actions[bot]

Thanks for raising this. The two-part analysis is well-documented. The Kiro-side gap is the one we can address: when a stdio MCP server process exits unexpectedly, the IDE should detect the process exit event, update the connection status to "disconnected," and ideally attempt a reconnect or at minimum surface a clear error on the next tool call instead of silently failing with "Not connected" and no log entries. The CODEGRAPH_NO_WATCHDOG=1 workaround you found is a valid short-term option. Marking this as a bug to investigate further.

AnilMaktala avatar Oct 15 '26 14:10 AnilMaktala