Skip to content

Invalid JSON RPC requests do not respond with an error #563

Open
@joshcanhelp

Description

@joshcanhelp

I noticed that this request:

{"jsonrpc": "2.0", "id": 1, "method": "tools/lit", "params": {}}

... returns an error response (code -32601) as expected but this:

{"jsonrpc": "2.0", "id": 1, "method_": "tools/list", "params": {}}

... returns nothing. I would expect that a missing method property or an unknown root property like methodX would throw and error. The JSON-RPC 2.0 spec says the server should return:

  • -32600 "Invalid Request" for malformed JSON-RPC (missing required fields like method)
  • -32602 "Invalid params" for bad parameters

I think the SDK should handle these but I'm not even able to write validation logic in my application code because an invalid RPC request never reaches my handler.

Claude tells me I can do something like this:

class ValidatingStdioTransport extends StdioServerTransport {
  // Override message handling to add validation
}

.. but I don't love that.

If a maintainer agrees that this validation should be in the SDK, I'd be more than happy to write a PR! Thank you for all your work on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions