Repository navigation
Answer a declined discover probe ahead of rmcp - #38
Merged
Merged
Conversation
Claude Code now opens a stdio session with server/discover at 2026-07-28 and falls back to initialize on the same session when the server declines that revision, which this one always does. rmcp marks a session as needing per-request _meta the moment its first message is not initialize, before the handler rejects the probe, and never clears the mark. The fallback handshake succeeded and then tools/list was refused for missing _meta, so "/mcp" showed the server connected with no tools. rmcp 3.5.0 behaves the same. A thin transport wrapper answers a discover for a declined revision with the same unsupported-version error rmcp sends, until initialize passes through, so rmcp sees initialize first and keeps the session on the lifecycle it negotiated. A discover naming a revision this server speaks still goes to rmcp. A failed write of that reply is logged before the session ends. The 2026-07-28 exclusion is unchanged. The new lifecycle test replays the probe, the fallback and tools/list. Starting the wrapper as already initialized, which hands the probe to rmcp, fails it with the reported error.
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.
Claude Code 2.1.285 now opens a stdio session with
server/discoverat 2026-07-28, and when the server declines that revision (this one always does, seeEXCLUDED_PROTOCOL_VERSIONS) it falls back toinitializeon the same session. rmcp marks the session as requiring per-request_metaas soon as the first message is notinitialize, before the probe is rejected, and never clears it. The fallback handshake succeeds, thentools/listis refused with-32602 request _meta is missing or has malformed required fields, so/mcpshows the server connected with no tools. rmcp 3.5.0 has the same behavior.This adds a small transport wrapper in
src/main.rs. Untilinitializearrives, it answers a discover for a declined revision itself, with the same-32022unsupported-version error rmcp sends, so rmcp seesinitializefirst. A discover that names a revision this server supports still goes to rmcp. The 2026-07-28 exclusion is unchanged.Verification: I captured Claude Code's actual exchange through a logging wrapper and replayed it against the new binary, and
tools/listnow answers. The new testa_declined_discover_probe_falls_back_to_initialize(test-process-lifecycle) replays the probe, the fallback andtools/list. As a negative control, starting the wrapper as already initialized (so the probe reaches rmcp) makes that test fail with the reported error.scripts/run-gates.shpassed all 18 gates on macOS with Frama-C 33.0 (unit 651, lifecycle 40, stdio 157).The underlying problem is in rmcp, and the wrapper can go once rmcp stops setting the flag for a probe it rejects.
Summary by cubic
Fixes a Claude Code compatibility issue where a
server/discoverprobe caused the fallbackinitializesession to show no tools. Declined probes are now answered before rmcp sees them, so the fallback handshake remains usable andtools/listsucceeds.tools/list, and negotiated protocol state.Written for commit d37c0a6. Summary will update on new commits.