You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mcp: custom methods registered with AddReceivingCustomMethod are rejected over the SSE transport #1291
A method registered with AddReceivingCustomMethod works over the in-memory, stdio and Streamable HTTP transports, but over the (deprecated) HTTP+SSE transport the POST is rejected with HTTP 400 and the whole client session breaks.
SSEServerTransport.ServeHTTP pre-validates each POSTed request with checkRequest(req, serverMethodInfos) (mcp/sse.go). serverMethodInfos is the static set of standard methods, so a custom method name fails with "acme/search" unsupported and the handler answers 400. The Streamable HTTP handler does the same pre-check but was updated in #956 to use Server.receivingMethodInfos(), which includes custom methods; the SSE handler was not.
On the client side, sseClientConn.Write returns failed to write: 400 Bad Request for the POST. jsonrpc2 treats that as a transport write failure, so not only the custom call fails: later calls on the same session fail too.
To Reproduce
Take the existing TestCustomMethods setup (server with AddReceivingCustomMethod(s, "acme/search", ...), client with AddSendingCustomMethod) and connect through SSE instead of NewInMemoryTransports:
The custom method is dispatched to the registered handler over SSE, the same as over the other transports, and the session stays usable.
Fix
Give SSEServerTransport access to the server it is connected to (set by SSEHandler before the transport is registered) and use server.receivingMethodInfos() in the pre-check when it is known, falling back to serverMethodInfos for a transport constructed directly. I have a PR with this change and a regression test (TestSSECustomMethod).
Activity
mcp: accept custom methods over the SSE transport (modelcontextprotoc…