Conversation
SSEServerTransport.ServeHTTP pre-validates each POSTed request against serverMethodInfos, the static set of standard methods, so a method registered with AddReceivingCustomMethod was rejected with HTTP 400 and `"acme/search" unsupported`. On the client, sseClientConn.Write turned that into `failed to write: 400 Bad Request`, which jsonrpc2 treats as a transport write failure, so the whole session broke rather than the one call. The same custom method works over the in-memory, stdio and Streamable HTTP transports; the Streamable handler already consults Server.receivingMethodInfos for this check (modelcontextprotocol#956), but the SSE handler was not updated at the same time. Give SSEServerTransport an unexported server field, set by SSEHandler before the transport is registered, and use the server's receiving method infos in the check when it is known. A transport constructed directly still falls back to the standard methods, as before. TestSSECustomMethod connects a client over SSE, calls a custom method, and pings afterwards to check that the session survived. It fails without the change with `failed to write: 400 Bad Request`.
This branch has not been deployed
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.
Fixes #1291.
SSEServerTransport.ServeHTTPpre-validates each POSTed request againstserverMethodInfos, the static set of standard methods, so a method registered withAddReceivingCustomMethodwas rejected with HTTP 400 and"acme/search" unsupported. On the client,sseClientConn.Writeturned that intofailed to write: 400 Bad Request, which jsonrpc2 treats as a transport write failure, so the whole session broke rather than the one call. The same custom method works over the in-memory, stdio and Streamable HTTP transports; the Streamable handler already consultsServer.receivingMethodInfosfor this check (#956), but the SSE handler was not updated at the same time.This gives
SSEServerTransportan unexportedserverfield, set bySSEHandlerbefore the transport is registered in its session map, and uses the server's receiving method infos in the check when it is known. A transport constructed directly still falls back to the standard methods, as before.getServeris now called before the transport is built so the field can be set in the struct literal; it is still called once per GET.TestSSECustomMethodconnects a client over SSE, calls a custom method, and pings afterwards to check that the session survived. It fails without the change withfailed to write: 400 Bad Request.