Skip to content

Change error response status from 400 to 404 for invalid sessions#2690

Draft
tmshkr wants to merge 1 commit into
modelcontextprotocol:mainfrom
tmshkr:fix-invalid-session-response-status
Draft

Change error response status from 400 to 404 for invalid sessions#2690
tmshkr wants to merge 1 commit into
modelcontextprotocol:mainfrom
tmshkr:fix-invalid-session-response-status

Conversation

@tmshkr
Copy link
Copy Markdown

@tmshkr tmshkr commented May 6, 2026

Changes the error status code from 400 to 404 in the documentation's TypeScript example.

Motivation and Context

The error status code returned by the server should be 404, not 400, so that the client starts a new session.

When a client receives HTTP 404 in response to a request containing an MCP-Session-Id, it MUST start a new session by sending a new InitializeRequest without a session ID attached.

https://modelcontextprotocol.io/specification/draft/basic/transports#session-management

How Has This Been Tested?

Tested with Claude. Claude returns an error when receiving a 400 status code error after sending an invalid MCP-Session-Id, but with the 404 status code, it initializes a new session, as it should.

Breaking Changes

No breaking changes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@tmshkr tmshkr requested review from a team as code owners May 6, 2026 05:47
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 6, 2026
@tmshkr tmshkr marked this pull request as draft May 6, 2026 16:05
@tmshkr tmshkr force-pushed the fix-invalid-session-response-status branch from e28dd2d to 9a3e03f Compare May 6, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant