Skip to content

Answer a method of an undeclared capability with Method not found - #611

Open
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:answer_an_undeclared_capability_with_method_not_found
Open

koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:answer_an_undeclared_capability_with_method_not_found

Conversation

@koic

@koic koic commented Oct 15, 2026

Copy link
Copy Markdown
Member

Motivation and Context

A request for a method whose capability the server does not declare, such as prompts/list on a server declaring only tools, is answered with -32603 Internal error (issue #602). To a client that reads as a crash, while the server merely has no such method: the TypeScript and Python servers answer -32601 Method not found for a handler they never registered, and the Streamable HTTP transport of 2026-07-28 has the server answer a method it does not implement with 404 Not Found and -32601, which this transport already does for an unknown method but not for this one.

Server#handle_request now re-raises Methods::MissingRequiredCapabilityError as -32601 Method not found, keeping the capability it names in the error data, so the modern transport answers 404 as for any other method it lacks.

Fixes #602.

How Has This Been Tested?

test/mcp/server_test.rb (the three capability tests now check the code and message) and new tests in test/mcp/server/transports/streamable_http_transport_test.rb for both lifecycles. Against the previous library they fail with -32603, the modern one also with a 200.

Breaking Changes

A client that matched the -32603 of an undeclared capability's method sees -32601 now, and a 404 instead of a 200 on the modern lifecycle. The error data text is unchanged.

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

@koic
koic force-pushed the answer_an_undeclared_capability_with_method_not_found branch from 7e42f58 to e48d890 Compare October 15, 2026 08:08
## Motivation and Context

A request for a method whose capability the server does not declare, such as `prompts/list` on a server declaring only `tools`,
is answered with `-32603` Internal error (issue modelcontextprotocol#602). To a client that reads as a crash, while the server merely has no such method:
the TypeScript and Python servers answer `-32601` Method not found for a handler they never registered,
and the Streamable HTTP transport of 2026-07-28 has the server answer a method it does not implement with `404 Not Found` and `-32601`,
which this transport already does for an unknown method but not for this one.

`Server#handle_request` now re-raises `Methods::MissingRequiredCapabilityError` as `-32601` Method not found,
keeping the capability it names in the error `data`, so the modern transport answers 404 as for any other method it lacks.

Fixes modelcontextprotocol#602.

## How Has This Been Tested?

`test/mcp/server_test.rb` (the three capability tests now check the code and message) and new tests in
`test/mcp/server/transports/streamable_http_transport_test.rb` for both lifecycles. Against the previous library
they fail with `-32603`, the modern one also with a 200.

## Breaking Changes

A client that matched the `-32603` of an undeclared capability's method sees `-32601` now, and a 404 instead of
a 200 on the modern lifecycle. The error `data` text is unchanged.
@koic
koic force-pushed the answer_an_undeclared_capability_with_method_not_found branch from e48d890 to a65512b Compare October 15, 2026 08:23

This branch has not been deployed

No deployments
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.

Methods of undeclared capabilities return -32603 instead of -32601

2 participants