Enable configuration of the JSON-RPC error object to be returned.#18
Closed
dak2 wants to merge 1 commit intoShopify:mainfrom
Closed
Enable configuration of the JSON-RPC error object to be returned.#18dak2 wants to merge 1 commit intoShopify:mainfrom
JSON-RPC error object to be returned.#18dak2 wants to merge 1 commit intoShopify:mainfrom
Conversation
Currently, the `modelcontextprotocol/ruby-sdk` delegates the handling of JSON-RPC error objects to the `json-rpc-handler`, which prevents flexible configuration of error objects returned by the SDK. For example, The logging utility should return the `JSON-RPC` error object `-32602`, `Invalid params`, when the log level is invalid. https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging#error-handling Currently, however, the `modelcontextprotocol/ruby-sdk` side cannot freely configure the `Invalid params` error object. Therefore, we implemented a solution in which you can return the intended `JSON-RPC` error object by including code in the error class and raising it. The modelcontextprotocol/ruby-sdk could define and return `JSON-RPC` error objects directly. However, I believe that delegating this responsibility to the `json-rpc-handler` keeps things simpler. For this use case, setting `ErrorCode::InvalidParams` flexibly would have been sufficient. However, I implemented it this way because I thought that allowing the flexible invocation of other error classes would make it more universally reusable.
11 tasks
Author
|
This PR no longer needs to be addressed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation / Background
This PR is a proposal.
Currently, the
modelcontextprotocol/ruby-sdkdelegates the handling ofJSON-RPCerror objects to thejson-rpc-handler, which prevents flexible configuration of error objects returned by the SDK.For example, The logging utility should return the
JSON-RPCerror object-32602,Invalid params, when the log level is invalid.https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging#error-handling
Currently, however, the
modelcontextprotocol/ruby-sdkside cannot freely configure theInvalid paramserror object. Therefore, we implemented a solution in which you can return the intendedJSON-RPCerror object by including code in the error class and raising it.The
modelcontextprotocol/ruby-sdkcould define and returnJSON-RPCerror objects directly. However, I believe that delegating this responsibility to thejson-rpc-handlerkeeps things simpler.For this use case, setting
ErrorCode::InvalidParamsflexibly would have been sufficient.However, I implemented it this way because I thought that allowing the flexible invocation of other error classes would make it more universally reusable.