FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Return METHOD_NOT_FOUND for invalid request methods by raashish1601 · Pull Request #2372 · modelcontextprotocol/python-sdk · GitHub

Return METHOD_NOT_FOUND for invalid request methods - #2372

Closed
raashish1601 wants to merge 1 commit into
modelcontextprotocol:mainfrom
raashish1601:contributor-26/python-sdk-1561
Closed

Return METHOD_NOT_FOUND for invalid request methods#2372
raashish1601 wants to merge 1 commit into
modelcontextprotocol:mainfrom
raashish1601:contributor-26/python-sdk-1561

Conversation

Copy link
Copy Markdown

Fixes #1561.

Summary

  • return METHOD_NOT_FOUND for unknown JSON-RPC request methods instead of collapsing them into the generic request-validation INVALID_PARAMS fallback
  • keep INVALID_PARAMS for malformed known methods by only special-casing method names that are outside the typed client request union
  • add a focused regression proving invalid/method returns -32601 while malformed initialize still returns -32602

Testing

  • PYTHONPATH=src python -m pytest -o addopts="" tests/issues/test_1561_invalid_method_names.py -q
  • python -m ruff check src/mcp/shared/session.py src/mcp/server/session.py tests/issues/test_1561_invalid_method_names.py
  • git diff --check

Copy link
Copy Markdown
Contributor

Thanks for the PR. This has since landed via #2836. Closing as part of a general backlog cleanup following the v2 release. If this is still relevant against v2, feel free to reopen.

AI Disclaimer

maxisbey closed this Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Invalid method names return error code -32602 instead of -32601

2 participants


Back | FazBrowse Home | New Git URL