Repository navigation
Commit a65512b
committed
Answer a method of an undeclared capability with Method not found
## 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.1 parent 0019b4d commit a65512b
3 files changed
Lines changed: 73 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
652 | 660 | | |
653 | 661 | | |
654 | 662 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6047 | 6047 | | |
6048 | 6048 | | |
6049 | 6049 | | |
| 6050 | + | |
| 6051 | + | |
| 6052 | + | |
| 6053 | + | |
| 6054 | + | |
| 6055 | + | |
| 6056 | + | |
| 6057 | + | |
| 6058 | + | |
| 6059 | + | |
| 6060 | + | |
| 6061 | + | |
| 6062 | + | |
| 6063 | + | |
| 6064 | + | |
| 6065 | + | |
| 6066 | + | |
| 6067 | + | |
| 6068 | + | |
| 6069 | + | |
| 6070 | + | |
| 6071 | + | |
| 6072 | + | |
| 6073 | + | |
| 6074 | + | |
| 6075 | + | |
| 6076 | + | |
| 6077 | + | |
| 6078 | + | |
| 6079 | + | |
| 6080 | + | |
| 6081 | + | |
| 6082 | + | |
| 6083 | + | |
| 6084 | + | |
| 6085 | + | |
| 6086 | + | |
| 6087 | + | |
| 6088 | + | |
| 6089 | + | |
| 6090 | + | |
| 6091 | + | |
| 6092 | + | |
| 6093 | + | |
| 6094 | + | |
| 6095 | + | |
| 6096 | + | |
| 6097 | + | |
| 6098 | + | |
6050 | 6099 | | |
6051 | 6100 | | |
6052 | 6101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1880 | 1880 | | |
1881 | 1881 | | |
1882 | 1882 | | |
1883 | | - | |
| 1883 | + | |
| 1884 | + | |
1884 | 1885 | | |
1885 | 1886 | | |
1886 | 1887 | | |
1887 | | - | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
1888 | 1891 | | |
1889 | 1892 | | |
1890 | 1893 | | |
| 1894 | + | |
| 1895 | + | |
1891 | 1896 | | |
1892 | 1897 | | |
1893 | 1898 | | |
| 1899 | + | |
| 1900 | + | |
1894 | 1901 | | |
1895 | 1902 | | |
1896 | 1903 | | |
1897 | | - | |
| 1904 | + | |
1898 | 1905 | | |
1899 | 1906 | | |
| 1907 | + | |
| 1908 | + | |
1900 | 1909 | | |
1901 | 1910 | | |
1902 | 1911 | | |
| |||
0 commit comments