Skip to content

Add opt-out for Streamable HTTP standalone GET stream#1699

Merged
jeffhandley merged 2 commits into
modelcontextprotocol:mainfrom
jstar0:fix/disable-standalone-streaming
Jul 15, 2026
Merged

Add opt-out for Streamable HTTP standalone GET stream#1699
jeffhandley merged 2 commits into
modelcontextprotocol:mainfrom
jstar0:fix/disable-standalone-streaming

Conversation

@jstar0

@jstar0 jstar0 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #1637.

Summary

Adds HttpClientTransportOptions.EnableStandaloneGetStream (a bool that defaults to true) so Streamable HTTP clients can skip the standalone GET SSE stream when they do not need unsolicited server-to-client messages.

Default behavior is unchanged: the transport opens the standalone GET SSE stream after initialization. Set the option to false to skip it -- the transport no longer starts ReceiveUnsolicitedMessagesAsync() after initialize or when resuming a known session, but direct and streaming responses to client POST requests still work.

Changes

  • Added HttpClientTransportOptions.EnableStandaloneGetStream (default true).
  • Routed Streamable HTTP standalone GET startup through the new option for the initialize and known-session paths.
  • Preserved structured HTTP completion details when AutoDetect adopts Streamable HTTP without opening a standalone GET stream.
  • Added regression coverage for initialize, known-session, POST SSE response behavior, and AutoDetect disposal.
  • Documented the option in the transport and session docs.

Why

Some clients run with constrained HttpClient connection pools. If a server holds the standalone GET stream open, later POSTs can queue behind that long-lived request and initialization can time out. Setting EnableStandaloneGetStream to false gives those clients a narrow opt-out without changing default behavior for clients that rely on unsolicited notifications.

Verification

dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj --framework net10.0 --filter FullyQualifiedName~HttpClientTransportTests --no-restore
dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj --framework net10.0 --no-restore
dotnet build src/ModelContextProtocol.Core/ModelContextProtocol.Core.csproj --no-restore

@jeffhandley jeffhandley requested review from halter73 and tarekgh July 14, 2026 04:10
Comment thread src/ModelContextProtocol.Core/Client/HttpClientTransportOptions.cs Outdated
Comment thread tests/ModelContextProtocol.Tests/Transport/HttpClientTransportTests.cs Outdated
@jstar0 jstar0 force-pushed the fix/disable-standalone-streaming branch from 5c8f473 to 1778312 Compare July 14, 2026 19:39
@jstar0

jstar0 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

The two failing Linux jobs are in unrelated OAuth integration tests: Debug failed in CanAuthenticate_WithAuthorizationServerPathFallbacks, while Release failed in AuthorizationFlow_AllowsOneStepUpEvenWhenChallengeAddsNoNewScope. This PR does not touch the OAuth implementation or tests, macOS and Windows passed, and recent main runs have shown failures in the same OAuth test family.

I do not have permission to rerun the upstream workflow. Could a maintainer rerun the failed jobs? I will leave the transport patch unchanged unless a changed-surface test fails.

Comment thread src/ModelContextProtocol.Core/Client/HttpClientTransportOptions.cs Outdated
- Rename the option to the affirmative EnableStandaloneGetStream with a = true default

- Invert the guard in StartUnsolicitedMessageStreamIfEnabled to check EnableStandaloneGetStream

- Set EnableStandaloneGetStream = false in the four transport tests and rename them to _DisablingStandaloneGetStream_

- Update transports.md and stateless.md to the new name, true default, and affirmative wording

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jeffhandley jeffhandley merged commit 6af05d0 into modelcontextprotocol:main Jul 15, 2026
11 checks passed
@jeffhandley jeffhandley changed the title Add opt-out for Streamable HTTP standalone GET stream Add HttpClientTransportOptions.EnableStandaloneGetStream to opt out of the Streamable HTTP standalone GET stream Jul 15, 2026
@jeffhandley jeffhandley changed the title Add HttpClientTransportOptions.EnableStandaloneGetStream to opt out of the Streamable HTTP standalone GET stream Add opt-out for Streamable HTTP standalone GET stream Jul 15, 2026
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.

Streamable HTTP: no opt-out for standalone SSE GET — handshake deadlocks under connection-pool pressure

4 participants