Skip to content

Fix invalid initialize request handling - #1709

Open
lntutor wants to merge 1 commit into
modelcontextprotocol:mainfrom
lntutor:fix/invalid-initialize-params-788
Open

Fix invalid initialize request handling#1709
lntutor wants to merge 1 commit into
modelcontextprotocol:mainfrom
lntutor:fix/invalid-initialize-params-788

Conversation

@lntutor

@lntutor lntutor commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • validate initialize request parameters before creating an HTTP session
  • return HTTP 400 with JSON-RPC InvalidParams and the original request ID
  • cover a missing clientInfo.version payload

Testing

  • dotnet build
  • ASP.NET Core test suite on net8.0, net9.0, and net10.0

Fixes #788

Comment thread src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs Outdated
@lntutor

lntutor commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and resolved the StreamableHttpHandler conflict by preserving both protocol paths: July 2026 initialize requests still return the required removed-method 404, while older-protocol initialization retains invalid-parameter validation. The focused regression set passes (24 tests), and the complete ModelContextProtocol.AspNetCore.Tests project passes locally across .NET 8, 9, and 10. @PranavSenthilnathan, could you re-review when convenient?

@lntutor

lntutor commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Current head 77b5d6b00a01a760bf41a3b9c3ba09fc8120142a is mergeable, the review decision is APPROVED, and the visible CI surface on this exact SHA is fully green: CodeQL, all Debug/Release build-and-test jobs on Ubuntu, macOS, and Windows, and publish-coverage all completed successfully. The current branch already carries the rebase conflict resolution and focused regression coverage noted earlier, so this looks ready for maintainer merge when convenient.

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.

Passing a malformed body throws a 500 error instead of 400. Very hard to figure out what is incorrect in the request being issued by the caller

3 participants