Skip to content

SSE Example Fails to Run - GET Requests Not Initialized Properly #376

Open
@Hooper93

Description

@Hooper93

Description:​​

I'm trying to run the SSE example from the official documentation, but encountering issues when making GET requests for SSE connections. The stdio example works fine, but the SSE implementation seems to have initialization problems.

​​Steps to Reproduce:​​

  • Cloned the repository and copied examples from src/examples/server
  • Ran simpleStatelessStreamableHttp.ts MCP server
  • Started MCPI using npx @modelcontextprotocol/inspector
  • Attempted to connect via SSE by making a GET request to http://localhost:3000/mcp
    ​​

Expected Behavior:​​

The SSE connection should establish successfully and stream data as described in the documentation.

Actual Behavior:​​

browser shows 500
and MCPI console show error:

400 - Error in /sse route: SseError: SSE error: Non-200 status code (400)

SSE transport: url=http://localhost:3000/mcp, headers=Accept
Error in /sse route: SseError: SSE error: Non-200 status code (400)
    at _eventSource.onerror (file:///Users/dxm/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:69:31)
    at EventSource.failConnection_fn (file:///Users/dxm/.npm/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:234:53)
    at file:///Users/dxm/.npm/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:76:74
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 400,
  event: {
    type: 'error',
    message: 'Non-200 status code (400)',
    code: 400,
    defaultPrevented: false,
    cancelable: false,
    timeStamp: 111063.962667
  }
}

Investigation Findings:​​

In transport.handleRequest, when the request method is GET, this._initialized is never set
Initialization appears to require a POST request first, seems like this issue
but: transport doesn't expose handlePostMessage publicly
No clear way to perform this initialization step

Similar issue occurs when trying to use the server with Cursor - it fails to recognize the MCP server
​​

Additional Context:​​

BUT The stdio example works correctly

Could you clarify if I'm missing a configuration step or if MCPI requires special parameters to support GET request initialization for SSE? The documentation doesn't mention any required setup for this scenario

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions