Repository navigation
fix(server): set Allow: POST on stateless legacy 405 responses - #3002
Merged
felixweinberger merged 4 commits intoOct 23, 2026
Merged
felixweinberger merged 4 commits into
felixweinberger merged 4 commits into
Conversation
🦋 Changeset detectedLatest commit: d5f14f2 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: |
|
Verified the fix: on main, a focused 405 test expects Allow: POST but receives null (2 failed). On this branch, the full server suite passes — 576 tests in 20.7s. The change adds the header in the non-POST branch at packages/server/src/server/createMcpHandler.ts:337-355, and the new assertions pin it at packages/server/test/server/legacyStatelessFallback.test.ts:90 and packages/server/test/server/createMcpHandler.test.ts:549. RFC 9110 compliance for the stateless fallback looks solid. |
Hugo-DDT
force-pushed
the
fix/stateless-405-allow-header
branch
from
October 20, 2026 11:18
0a2a5d9 to
530a467
Compare
olaservo
pushed a commit
to olaservo/typescript-sdk
that referenced
this pull request
Oct 21, 2026
…nfo in result _meta, clientInfo optional (modelcontextprotocol#2513)
Hugo-DDT
force-pushed
the
fix/stateless-405-allow-header
branch
from
October 22, 2026 12:20
530a467 to
7f9541f
Compare
createMcpHandler's legacy stateless fallback answered non-POST requests with 405 without an Allow header. RFC 9110 §15.5.6 requires Allow on 405, and WebStandardStreamableHTTPServerTransport.handleUnsupportedRequest already sets it. Stateless serving only accepts POST, so advertise that. Closes modelcontextprotocol#2970 Assisted-by: AI (Grok Bot)
Hugo-DDT
force-pushed
the
fix/stateless-405-allow-header
branch
from
October 23, 2026 09:04
7f9541f to
cf633b3
Compare
Moves the header into jsonRpcErrorResponse, so the 405 of legacy: 'reject' carries it too, and asserts it in the e2e requirement that runs on both postures.
felixweinberger
approved these changes
Oct 23, 2026
Merged
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
Fixes #2970.
createMcpHandler's legacy stateless fallback answers non-POSTrequests with405 Method not allowedbut omits theAllowheader. RFC 9110 §15.5.6 requiresAllowon 405 responses.WebStandardStreamableHTTPServerTransport.handleUnsupportedRequest()already setsAllow: GET, POST, DELETE; the stateless fallback only acceptsPOST, so it should advertiseAllow: POST.How Has This Been Tested?
legacyStatelessFallback.test.tsandcreateMcpHandler.test.tsto assertAllow: POST.mainand pass with this change.createMcpHandler+legacyStatelessFallbacksuites (61 tests).pnpm --filter @modelcontextprotocol/server typecheckandlintpassed.Breaking Changes
None. Adds a response header on an existing 405 path; status and JSON-RPC body are unchanged.
Types of changes
Checklist
AI assistance
This change was prepared with AI assistance (Grok Bot). I reviewed the diff, ran the tests above, and take responsibility for the content.