Title: Unknown methods return -32602 Invalid params instead of -32601 Method not found · Issue #3193 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Unknown methods return -32602 Invalid params instead of -32601 Method not found · Issue #3193 · modelcontextprotocol/python-sdk
X Title: Unknown methods return -32602 Invalid params instead of -32601 Method not found · Issue #3193 · modelcontextprotocol/python-sdk
Description: A server built on this SDK answers every unknown JSON-RPC method with -32602 Invalid request parameters, where JSON-RPC 2.0 requires -32601 Method not found. Why it matters Catalogue scanners probe for optional capabilities and read the ...
Open Graph Description: A server built on this SDK answers every unknown JSON-RPC method with -32602 Invalid request parameters, where JSON-RPC 2.0 requires -32601 Method not found. Why it matters Catalogue scanners probe...
X Description: A server built on this SDK answers every unknown JSON-RPC method with -32602 Invalid request parameters, where JSON-RPC 2.0 requires -32601 Method not found. Why it matters Catalogue scanners probe...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3193
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unknown methods return -32602 Invalid params instead of -32601 Method not found","articleBody":"A server built on this SDK answers **every** unknown JSON-RPC method with `-32602 Invalid request parameters`, where JSON-RPC 2.0 requires `-32601 Method not found`.\n\n## Why it matters\n\nCatalogue scanners probe for optional capabilities and read the error code to decide whether a method is unsupported or genuinely malformed. Smithery, scanning our production server, logged:\n\n```\nWarning: Failed to list triggers: MCP error -32602: Invalid request parameters\n```\n\n`-32602` reads as \"you called it wrong\", so the sensible client behaviour is to retry with different parameters — but no parameters will ever work, because the method does not exist. `-32601` is the answer that lets a client move on.\n\n## Reproduction\n\nAgainst any server on this SDK, after `initialize` + `notifications/initialized`:\n\n```json\n{\"jsonrpc\":\"2.0\",\"id\":9,\"method\":\"totally/bogus\"}\n```\n\nResponse:\n\n```json\n{\"jsonrpc\":\"2.0\",\"id\":9,\"error\":{\"code\":-32602,\"message\":\"Invalid request parameters\",\"data\":\"\"}}\n```\n\nSame code for `triggers/list`, `completions/complete` and `logging/setLevel` on a server that declares none of those capabilities — the four are indistinguishable from a genuine schema violation.\n\n## Cause\n\nIn `mcp/shared/session.py`, `self._receive_request_type.model_validate(...)` raises for a method outside the request union, and the surrounding `except Exception` maps everything to `INVALID_PARAMS`:\n\n```python\nexcept Exception as e:\n # For request validation errors, send a proper JSON-RPC error\n # response instead of crashing the server\n logging.warning(f\"Failed to validate request: {e}\")\n error_response = JSONRPCError(\n ...\n error=ErrorData(code=INVALID_PARAMS, message=\"Invalid request parameters\", data=\"\"),\n )\n```\n\nThe comment is accurate for its original purpose — the union is just doing double duty as a method registry, so \"method I do not have\" and \"parameters I cannot parse\" arrive at the same handler.\n\n## Suggested fix\n\nDistinguish the two before building the error: if `message.message.root.method` is not among the known request methods, answer `METHOD_NOT_FOUND` and keep `INVALID_PARAMS` for a known method that fails validation. Populating `data` with the validation error would also help — it is currently an empty string, so the response carries no diagnostic at all.\n\nHappy to open a PR if the approach looks right.\n\nObserved on `mcp` 1.27.1, Python 3.14.","author":{"url":"https://github.com/borisowvalia","@type":"Person","name":"borisowvalia"},"datePublished":"2026-07-27T21:51:02Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3193"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5422a454-c137-3b37-e78d-ed49cc729cee |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E302:25C00B:310D727:405E98D:6B0575C2 |
| html-safe-nonce | 747aabf1e649ba4b7a01e5968397466d3bffe24d749822e2675489b25a4591aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzAyOjI1QzAwQjozMTBENzI3OjQwNUU5OEQ6NkIwNTc1QzIiLCJ2aXNpdG9yX2lkIjoiNjIzMTQ0Nzk3NzE2MTIyNTY2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 79e0bb2c0a969f07f0dcc4d6ba5a8032d084da929812de74346518086f23fdb7 |
| hovercard-subject-tag | issue:4992630215 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3193/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a3a471c471289af04f51f9394315c636a01455a3c0b06e66f306fe064bfe8a9/modelcontextprotocol/python-sdk/issues/3193 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a3a471c471289af04f51f9394315c636a01455a3c0b06e66f306fe064bfe8a9/modelcontextprotocol/python-sdk/issues/3193 |
| og:image:alt | A server built on this SDK answers every unknown JSON-RPC method with -32602 Invalid request parameters, where JSON-RPC 2.0 requires -32601 Method not found. Why it matters Catalogue scanners probe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | borisowvalia |
| hostname | github.com |
| expected-hostname | github.com |
| None | 507b2d62524c0f595c35a2a2ee8a6ec54b119f245b3c59eaa070013b70ed1ada |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e7a883ae3b439b8952652eaa7803e2587f30e339 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width