Skip to content

Conversation

@atesgoral
Copy link
Contributor

@atesgoral atesgoral commented Oct 30, 2025

Motivation and Context

The ruby-sdk gem is the only popular gem that uses the json_rpc_handler gem. For tweaks around transport error handling, there is an ongoing awkwardness of working around the opinions of the json_rpc_handler gem or needing to extend that gem to make its API more flexible.

Just internalizing the JSON-RPC handling will alllow mcp gem development to move faster.

Incidentally, we also pick up an unreleased security fix on json_rpc_handler:

Reviewers: Follow individual commits to see the incremental steps I took in copying things over, so you're not tasked with reviewing the entire internalized "new" code. Code copied from commit Shopify/json-rpc-handler@b41c412

How Has This Been Tested?

Existing unit tests pass.

Breaking Changes

The gem becomes stringent on the format of JSON-RPC call ids by default, to prevent an XSS vulnerability.

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
  • I have added or updated documentation as needed

Additional context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I preserved the name, but this could be moved to a nicer, json-rpc folder to follow suit with mcp.

PARSE_ERROR = -32700
end

DEFAULT_ALLOWED_ID_CHARACTERS = /\A[a-zA-Z0-9_-]+\z/
Copy link
Contributor Author

@atesgoral atesgoral Oct 30, 2025

Choose a reason for hiding this comment

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

As a follow up, we need to decide whether we want to keep this as configurable through the mcp gem, or allow developers to punch through layers to be able to directly override it at JSON-RPC module level, or simply make the mcp gem super opinionated about always having strict id validation. Heuristically this pattern should cover any non-pen-tester scenarios.

@atesgoral atesgoral merged commit 3f5f6f8 into modelcontextprotocol:main Oct 30, 2025
5 checks passed
@atesgoral atesgoral deleted the ag/include-json-rpc-handler branch October 30, 2025 21:43
@koic
Copy link
Member

koic commented Oct 31, 2025

Thank you!

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.

3 participants