Skip to content

Add real-IO SSE server transport handshake test#216

Merged
gophergogo merged 2 commits into
mainfrom
feature/mcp-lifecycle-integration-tests
Apr 20, 2026
Merged

Add real-IO SSE server transport handshake test#216
gophergogo merged 2 commits into
mainfrom
feature/mcp-lifecycle-integration-tests

Conversation

@gophergogo
Copy link
Copy Markdown
Collaborator

@gophergogo gophergogo commented Apr 20, 2026

Summary

  • Integration test that exercises the GET /sse → 200 + event: endpoint handshake end-to-end through a socketpair-backed ConnectionImpl and the real HttpSseFilterChainFactory, without standing up a full McpServer.
  • Covers three handshake contracts that PR Add SSE server transport for HTTP+SSE filter chain #215's test plan left unchecked:
    • default handshake advertises a callback URL with a non-empty session id and Content-Type: text/event-stream;
    • external_url is honored in the advertised endpoint (the internal Host header is not leaked through);
    • a configured sse_path is honored for the GET endpoint.
  • Teardown tears the connection and the factory down on the dispatcher thread so ConnectionImpl and SseSessionRegistry thread-affinity asserts hold.

The POST /callback/{id} → 202 → response-through-stream leg of the round-trip is documented as deferred in the test header; it requires either a full McpServer bootstrap or a test-only connection-tracking filter to capture the Connection* from onRequest, and is tracked as a follow-up.

Test plan

  • ctest -R SseTransportRoundTripTest passes
  • Full ctest suite passes (121/121)
  • Follow-up: POST /callback leg of the round-trip

gophergogo added 2 commits April 20, 2026 08:50
Exercises the GET /sse -> 200 + event:endpoint handshake end-to-end
through a socketpair-backed ConnectionImpl and the real
HttpSseFilterChainFactory, without standing up a full McpServer. Covers:

  - default handshake advertises a callback URL with a non-empty
    session id and Content-Type: text/event-stream;
  - external_url is honored in the advertised endpoint (the internal
    Host header is not leaked through);
  - a configured sse_path is honored for the GET endpoint.

The POST /callback/{id} -> 202 -> response-through-stream leg is
documented as deferred in the test header; it requires either a full
McpServer bootstrap or a test-only connection-tracking filter to capture
the Connection* from onRequest, and is tracked as a follow-up.

Teardown tears the connection and the factory down on the dispatcher
thread to satisfy ConnectionImpl and SseSessionRegistry thread-affinity
asserts.
Extends the SSE transport round-trip test with the second leg that PR
separate server connection returns 202 Accepted, and a JSON-RPC response
produced on that POST connection is rerouted by
HttpSseJsonRpcProtocolFilter::onWrite through SseSessionRegistry onto
the original SSE stream — not framed back as HTTP bytes on the POST
socket.

The test runs two ServerConnections over separate socketpairs against a
single shared HttpSseFilterChainFactory, which is the key to exercising
the cross-connection routing: both filter instances share the factory's
SseSessionRegistry, so the POST-side filter can find and write to the
SSE-side connection. No McpServer bootstrap is needed.

A test-only McpProtocolCallbacks emits the response via
connection().write() from onRequest — the same write chain the real
McpServer's JSON-RPC encoder would drive — so the onWrite interception
runs against real JSON-RPC bytes rather than a mocked payload.

Header comment updated to reflect that both legs are now covered.
@gophergogo gophergogo force-pushed the feature/mcp-lifecycle-integration-tests branch from 7d4020b to 81460bf Compare April 20, 2026 16:24
@gophergogo gophergogo merged commit f26f59f into main Apr 20, 2026
1 check passed
gophergogo pushed a commit that referenced this pull request Apr 20, 2026
Exercises the GET /sse -> 200 + event:endpoint handshake end-to-end
through a socketpair-backed ConnectionImpl and the real
HttpSseFilterChainFactory, without standing up a full McpServer. Covers:

  - default handshake advertises a callback URL with a non-empty
    session id and Content-Type: text/event-stream;
  - external_url is honored in the advertised endpoint (the internal
    Host header is not leaked through);
  - a configured sse_path is honored for the GET endpoint.

The POST /callback/{id} -> 202 -> response-through-stream leg is
documented as deferred in the test header; it requires either a full
McpServer bootstrap or a test-only connection-tracking filter to capture
the Connection* from onRequest, and is tracked as a follow-up.

Teardown tears the connection and the factory down on the dispatcher
thread to satisfy ConnectionImpl and SseSessionRegistry thread-affinity
asserts.
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.

2 participants