Skip to content

StreamableHttpClientTransport fails when server uses JSON-only #308

@devcrocod

Description

@devcrocod

Describe the bug
The StreamableHttpClientTransport client violates the MCP specification when connecting to servers that don't support SSE and only use JSON responses

To Reproduce
Steps to reproduce the behavior:

  1. Client sends POST initialize request
  2. Server responds with 200 OK, Content-Type: application/json
  3. Client sends POST notifications/initialized
  4. Server responds with 202 Accepted
  5. Client attempts GET request to open SSE stream
  6. Server responds with 200 OK, Content-Type: application/json (or 405 Method Not Allowed)
  7. Client throws SSEClientException instead of gracefully handling JSON-only mode

Expected behavior

  1. If the input contains any number of JSON-RPC requests, the server MUST either return Content-Type: text/event-stream, to initiate an SSE stream, or Content-Type: application/json, to return one JSON object. The client MUST support both these cases.
    spec

Additional context
The startSseSession() method doesn't handle the case where the server returns application/json instead of
text/event-stream, which is a valid response indicating the server operates in JSON-only mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions