Skip to content

[Feature Request] Include McpError 'data' payload in JSON-RPC error response #774

Closed

Description

@victorRadu

Problem:
When a tool throws an McpError with a data payload for structured error context, the server's error handler correctly catches the error but only includes the code and message in the final JSON-RPC response. The data field is ignored and not sent to the client.

This limits the ability to provide rich, machine-readable error context from tools as intended by the JSON-RPC specification.

To Reproduce:
Create a tool that throws an McpError with a data payload:

  throw new McpError(
    ErrorCode.InvalidParams,
    'Invalid parameters provided.',
    {
      'field': 'experienceId',
      'issue': 'The experience ID is not valid.',
    }
  );
});

Expected Outcome:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32602,
    "message": "Invalid parameters provided.",
    "data": {
      "field": "experienceId",
      "issue": "The experience ID is not valid."
    }
  },
  "id": "1"
}

Actual Outcome:

{
  "type": "text",
  "text": "MCP error -32602: Invalid parameters provided."
}

Activity

  1. added
    enhancementRequest for a new feature that's not currently supported
    on Jul 16, 2025
  2. matiasedgeandnode commented on Oct 16, 2025

    @matiasedgeandnode

    This is required by the x402 spec - Please fix.

  3. added
    good first issueGood for newcomers - can be tackled without deep knowledge of the codebase
    ready for workEnough information for someone to start working on
    P3Nice to haves, rare edge cases
    and removed
    good first issueGood for newcomers - can be tackled without deep knowledge of the codebase
    ready for workEnough information for someone to start working on
    on Oct 17, 2025
  4. felixweinberger commented on Oct 17, 2025

    @felixweinberger
    Contributor

    Already has a PR: #1031

  5. matiasedgeandnode commented on Oct 17, 2025

    @matiasedgeandnode

    @felixweinberger shouldn't this rank higher than P3, since it's part of the MCP schema as per here. Also, please consider that structured errors are crucial for building on top of MCP.

  6. felixweinberger commented on Oct 21, 2025

    @felixweinberger
    Contributor

    @felixweinberger shouldn't this rank higher than P3, since it's part of the MCP schema as per here. Also, please consider that structured errors are crucial for building on top of MCP.

    I'm already looking at it, thank you for submitting #1031

  7. added
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    ready for workEnough information for someone to start working on
    and removed
    P3Nice to haves, rare edge cases
    on Oct 21, 2025
  8. felixweinberger commented on Mar 26, 2026

    @felixweinberger
    Contributor

    Fixed by #1105.

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

    P2Moderate issues affecting some users, edge cases, potentially valuable featureenhancementRequest for a new feature that's not currently supportedready 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