Skip to content

Add JSON response mode to Streamable HTTP server - #1714

Open
lntutor wants to merge 1 commit into
modelcontextprotocol:mainfrom
lntutor:feat/json-only-545
Open

Add JSON response mode to Streamable HTTP server#1714
lntutor wants to merge 1 commit into
modelcontextprotocol:mainfrom
lntutor:feat/json-only-545

Conversation

@lntutor

@lntutor lntutor commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add opt-in EnableJsonResponse configuration for ASP.NET Core and StreamableHttpServerTransport
  • return the final correlated JSON-RPC response directly as application/json without SSE framing
  • omit intermediate request-related messages and POST event-store writes in JSON mode
  • preserve default SSE behavior, empty 202 Accepted notification responses, and standalone GET SSE streams
  • reject polling when JSON responses are enabled and document the transport tradeoffs

Testing

  • 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

Comment thread src/ModelContextProtocol.AspNetCore/HttpServerTransportOptions.cs
@lntutor
lntutor force-pushed the feat/json-only-545 branch from 755707a to ac91aad Compare July 26, 2026 06:44
@jeffhandley jeffhandley added this to the 2.x milestone Jul 27, 2026
@lntutor
lntutor force-pushed the feat/json-only-545 branch from ac91aad to 3f89cf6 Compare July 30, 2026 15:51
@lntutor

lntutor commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and resolved the transport conflicts by preserving both JSON-only responses and the July 2026 HTTP status mapping. Added a regression proving an unknown July 2026 method returns HTTP 404 with an application/json JSON-RPC error in JSON response mode; it fails without the response-start callback and passes with the merged implementation across .NET 8, 9, and 10. The complete ModelContextProtocol.AspNetCore.Tests project also passes locally.

@lntutor
lntutor force-pushed the feat/json-only-545 branch from 3f89cf6 to 4a48b52 Compare July 30, 2026 16:32
@lntutor
lntutor force-pushed the feat/json-only-545 branch from 4a48b52 to cb711d3 Compare July 30, 2026 16:53
@lntutor

lntutor commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Fresh verification on cb711d3 is fully green: Ubuntu, macOS, and Windows Debug/Release build-and-test jobs all passed; coverage publication, CodeQL, and markdown-link-check also passed. The prior Windows Debug failure and link 502 did not recur. Ready for review.

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.

Support a non-SSE JSON-only mode similar to the TypeScript SDKs enableJsonResponse: true

3 participants