Skip to content

Session reset upon server restart #106

Open
@shrikrishnaholla

Description

@shrikrishnaholla

The spec for session management states

The server MAY terminate the session at any time, after which it MUST respond to requests containing that session ID with HTTP 404 Not Found.
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.

So I've configured my MCP server to throw a 404 when session id is not found (for instance if the MCP server restarts and the in-memory map of session ids is lost). However, mcp-remote doesn't seem to be handling this gracefully, as I see the following logs in the client, when it tries to continue using the now-stale session id.

[526630] [Local→Remote] tools/call
[526630] Error from remote server: Error: Error POSTing to endpoint (HTTP 404): {"jsonrpc":"2.0","error":{"code":-32001,"message":"Session not found"},"id":null}
    at StreamableHTTPClientTransport.send (file:///home/shrikrishna/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-FBGYN3F2.js:13029:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
[526630] Error from remote server: Error: Error POSTing to endpoint (HTTP 404): {"jsonrpc":"2.0","error":{"code":-32001,"message":"Session not found"},"id":null}
    at StreamableHTTPClientTransport.send (file:///home/shrikrishna/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-FBGYN3F2.js:13029:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Instead of crashing like this, as per the spec, the client should be re-initializing the session.

Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions