Skip to content

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

@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

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workinggood first issueGood for newcomersimproves spec complianceWhen a change improves ability of SDK users to comply with spec definitionready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions