Skip to content

Conversation

@Jflick58
Copy link
Contributor

Tool execution errors now return successful responses with isError: true
instead of JSON-RPC protocol errors, per the MCP specification.

Motivation and Context

This allows clients to distinguish between protocol-level errors and
tool execution errors, providing better error context.

Fixes #159

How Has This Been Tested?

Updated unit tests to support new error behavior. All existing tests passing.

Breaking Changes

If client libs are parsing the error message for the specific tool call error, then they will likely get a parser error due to the change of the error structure.

Current behavior:

    {
      "jsonrpc": "2.0",
      "id": 4,
      "error": {
        "code": -32603,
        "message": "Internal error",
        "data": "Internal error calling tool fetch_weather_data"
      }
    }

Updated behavior (matches spec and readme):

     {
       "jsonrpc": "2.0",
       "id": 4,
       "result": {
         "content": [{
           "type": "text",
           "text": "Internal error calling tool fetch_weather_data"
         }],
         "isError": true
       }
     }

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • [x ] I have added or updated documentation as needed

@koic
Copy link
Member

koic commented Oct 15, 2025

I've left one small comment, but overall it looks good to me. Can you address it and squash the commits in to one?

@koic
Copy link
Member

koic commented Oct 19, 2025

@Jflick58 ping.

@Jflick58
Copy link
Contributor Author

@koic sorry have been sick. I'll get this buttoned up

Tool execution errors now return successful responses with isError: true
instead of JSON-RPC protocol errors, per the MCP specification.

This allows clients to distinguish between protocol-level errors and
tool execution errors, providing better error context.

Fixes modelcontextprotocol#159
@Jflick58 Jflick58 force-pushed the fix/make-tool-error-spec-compliant branch from f383442 to 389cc2e Compare October 22, 2025 01:34
Copy link
Member

@koic koic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jflick58 Thank you for working on this!

@koic koic merged commit 61d48cd into modelcontextprotocol:main Oct 22, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool error handling does not follow spec

4 participants