modelcontextprotocol / modelcontextprotocol/python-sdk

MCP client doesn't not initialize new session when getting 404 session not found

Open
#1,676 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug improves spec compliance P2 ready for work
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

Initial Checks
Description

Per https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#session-management

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.

This is not the case with the python client. It just sends a session terminated error in streamable_http.py

Example Code

Python & MCP Python SDK
mcp: 1.22.0
python: 3.14.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/mcp/client/streamable_http.py around line 277, where a 404 response containing an MCP-Session-Id is handled, and compare that behavior with the session-management requirement linked in the issue. Trace the client’s initialization entry point and verify the completed behavior by exercising a 404 response: the client should send a new InitializeRequest without a session ID instead of returning a session-terminated error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.