Skip to content

Add option to disable standalone SSE stream - #1080

Open
arnabnandy7 wants to merge 1 commit into
modelcontextprotocol:mainfrom
arnabnandy7:fix/disable-standalone-sse
Open

Add option to disable standalone SSE stream#1080
arnabnandy7 wants to merge 1 commit into
modelcontextprotocol:mainfrom
arnabnandy7:fix/disable-standalone-sse

Conversation

@arnabnandy7

@arnabnandy7 arnabnandy7 commented Aug 7, 2026

Copy link
Copy Markdown

Adds an openSseStream(boolean) option to HttpClientStreamableHttpTransport.Builder, allowing clients to disable standalone GET SSE connections and operate using POST request-response flows only.

Motivation and Context

The Streamable HTTP specification makes the standalone GET SSE stream optional, but the transport previously opened one automatically after session initialization.

This meant openConnectionOnStartup(false) could prevent the initial eager connection but could not prevent the GET request triggered by the first successful POST response.

When openSseStream(false) is configured:

  • No GET request is made during connect().
  • No GET request is made after session initialization.
  • POST responses, including SSE-formatted POST responses, remain supported.
  • Server-initiated messages outside POST response streams are not received.

The existing behavior remains the default.

Fixes #1068.

How Has This Been Tested?

Added a regression test covering both standalone SSE connection paths:

  • Eager connection with openConnectionOnStartup(true).
  • Automatic connection after receiving a session ID from a POST response.

The test verifies that the POST request succeeds while no GET request is issued.

Automated tests have not been run locally.

Breaking Changes

No breaking changes. openSseStream defaults to true, preserving the existing transport behavior.

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

The new option controls only the standalone SSE stream established with an HTTP GET request. It does not disable processing SSE responses returned from HTTP POST requests.

The option defaults to enabled to maintain backward compatibility:

var transport = HttpClientStreamableHttpTransport.builder("https://example.com")
    .openSseStream(false)
    .build();

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
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.

Disable standalone GET SSE Stream option for Streamable HTTP client transport

1 participant