-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
I am using cursor to connect to my Node StreamableHTTPServer and cursor succeed to connect to the server
the first time. But If I disable the MCP server and connect again, It's hanging there and failed to fetch. I read some docs and it's related to how MCP 1.25 is handling Cursor ' second initialize request and failed to respond. which is not the same StreamingHttpServer and it's working for MCP 1.24.
To Reproduce
Steps to reproduce the behavior:
Locally: Source Code is https://github.com/AI-Hub-Admin/fortune-compass-agent. It can be reproduced the same error logs
Live URL also failed after I update MCP sdk from 1.24 to 1.25, url is https://derekzz.aiagenta2z.com/fortune-compass-agent/mcp deployed at the AI Agent A2Z Web Host
First Time Connect:
Disable and Connect Again
Expected behavior
A clear and concise description of what you expected to happen.
I am expecting the Cursor:
- disable and connect again: The StreamableHttpServer can handle the second initialze request ({"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request: Server already initialized"},"id":null}) and maybe you have better ways to handle. Please give me and example.
- I don't want to switch to default SSE mode.
After ChatGPT, Gemin, it seems like the key is MCP 1.25 ways to initialize the Server Once and didn't allow Client to send intialize again.
https://github.com/AI-Hub-Admin/fortune-compass-agent/blob/main/src/server.ts
const transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
onsessioninitialized: (sid) => {
console.log("[mcp] Session initialized:", sid);
},
onsessionclosed: (sid) => {
console.log("[mcp] Session closed:", sid);
},
});
// await server.connect(transport);
await server.connect(transport);
console.log("[mcp] MCP server connected");
Logs
If applicable, add logs to help explain your problem.
First Successfuly Cursor Log
2026-01-17 11:45:00.312 [info] Handling CreateClient action
2026-01-17 11:45:00.312 [info] Creating streamableHttp transport
2026-01-17 11:45:00.327 [info] Connecting to streamableHttp server
2026-01-17 11:45:00.335 [info] No stored tokens found
2026-01-17 11:45:00.365 [info] No stored tokens found
2026-01-17 11:45:00.373 [info] Successfully connected to streamableHttp server
2026-01-17 11:45:00.373 [info] Storing streamableHttp client
2026-01-17 11:45:00.373 [info] CreateClient completed, server stored: true
2026-01-17 11:45:00.373 [info] No stored tokens found
2026-01-17 11:45:00.377 [info] No stored tokens found
2026-01-17 11:45:00.401 [info] No stored tokens found
2026-01-17 11:45:03.710 [info] Handling ListOfferings action, server stored: true
2026-01-17 11:45:03.711 [info] Connected to streamableHttp server, fetching offerings
2026-01-17 11:45:03.711 [info] No stored tokens found
2026-01-17 11:45:03.723 [info] listOfferings: Found 1 tools
2026-01-17 11:45:03.724 [info] No stored tokens found
2026-01-17 11:45:03.730 [info] listResources: Found 1 resources
2026-01-17 11:45:03.731 [info] Found 1 tools, 0 prompts, and 1 resources
Second Failture Connection Log
2026-01-17 11:45:53.542 [info] Handling CreateClient action
2026-01-17 11:45:53.544 [info] Creating streamableHttp transport
2026-01-17 11:45:53.558 [info] Connecting to streamableHttp server
2026-01-17 11:45:53.559 [info] No stored tokens found
2026-01-17 11:45:53.568 [error] Client error for command Streamable HTTP error: Error POSTing to endpoint: {"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request: Server already initialized"},"id":null}
2026-01-17 11:45:53.568 [info] Client closed for command
2026-01-17 11:45:53.568 [warning] Error connecting to streamableHttp server, falling back to SSE: Streamable HTTP error: Error POSTing to endpoint: {"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request: Server already initialized"},"id":null}
2026-01-17 11:45:53.568 [warning] Error connecting to streamableHttp server, falling back to SSE: Streamable HTTP error: Error POSTing to endpoint: {"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request: Server already initialized"},"id":null}
2026-01-17 11:45:53.569 [info] Connecting to SSE server
2026-01-17 11:45:53.580 [info] No stored tokens found
2026-01-17 11:45:53.583 [error] Client error for command SSE error: Non-200 status code (400)
2026-01-17 11:45:53.584 [error] Error connecting to SSE server after fallback: SSE error: Non-200 status code (400)
2026-01-17 11:45:53.584 [info] Client closed for command
These are the headers I connect
Additional context
Add any other context about the problem here.