Repository navigation
fix(client): deliver a modern-era 404 Method not found as a ProtocolError - #3146
jaeminbird wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: cb579d8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
…rror The 2026-07-28 Streamable HTTP spec says a server that does not implement the requested method MUST answer 404 with a -32601 JSON-RPC error body. The client already delivered 400 JSON-RPC error bodies in-band on modern-enveloped requests, but a 404 fell through to SdkHttpError, so callers could not tell Method not found from a transport failure and onerror fired for an ordinary protocol error. Treat 404 the same as 400; bare 404s and legacy-era requests are unchanged.
c12bc29 to
f7ceb6c
Compare
JosephDoUrden
left a comment
There was a problem hiding this comment.
pulled f7ceb6c, 0 behind main. client suite 1079 passed, mcpParamMirroring.test.ts 20/20, integration createMcpHandler + skillsWire 27/27. new test fails with main's streamableHttp.ts (1 failed, 19 passed). mocked 404s: modern -32601 comes back in-band, bare and legacy id:null 404s still SdkHttpError.
nit streamableHttp.ts:1144: gate matches status and request id, not the code, so "matching JSON-RPC error body" reads more accurate.
lgtm.
|
Reworded that comment in cb579d8. |
On the 2026-07-28 protocol, a server answers a method it doesn't implement with HTTP 404 and a
-32601JSON-RPC error body. The SDK's own server does this (LADDER_ERROR_HTTP_STATUSin core-internalinboundClassification.ts, used bycreateMcpHandler), as does Pythonmcp2.3.0. A TS client callingcomplete()or a custom method against either getsSdkHttpError(CLIENT_HTTP_NOT_IMPLEMENTED, status 404) instead of aProtocolError-32601, andonerrorfires for it, so a caller can't fall back on Method not found.Cause:
StreamableHTTPClientTransport.senddelivers JSON-RPC error bodies in-band only for status 400 (#2286).Fix: accept 404 on that same path. It still requires a modern-enveloped request and a parsed JSON-RPC error matching the request id, so bare 404s and 2025-era session-expiry 404s (id null) still throw
SdkHttpError.Tests
mcpParamMirroring.test.tsand integration test intest/integration/test/server/createMcpHandler.test.ts: both fail on main 1e608ca, pass with the fix.eslint src/clean (Windows, Node).createMcpHandlerand Pythonmcp2.3.0: 2/2 calls per server went fromSdkHttpError404 plus twoonerrorcalls toProtocolError-32601 with noonerror.pnpm test:allon Linux.