Skip to content

fix(everything): answer 404 for an unknown streamable HTTP session - #4944

Open
jayhemnani9910 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jayhemnani9910:fix/everything-unknown-session-404
Open

jayhemnani9910 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jayhemnani9910:fix/everything-unknown-session-404

Conversation

@jayhemnani9910

Copy link
Copy Markdown

Description

The everything server's streamable HTTP endpoint answered 400 "Bad Request: No valid session ID provided" for a request carrying a session ID it didn't know, whether never issued or already ended with DELETE. The transport spec (Session Management) says the server MUST answer 404 in that case, and that the client MUST start a new session when it gets 404. With 400 a client can't tell that its session is gone, for example after the server restarts. Unknown session IDs now get 404 {"code": -32001, "message": "Session not found"}, the same response the SDK transport uses. A request with no session ID still gets 400.

Server Details

  • Server: everything
  • Changes to: streamable HTTP transport

Motivation and Context

The everything server is what client authors test against, so it should show the session-expiry behaviour clients are expected to handle.

How Has This Been Tested?

  • With an MCP client over streamable HTTP: initialize, end the session with DELETE, then POST/GET/DELETE with the old ID, plus the same with a never-issued ID. All six now return 404 (400 on main), and a live session still works.
  • npm run build and vitest pass. There are no transport-level tests in this package to extend.

Breaking Changes

None for spec-compliant clients.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • My code follows the repository's style guidelines
  • New and existing tests pass locally

Requests carrying a session ID the server didn't know (never issued, or
already terminated with DELETE) got 400 "No valid session ID provided".
The transport spec requires 404 here so the client starts a new session;
with 400 a client cannot recover, e.g. after a server restart. Return
404 "Session not found" (as the SDK transport does) for an unknown
session ID, and keep 400 for a missing one.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 19:41
@changeset-bot

changeset-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 386fd9c

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.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

2 participants