Refuse server-to-client requests in the modern lifecycle per SEP-2575 - #503
Open
koic wants to merge 1 commit into
Open
Refuse server-to-client requests in the modern lifecycle per SEP-2575#503koic wants to merge 1 commit into
koic wants to merge 1 commit into
Conversation
## Motivation and Context The modern lifecycle removes server-initiated JSON-RPC requests: a stateless server has no connection to send them on, and SEP-2322 multi round-trip `input_required` results replace what sampling and elicitation covered before. `StdioTransport#send_request` already says so, refusing outright when its session is modern. `StreamableHTTPTransport#send_request` says nothing, so a modern handler that reaches for elicitation or sampling falls through to the session lookup and is told `Session not found: <uuid>` against a session id it never chose. Failing is right, the explanation is not: `handle_modern` mints a session per request without ever registering it in `@sessions`, so that lookup cannot succeed for a modern request no matter what the handler does. `send_request` now refuses a modern-era session up front with the message `StdioTransport` uses, which turns an incidental registration detail into a stated rule and leaves the rest of the method a legacy-only path by construction. Callers see the same `RuntimeError` class as before, only with a message naming the actual constraint. ## How Has This Been Tested? A new test in `test/mcp/server/transports/streamable_http_transport_test.rb` sends `elicitation/create` from a session constructed with `era: :modern` and asserts the SEP-2575 message. It sits with the existing guard tests for stateless mode, a missing `session_id`, and an unknown session, which still pass unchanged. `bundle exec rake` is green, and both conformance legs pass their baseline check. ## Breaking Changes None. The call already failed; only the message changes.
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.
Motivation and Context
The modern lifecycle removes server-initiated JSON-RPC requests: a stateless server has no connection to send them on, and SEP-2322 multi round-trip
input_requiredresults replace what sampling and elicitation covered before.StdioTransport#send_requestalready says so, refusing outright when its session is modern.StreamableHTTPTransport#send_requestsays nothing, so a modern handler that reaches for elicitation or sampling falls through to the session lookup and is toldSession not found: <uuid>against a session id it never chose. Failing is right, the explanation is not:handle_modernmints a session per request without ever registering it in@sessions, so that lookup cannot succeed for a modern request no matter what the handler does.send_requestnow refuses a modern-era session up front with the messageStdioTransportuses, which turns an incidental registration detail into a stated rule and leaves the rest of the method a legacy-only path by construction. Callers see the sameRuntimeErrorclass as before, only with a message naming the actual constraint.How Has This Been Tested?
A new test in
test/mcp/server/transports/streamable_http_transport_test.rbsendselicitation/createfrom a session constructed withera: :modernand asserts the SEP-2575 message. It sits with the existing guard tests for stateless mode, a missingsession_id, and an unknown session, which still pass unchanged.bundle exec rakeis green, and both conformance legs pass their baseline check.Breaking Changes
None. The call already failed; only the message changes.
Types of changes
Checklist