MCP client wrong handling of http.NOT_FOUND in session management (stateful MCP server)

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

MCP client wrong handling of http.NOT_FOUND in session management (stateful MCP server).
When Cursor MCP client receives NOT_FOUND response on request with session_id, it MUST start a new session and it didn’t.

According to MCP spec: Transports - Model Context Protocol

  1. 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.
  2. 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.

Steps to Reproduce

  1. MCP server up and running as stateful streamable-http.
  2. Cursor configured to use the MCP server - initialization OK, tool working
  3. Stop the MCP server and start it again without touching Cursor - simulate network outage, server restart, etc.
  4. In Cursor settings, the MCP indicator turns red
  5. Now, trigger Agent to call the tools, ends with {"error": "Error POSTing to endpoint (HTTP 404): Bad Request: No valid session ID provided"}
  6. Reloading the mcp.json file ends with several requests that gets 404 response

Without OFF/ON the MCP server from Cursor settings, there is no way to establish new session with the MCP server

I used modified python mcp=1.12.1 package: streamable_http_manager.py, line 275 to be sure that after connection terminate, the response on client request with session-id which is not known by the server, server response NOT_FOUND with the session_id.
from:

            response = Response(
                "Bad Request: No valid session ID provided",
                status_code=HTTPStatus.BAD_REQUEST,
            )
            await response(scope, receive, send)

to:

            response = Response(
                "Bad Request: No valid session ID provided",
                status_code=HTTPStatus.NOT_FOUND,
                headers={MCP_SESSION_ID_HEADER: request_mcp_session_id},
            )
            await response(scope, receive, send)

Expected Behavior

When receiving http.NOT_FOUND with session_id, the client MUST start a new session, must send InitializeRequest. This will make the handling of stateful MCP server more robust, more reliable on client-server connection problems

Operating System

Linux

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.6.45
VSCode Version: 1.99.3
Commit: 3ccce8f55d8cca49f6d28b491a844c699b8719a0
Date: 2025-09-22T18:22:38.013Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Linux x64 6.8.0-83-generic

Additional Information

MCP client logs from Cursor->output:

2025-09-24 14:22:26.998 [info] Handling CreateClient action
2025-09-24 14:22:26.998 [info] Creating streamableHttp transport
2025-09-24 14:22:26.998 [info] Connecting to streamableHttp server
2025-09-24 14:22:27.018 [info] No stored tokens found
2025-09-24 14:22:27.043 [info] No stored tokens found
2025-09-24 14:22:27.049 [info] Successfully connected to streamableHttp server
2025-09-24 14:22:27.049 [info] Storing streamableHttp client
2025-09-24 14:22:27.049 [info] CreateClient completed, server stored: true
2025-09-24 14:22:27.055 [info] No stored tokens found
2025-09-24 14:22:33.565 [info] Handling ListOfferings action, server stored: true
2025-09-24 14:22:33.565 [info] Connected to streamableHttp server, fetching offerings
2025-09-24 14:22:33.566 [info] No stored tokens found
2025-09-24 14:22:33.575 [info] No stored tokens found
2025-09-24 14:22:33.586 [info] No stored tokens found
2025-09-24 14:22:33.590 [info] Found 1 tools, 0 prompts, and 0 resources

//Restart MCP server

2025-09-24 14:22:43.496 [error] Client error for command SSE stream disconnected: TypeError: terminated
2025-09-24 14:22:44.498 [info] No stored tokens found
2025-09-24 14:22:44.509 [error] Client error for command fetch failed
2025-09-24 14:22:44.509 [error] Client error for command Failed to reconnect SSE stream: fetch failed
2025-09-24 14:22:46.011 [info] No stored tokens found
2025-09-24 14:22:46.015 [error] Client error for command fetch failed
2025-09-24 14:22:46.015 [error] Client error for command Failed to reconnect SSE stream: fetch failed
2025-09-24 14:22:46.015 [error] Client error for command Maximum reconnection attempts (2) exceeded.

//Trigger to Call tool

2025-09-24 14:23:08.097 [info] Handling CallTool action for tool 'nordic_pr_analyzer'
2025-09-24 14:23:08.097 [info] Calling tool 'nordic_pr_analyzer' with toolCallId: tool_ddaec993-ff17-4e81-9fd3-1c531e8920b
2025-09-24 14:23:08.100 [info] No stored tokens found
2025-09-24 14:23:08.106 [error] Client error for command Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:08.106 [error] Error calling tool 'nordic_pr_analyzer': Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:18.466 [info] Handling CreateClient action
2025-09-24 14:23:18.467 [info] CreateClient completed, server stored: true
2025-09-24 14:23:18.486 [info] Handling CreateClient action
2025-09-24 14:23:18.486 [info] CreateClient completed, server stored: true


//Reload mcp.json (make small change in the file and save)

2025-09-24 14:23:31.073 [info] Handling ListOfferings action, server stored: true
2025-09-24 14:23:31.074 [info] Connected to streamableHttp server, fetching offerings
2025-09-24 14:23:31.074 [info] No stored tokens found
2025-09-24 14:23:31.077 [error] Client error for command Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:31.077 [error] Error listing tools: Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:31.087 [info] No stored tokens found
2025-09-24 14:23:31.090 [error] Client error for command Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:31.090 [error] Error listing prompts: Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:31.092 [info] No stored tokens found
2025-09-24 14:23:31.097 [error] Client error for command Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:31.097 [error] Error listing resources: Error POSTing to endpoint (HTTP 400): Bad Request: No valid session ID provided
2025-09-24 14:23:31.097 [info] Found 0 tools, 0 prompts, and 0 resources
...

//Turn OFF and ON of the MCP server from Cursor settings

2025-09-24 14:23:40.041 [info] Handling DeleteClient action
2025-09-24 14:23:40.042 [info] Cleaning up
2025-09-24 14:23:41.498 [info] Handling CreateClient action
2025-09-24 14:23:41.498 [info] Creating streamableHttp transport
2025-09-24 14:23:41.498 [info] Connecting to streamableHttp server
2025-09-24 14:23:41.504 [info] No stored tokens found
2025-09-24 14:23:41.521 [info] No stored tokens found
2025-09-24 14:23:41.525 [info] Successfully connected to streamableHttp server
2025-09-24 14:23:41.525 [info] Storing streamableHttp client
2025-09-24 14:23:41.525 [info] CreateClient completed, server stored: true
2025-09-24 14:23:41.527 [info] No stored tokens found
2025-09-24 14:23:47.919 [info] Handling ListOfferings action, server stored: true
2025-09-24 14:23:47.919 [info] Connected to streamableHttp server, fetching offerings
2025-09-24 14:23:47.920 [info] No stored tokens found
2025-09-24 14:23:47.936 [info] No stored tokens found
2025-09-24 14:23:47.941 [info] No stored tokens found
2025-09-24 14:23:47.947 [info] Found 1 tools, 0 prompts, and 0 resources

Does this stop you from using Cursor

No - Cursor works, but with this issue

3 Likes

Hey, thanks for the report, we’ll look into it.

seeing the same issue this is breaking hosted MCP servers for me

2 Likes

Yeah I’m also seeing this, we have to continuously turn the MCP server off and on or quit and restart Cursor to get it working.