Skip to content

Session ID not present in memory store should return 404, not 400 #1004

Closed

Description

@sthomson-wyn

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,
)
await response(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

HTTPStatus.NOT_FOUND,
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

3.10.12 and 2.3.4

Activity

  1. added
    bugSomething isn't working
    ready for workEnough information for someone to start working on
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Oct 3, 2025
  2. felixweinberger commented on Oct 3, 2025

    @felixweinberger
    Contributor

    Should be resolved by Stateful Streamable-HTTP: send 404 Not Found on unknown Mcp-Session-Id #1417 if someone comes here we should prioritize reviewing that.

  3. tybalex commented on Nov 4, 2025

    @tybalex

    encountered the same issue.

  4. maxisbey commented on May 18, 2026

    @maxisbey
    Contributor

    Fixed by #1945 (v1.x) and the equivalent change on main — StreamableHTTPSessionManager now returns HTTP 404 for unknown/expired session IDs. This was a duplicate of #1727, which was closed when #1945 merged; this one was missed.

    AI Disclaimer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions