Skip to content

fix: stop --mcp alone from triggering the UI keep-alive loop - #57

Open
JProck21 wants to merge 2 commits into
intuit:mainfrom
JProck21:fix/mcp-worker-process-leak
Open

fix: stop --mcp alone from triggering the UI keep-alive loop#57
JProck21 wants to merge 2 commits into
intuit:mainfrom
JProck21:fix/mcp-worker-process-leak

Conversation

@JProck21

Copy link
Copy Markdown

Summary

infigraph-mcp was leaking worker processes: passing --mcp alone incorrectly
set ui_enabled = true, which puts the process into a loop { sleep(3600s) }
keep-alive after stdin EOF instead of exiting. Over repeated MCP client
restarts this accumulates orphaned worker processes.

Root cause: ui_enabled was derived from
args.iter().any(|a| a == "--ui" || a.starts_with("--ui=") || a == "--mcp")
the || a == "--mcp" clause meant bare --mcp (no --ui) still enabled the
UI keep-alive path. Fix removes that clause so ui_enabled only reflects an
actual --ui/--ui= flag.

Also extracted the check into ui_enabled_from(args: &[String]) -> bool so
it's unit-testable in isolation from run().

Test plan

  • [x ] cargo test --all passes
  • [x ] cargo clippy --all-targets passes
  • [x ] Tested manually (describe below)
./target/debug/infigraph-mcp --mcp < /dev/null &
  pid=$!
  sleep 5
  if kill -0 $pid 2>/dev/null; then
    echo "STILL RUNNING after 5s — bug present"
    kill -9 $pid
  else
    wait $pid
    echo "exited on its own, exit code: $?"
  fi

The above exited 0 after the update.

Notes

No behavior change for --ui / --ui=<port> / --mcp --ui combinations; only bare --mcp is affected.

jprock21 and others added 2 commits August 10, 2026 12:28
ui_enabled was true for bare --mcp, not just --ui/--ui=. That made every
plain stdio MCP session (the documented, standard invocation) hit the
post-stdin-EOF "UI still serving" keep-alive loop on client disconnect,
so the worker process (and its supervisor) never exited. Confirmed via
~/.infigraph/mcp.log: 119/133 sessions logged "stdin loop exited" yet
their processes were still resident days later, some orphaned to pid 1.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Regression test for the --mcp-alone-triggers-UI-loop leak fix — extracts
the flag check into ui_enabled_from() so it's directly unit testable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant