Files
ruflo/v3/@claude-flow/cli/src
Mr. MakandClaude Opus 5 6c2b5d7dff fix(mcp): stdio start no longer SIGKILLs sibling servers (#3364)
`mcp start` on the stdio transport force-"restarted" whatever server was
recorded in the shared PID file — a single slot per os.tmpdir() (per user
on macOS/Windows; the machine-wide /tmp on Linux unless TMPDIR is set).
It sent SIGKILL to that PID, because a stdio server "can't be health-
checked". The victim was simply the last server started through the
command parser: another terminal's stdio server, or a live http/websocket
server that other clients were using. For the same reason, a terminal
stdio server made a later `mcp start -t http` refuse with "MCP Server
already running".

A stdio server is owned by the client that spawned it, over its own
pipes, and any number can run side by side. Only a port-bound transport
is single-instance. ADR-071 made this singleton safe against
self-detection and PID reuse; a stdio server has no business claiming or
killing the shared slot at all. So:

- commands/mcp.ts: a stdio start kills a recorded server only on an
  explicit --force; http/websocket keep their guard unchanged.
- MCPServerManager: a stdio server no longer refuses to start over the
  PID file, writes it, removes it on stop(), or health-checks it. While
  it serves stdio, getStatus() and checkHealth() report the process
  itself rather than whatever PID is recorded. A stale record is still
  cleaned up by the pre-start status read, as before.

The documented piped-stdin `mcp start` (how MCP clients launch it) is
answered by bin/cli.js's inline fast path, which never touches the PID
file. A piped start whose argv does not begin with `mcp` (a leading
global flag) does reach the parser, and is covered too, because the fix
keys on the transport rather than on the TTY.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KTedGmPKpEdArVBMMn3JaP
2026-09-20 11:55:49 -04:00
..
…
2026-01-14 18:48:53 +00:00