feat(mcp): add a reload_server meta-tool - #176
Conversation
Changing Konnect's source and rebuilding does nothing until the MCP client is restarted, because the client spawns the server and holds it for the session. Replacing the binary underneath a running server just kills the connection. A stdio server cannot restart itself by exiting — the client owns the process lifecycle and does not respawn it mid-session. So reload_server execs into the binary on disk instead: that replaces the process image while keeping the PID and the inherited stdin/stdout pipes, so the connection is never broken and the client goes on talking to the new build. exec is a one-way door, so the new binary is run once (--version) and checked before the switch. A half-written copy, a failed link, or an unsigned binary macOS would kill becomes a refused call naming the reason rather than a server that is simply gone. confirm=true is required so a stray call cannot restart mid-task, and the reply is written before the switch since exec never returns on success. Windows gets a clear unsupported error — no exec equivalent keeps the pipes. Router state does not survive; the new image starts at the starter kit. That is self-healing: a call to a previously loaded tool returns toolset_not_loaded naming its toolset, so recovery is one hop. Also pins the meta-tool count in a test. It is quoted in DEV.md, README.md and tool-directory.md, so adding one now forces those to be updated in the same commit instead of drifting. Meta-tools 6 -> 7, docs updated to 194 total. 433 tests pass (3 added); clippy --workspace -D warnings clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Good problem, and the core insight — that a stdio server can't restart itself by exiting, because the client owns the process lifecycle — is right. But there are enough sharp edges that I'd like changes before it lands. argv is lost. No transport guard. The whole "the connection survives" rationale is stdio-only. Under The 250 ms window is a real one. The Windows. The Note main now has a test pinning the documented tool counts ( Deferring to the next round rather than closing; ping me when you've reworked it. |
|
Checking in — this has been waiting on the rework since 2026-08-14, and I would like to either land it or close it rather than leave it open indefinitely. The three things from the review still stand:
(3) also has a cost you may not have noticed: adding a meta-tool takes the count from 6 to 7, and No pressure on timing — say the word if you would rather I take it over, or if you would prefer to close it and revisit later. It is a reasonable feature and I do not want it to rot silently. |
|
Status check at Round 12: no commits since the rework request — all four items stand (argv preserved via |
Changing Konnect's source and rebuilding does nothing until the MCP client is restarted, because the client spawns the server and holds it for the session. Replacing the binary underneath a running server just kills the connection.
A stdio server cannot restart itself by exiting — the client owns the process lifecycle and does not respawn it mid-session. So reload_server execs into the binary on disk instead: that replaces the process image while keeping the PID and the inherited stdin/stdout pipes, so the connection is never broken and the client goes on talking to the new build.
exec is a one-way door, so the new binary is run once (--version) and checked before the switch. A half-written copy, a failed link, or an unsigned binary macOS would kill becomes a refused call naming the reason rather than a server that is simply gone. confirm=true is required so a stray call cannot restart mid-task, and the reply is written before the switch since exec never returns on success. Windows gets a clear unsupported error — no exec equivalent keeps the pipes.
Router state does not survive; the new image starts at the starter kit. That is self-healing: a call to a previously loaded tool returns toolset_not_loaded naming its toolset, so recovery is one hop.
Also pins the meta-tool count in a test. It is quoted in DEV.md, README.md and tool-directory.md, so adding one now forces those to be updated in the same commit instead of drifting. Meta-tools 6 -> 7, docs updated to 194 total.