Skip to content

test_streaming_elicitation: use proper SSE instead of NDJSON#392

Open
howardjohn wants to merge 2 commits into
modelcontextprotocol:mainfrom
howardjohn:server/proper-sse
Open

test_streaming_elicitation: use proper SSE instead of NDJSON#392
howardjohn wants to merge 2 commits into
modelcontextprotocol:mainfrom
howardjohn:server/proper-sse

Conversation

@howardjohn

Copy link
Copy Markdown

Motivation and Context

NDJSON is not acceptable in the spec.

Before:

$ curl -iN --max-time 5 -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -H 'MCP-Protocol-Version: 2026-07-28' -H 'Mcp-Method: tools/call' -H 'Mcp-Name: test_streaming_elicitation' --data '{
      "jsonrpc":"2.0",
      "id":1,
      "method":"tools/call",
      "params":{
        "name":"test_streaming_elicitation",
        "arguments":{},
        "_meta":{
          "io.modelcontextprotocol/protocolVersion":"2026-07-28",
          "io.modelcontextprotocol/clientInfo":{"name":"conformance-client","version":"1.0.0"},
          "io.modelcontextprotocol/clientCapabilities":{}
        }
      }
    }' http://localhost:3001/mcp
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Mcp-Session-Id
Content-Type: application/json
Transfer-Encoding: chunked
Date: Mon, 06 Jul 2026 16:30:12 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"jsonrpc":"2.0","method":"notifications/progress","params":{"progressToken":"token-abc","total":100,"value":50}}
{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"Streaming complete"}]}}

After:

$ curl -iN --max-time 5 -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -H 'MCP-Protocol-Version: 2026-07-28' -H 'Mcp-Method: tools/call' -H 'Mcp-Name: test_streaming_elicitation' --data '{
      "jsonrpc":"2.0",
      "id":1,
      "method":"tools/call",
      "params":{
        "name":"test_streaming_elicitation",
        "arguments":{},
        "_meta":{
          "io.modelcontextprotocol/protocolVersion":"2026-07-28",
          "io.modelcontextprotocol/clientInfo":{"name":"conformance-client","version":"1.0.0"},
          "io.modelcontextprotocol/clientCapabilities":{}
        }
      }
    }' http://localhost:3001/mcp
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Mcp-Session-Id
Content-Type: text/event-stream
Cache-Control: no-cache
Date: Mon, 06 Jul 2026 16:32:49 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

event: message
data: {"jsonrpc":"2.0","method":"notifications/progress","params":{"progressToken":"token-abc","total":100,"value":50}}

event: message
data: {"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"Streaming complete"}]}}

How Has This Been Tested?

curl above + running the server through a real client that rejected the invalid NDJSON

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

NDJSON is not acceptable in the spec.

Before:

```
$ curl -iN --max-time 5 -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -H 'MCP-Protocol-Version: 2026-07-28' -H 'Mcp-Method: tools/call' -H 'Mcp-Name: test_streaming_elicitation' --data '{
      "jsonrpc":"2.0",
      "id":1,
      "method":"tools/call",
      "params":{
        "name":"test_streaming_elicitation",
        "arguments":{},
        "_meta":{
          "io.modelcontextprotocol/protocolVersion":"2026-07-28",
          "io.modelcontextprotocol/clientInfo":{"name":"conformance-client","version":"1.0.0"},
          "io.modelcontextprotocol/clientCapabilities":{}
        }
      }
    }' http://localhost:3001/mcp
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Mcp-Session-Id
Content-Type: application/json
Transfer-Encoding: chunked
Date: Mon, 06 Jul 2026 16:30:12 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"jsonrpc":"2.0","method":"notifications/progress","params":{"progressToken":"token-abc","total":100,"value":50}}
{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"Streaming complete"}]}}
```

After:

```
$ curl -iN --max-time 5 -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -H 'MCP-Protocol-Version: 2026-07-28' -H 'Mcp-Method: tools/call' -H 'Mcp-Name: test_streaming_elicitation' --data '{
      "jsonrpc":"2.0",
      "id":1,
      "method":"tools/call",
      "params":{
        "name":"test_streaming_elicitation",
        "arguments":{},
        "_meta":{
          "io.modelcontextprotocol/protocolVersion":"2026-07-28",
          "io.modelcontextprotocol/clientInfo":{"name":"conformance-client","version":"1.0.0"},
          "io.modelcontextprotocol/clientCapabilities":{}
        }
      }
    }' http://localhost:3001/mcp
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Mcp-Session-Id
Content-Type: text/event-stream
Cache-Control: no-cache
Date: Mon, 06 Jul 2026 16:32:49 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

event: message
data: {"jsonrpc":"2.0","method":"notifications/progress","params":{"progressToken":"token-abc","total":100,"value":50}}

event: message
data: {"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"Streaming complete"}]}}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant