GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Unknown methods return -32602 Invalid params instead of -32601 Method not found · Issue #3193 · modelcontextprotocol/python-sdk

Unknown methods return -32602 Invalid params instead of -32601 Method not found #3193

New issue
Copy link
New issue
Copy link
Closed
Closed
Unknown methods return -32602 Invalid params instead of -32601 Method not found#3193
Copy link
Labels
v1Affects the v1.x maintenance lineAffects the v1.x maintenance line

Description

@borisowvalia
borisowvalia
opened on Jul 27, 2026
Issue body actions

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 error code to decide whether a method is unsupported or genuinely malformed. Smithery, scanning our production server, logged:

Warning: Failed to list triggers: MCP error -32602: Invalid request parameters

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

Reproduction

Against any server on this SDK, after initialize + notifications/initialized:

{"jsonrpc":"2.0","id":9,"method":"totally/bogus"}

Response:

{"jsonrpc":"2.0","id":9,"error":{"code":-32602,"message":"Invalid request parameters","data":""}}

Same 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.

Cause

In 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:

except Exception as e:
    # For request validation errors, send a proper JSON-RPC error
    # response instead of crashing the server
    logging.warning(f"Failed to validate request: {e}")
    error_response = JSONRPCError(
        ...
        error=ErrorData(code=INVALID_PARAMS, message="Invalid request parameters", data=""),
    )

The 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.

Suggested fix

Distinguish 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.

Happy to open a PR if the approach looks right.

Observed on mcp 1.27.1, Python 3.14.

Activity

  1. Ben-Home commented on Jul 28, 2026

    @Ben-Home
    Ben-Home
    on Jul 28, 2026 · Hidden as spam
    show commentMore actions
  2. Pradhyut21 commented on Jul 29, 2026

    @Pradhyut21
    Pradhyut21
    on Jul 29, 2026
    More actions

    Hi @borisowvalia! I'd like to work on this issue. I'll differentiate
    unknown JSON-RPC methods from parameter validation errors in
    mcp/shared/session.py per the JSON-RPC 2.0 spec (-32601 Method not
    found vs -32602 Invalid params), with test coverage. Will follow up
    here once I open the PR.

  3. Pradhyut21
    added a commit that references this issue on Jul 29, 2026

    fix(server): return METHOD_NOT_FOUND for unregistered spec methods (m…

    9724cea
  4. borisowvalia commented on Jul 29, 2026

    @borisowvalia
    borisowvalia
    on Jul 29, 2026
    Author
    More actions

    Thanks for picking this up! Worth checking #2372 first — it targets the same file and already carries a test (test_1561_invalid_method_names.py), but it has been stale since March and now conflicts with main. Rebasing it might be less work than starting over, and it would also close #1561.

    Either way, happy to test the result against our production server: it is the one whose scan produced the -32602 warning in the issue.

  5. Ranga-Prasath-22 commented on Jul 29, 2026

    @Ranga-Prasath-22
    Ranga-Prasath-22
    on Jul 29, 2026
    More actions

    Hi @borisowvalia! I'm picking up this fix to return -32601 METHOD_NOT_FOUND when the request method is unknown before parameter validation in mcp/shared/session.py, along with proper unit tests.

  6. maxisbey commented on Jul 29, 2026

    @maxisbey
    maxisbey
    on Jul 29, 2026
    Contributor
    More actions

    Hey! This has been fixed in the recent v2 release of the SDK, go ahead and try it out with the 2.0.0 version :)

    As v1.x is in maintenance mode only critical issues like vulnerabilities will be fixed for it, so going to close this for now.

  7. maxisbey
    closed this as completedon Jul 29, 2026
  8. Ecocitizenz commented on Jul 29, 2026

    @Ecocitizenz
    Ecocitizenz
    on Jul 29, 2026 via email · Hidden as spam
    show commentMore actions
  9. claude
    added
    v1Affects the v1.x maintenance lineAffects the v1.x maintenance line
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v1Affects the v1.x maintenance lineAffects the v1.x maintenance line

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.