feat(mcp): add a safe Unix stdio reload tool - #484
Merged
Conversation
Collaborator
Author
|
Please reconstruct this PR from current #442 has now merged, so the dependency is resolved, but this head is
This is now |
Reconstruct reload_server on current main while preserving the original contributor authorship and closing the safety gaps found in review. Registration is conditional: only a Unix server running exclusively over stdio advertises or dispatches the tool. Windows, HTTP, and mixed transports retain the seven-tool baseline. The handler validates confirmation and the on-disk version, refuses downgrades, requires an explicit override for same-version development builds, preserves the original argv, and queues a one-shot reload plan. The stdio loop performs exec only after flushing the response and notifications and before accepting another request. Documentation describes the conditional eighth tool without changing cross-platform tool counts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
neusse
force-pushed
the
neusse/reconstruct-176
branch
from
September 10, 2026 19:22
e106549 to
37f6f51
Compare
neusse
force-pushed
the
neusse/reconstruct-176
branch
from
September 10, 2026 19:26
37f6f51 to
e1b6c1f
Compare
neusse
force-pushed
the
neusse/reconstruct-176
branch
from
September 10, 2026 19:37
e1b6c1f to
59354a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reconstructs #176 on current
main, preserving Jean-Yves POCHEZ's original authorship while implementing the safety rework requested in review.What changed
reload_serveronly from the standalone Unix executable when it runs exclusively over stdio.argv[0], including an explicit--configpath./proc/self/fd, so a concurrent pathname replacement cannot change the selected executable.fexecve, records device, inode, length, and modification time and revalidates both the open file and named path immediately beforeexec; ordinary atomic build/install replacement is refused.allow_same_version=truefor an intentional same-version development rebuild.exec.Why the transport handoff matters
The original 250 ms timer allowed the stdio loop to accept a second mutation before
exec, potentially interrupting a write before cleanup guards ran. The transport now returns a sealed handoff before reading another request. The standalone entry point drops its run-record guard beforeexec, so the replacement process can register the same PID cleanly.Evidence
Windows-local evidence:
cargo fmt --all -- --checkcargo clippy --workspace --locked --all-targets -- -D warningscargo test --workspace --locked --lib --testscargo test --workspace --locked --docHosted Unix tests exercise the platform-specific handoff guards:
Risk and rollback
The tool is absent unless the process proves the supported capability combination. The irreversible action requires
confirm=true; same-version builds require a second explicit opt-in. The PR contains the preserved contributor commit plus one focused safety/adaptation commit, either of which can be reverted normally.Supersedes #176.