Skip to content

Fix error behavior on unregistered handlers in stateless server handler#800

Open
maff wants to merge 1 commit intomodelcontextprotocol:mainfrom
maff:fix-stateless-server-unregistered-handler-behavior
Open

Fix error behavior on unregistered handlers in stateless server handler#800
maff wants to merge 1 commit intomodelcontextprotocol:mainfrom
maff:fix-stateless-server-unregistered-handler-behavior

Conversation

@maff
Copy link

@maff maff commented Feb 16, 2026

When a client requests a resource without a registered handler despite a stateless server not advertising it, the server now returns with a JSON-RPC method not found error (-32601), aligned with the stateful implementation.

Motivation and Context

Closes issue #784

How Has This Been Tested?

Integration test covering unregistered handler response with stateless transport.

Breaking Changes

Behavioral change to return a proper JSON-RPC error instead of a HTTP 500 response. Breaking only in terms of changed behavior in case of an error.

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

Instead of throwing an McpError, it now returns with a JSON-RPC method not found error (-32601), aligned with the stateful implementation.
@maff maff force-pushed the fix-stateless-server-unregistered-handler-behavior branch from caf8474 to 3ac4484 Compare February 16, 2026 19:40
HttpResponse<String> response;

try {
HttpRequest request = HttpRequest.newBuilder()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Not using the MCP client here as it would throw a client error due to missing capabilities advertised in initialization response.

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.

1 participant