Initial Checks
Description
When a session ID is provided by a client, but it is not present in the in-memory session store for the server, the server returns a 400
| else: |
| # Invalid session ID |
| response=Response( |
| "Bad Request: No valid session ID provided", |
| status_code=HTTPStatus.BAD_REQUEST, |
| ) |
| awaitresponse(scope, receive, send) |
This is a problem, because as noted in #880 sessions are not persisted between restarts
This library should return a 404, as in
So that the client can re-initialize and get a new session ID as needed (as in
https://github.com/mark3labs/mcp-go/blob/8f5b048218f6d044c3322f16b8cb0b08e10bf5d0/client/transport/streamable_http.go#L257).
400 isn't applicable because the request isn't bad, but the server simply doesn't persist sessions between restarts.
Example Code
Python & MCP Python SDK
Initial Checks
Description
When a session ID is provided by a client, but it is not present in the in-memory session store for the server, the server returns a 400
python-sdk/src/mcp/server/streamable_http_manager.py
Lines 250 to 256 in d0443a1
This is a problem, because as noted in #880 sessions are not persisted between restarts
This library should return a 404, as in
python-sdk/src/mcp/server/streamable_http.py
Line 371 in d0443a1
400 isn't applicable because the request isn't bad, but the server simply doesn't persist sessions between restarts.
Example Code
Python & MCP Python SDK