modelcontextprotocol / modelcontextprotocol/typescript-sdk

MCP 1.25 Cursor Second Connection to StreamableHTTPServerTransport Initialization Request Failed

Open
#1,400 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug documentation P3 potentially close question ready for work
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

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:

Image

Disable and Connect Again

Image

Expected behavior
A clear and concise description of what you expected to happen.

I am expecting the Cursor:

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked src/server.ts and reproduce the second Cursor connection using StreamableHTTPServerTransport, comparing MCP SDK 1.24 and 1.25 behavior. Trace the initialize request and session lifecycle around server.connect, using the logged Invalid Request response to define done: reconnecting should succeed without switching to SSE.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.