Add JSON response mode to Streamable HTTP server#1714
Open
lntutor wants to merge 1 commit into
Open
Conversation
halter73
reviewed
Jul 22, 2026
| /// Request-related notifications and other intermediate messages are not included in the response. Standalone GET | ||
| /// requests continue to use SSE when stateful mode is enabled. | ||
| /// </remarks> | ||
| public bool EnableJsonResponse { get; set; } |
Contributor
There was a problem hiding this comment.
The EnableJsonResponse name and ordinary POST behavior match other SDKs, but those SDKs still permit SSE for cases such as subscriptions/listen or standalone GET. Is that the contract we want, or should this be an explicit mode API like ResponseMode = HttpResponseMode.JsonOnly?
For deployments where intermediaries buffer streaming responses, JsonOnly should mean no SSE anywhere. Ordinary POSTs return JSON, GET returns 405, subscriptions/listen returns a correlated MethodNotFound, and EnableLegacySse is incompatible.
We could add a JsonPreferred mode if the hybrid behavior is valuable, but I suspect disabling SSE entirely is the primary use case. Am I off base here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EnableJsonResponseconfiguration for ASP.NET Core andStreamableHttpServerTransportapplication/jsonwithout SSE framing202 Acceptednotification responses, and standalone GET SSE streamsTesting
dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj --filter FullyQualifiedName~JsonResponseModeTests --no-restore(15 passed across net8.0, net9.0, and net10.0)dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj -f net10.0 --no-restore --filter "(Execution!=Manual)"(512 passed)dotnet test ModelContextProtocol.slnx --configuration Release --no-build --filter "(Execution!=Manual)"(8,454 passed)dotnet build ModelContextProtocol.slnx --configuration Release(36 projects, 0 warnings)dotnet format ModelContextProtocol.slnx --no-restore --verify-no-changes --include ...dotnet docfx docs/docfx.json --warningsAsErrors true(0 warnings)Fixes #545