Skip to content

Calling a nonexistent tool should trigger a JSON-RPC Error #1510

Closed

Description

@chemicL

Describe the bug
When a client attempts to call a tool that does not exist the specification requires that a protocol error is raised as a JSON-RPC Error. Instead, the current SDK returns a JSON-RPC Result with isError = true.

To Reproduce
Steps to reproduce the behavior:

  1. Call a missing tool

Expected behavior
As per the specification, the result should be:

{
  "jsonrpc": "2.0",
  "id": 3,
  "error": {
    "code": -32602,
    "message": "Unknown tool: nonexistent_tool"
  }
}

while actually it's

{
    "jsonrpc": "2.0",
    "id": "3",
    "result": {
      "content": [
        {
          "type": "text",
          "text": "MCP error -32602: Tool nonexistent_tool not found"
        }
      ],
      "isError": true
    }
  }

Additional context
https://github.com/modelcontextprotocol/typescript-sdk/blob/main/packages/server/src/server/mcp.ts#L201-L204
https://github.com/modelcontextprotocol/typescript-sdk/blob/main/packages/server/src/server/mcp.ts#L211-L227
are at fault.

Activity

  1. added
    bug
    on Feb 9, 2026
  2. chemicL commented on Feb 9, 2026

    @chemicL
    MemberAuthor

    I believe this behaviour is intended looking at #1044. However, it is against the specification. Perhaps the spec has to change?

  3. added a commit that references this issue on Feb 10, 2026
    f584fd7
  4. added a commit that references this issue on Feb 14, 2026
    f5bee11
  5. added 3 commits that reference this issue on Feb 22, 2026
    65f5f72
    cb1f173
    1030c40
  6. fahe1em1 commented on Mar 12, 2026

    @fahe1em1

    Opened a focused fix in #1674 that keeps missing-tool failures as JSON-RPC errors instead of wrapping them into CallToolResult.isError.

  7. m13v commented on Mar 13, 2026

    @m13v
  8. kdn-posipaka commented on Mar 13, 2026

    @kdn-posipaka

    This appears to have already been fixed by #1389 (commit 108f2f3). The fix moved the tool-not-found and tool-disabled checks outside the try/catch block in the tools/call handler, so they now correctly propagate as JSON-RPC errors (ProtocolError with InvalidParams code) instead of being caught and wrapped as CallToolResult with isError: true.

    The fix is on the main branch. This issue can likely be closed.

  9. felixweinberger commented on Mar 26, 2026

    @felixweinberger
    Contributor

    Fixed by #1389 — tool-not-found and tool-disabled checks now throw before the try block, so they propagate as JSON-RPC errors.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions