Skip to content

fix: use HTTP 404 for invalid session IDs per MCP spec#1703

Closed
ghost wants to merge 1 commit intomainfrom
unknown repository
Closed

fix: use HTTP 404 for invalid session IDs per MCP spec#1703
ghost wants to merge 1 commit intomainfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 19, 2026

Summary

  • Changes HTTP status code from 400 to 404 when GET/DELETE requests reference an invalid or missing session ID
  • Affects simpleStreamableHttp.ts (2 locations), standaloneSseWithGetStreamableHttp.ts (1 location), and everythingServer.ts (2 locations)
  • Per the MCP spec, 404 is the correct response when a session ID is not recognized by the server

Fixes #389

Test plan

  • Verify conformance tests still pass with updated status codes
  • Confirm client transport handles 404 correctly for invalid sessions

Per the MCP spec, servers should return 404 (Not Found) when a client
provides a session ID that the server does not recognize, not 400
(Bad Request). Updated all example and conformance test server files.

Fixes #389
@ghost ghost self-requested a review as a code owner March 19, 2026 00:20
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 19, 2026

⚠️ No Changeset found

Latest commit: 267886e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 19, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1703

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1703

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1703

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1703

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1703

commit: 267886e

@ghost ghost closed this by deleting the head repository Mar 26, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamable HTTP examples use incorrect status code for invalid session IDs

0 participants