Repository navigation
Conversation
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)
🦋 Changeset detectedLatest commit: 0a2a5d9 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. |
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.
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.