Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
@sthomson-wyn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions