Is your feature request related to a problem? Please describe.
I'm contributing about SEP-2624 in modelcontextprotocol/experimental-ext-interceptors, which implements interceptors for MCP protocols. This feature requires extending the protocol with custom JSON-RPC methods.
Although the Golang SDK provides a solid interface, it currently does not allow to extend handlers for custom JSON-RPC methods.
Describe the solution you'd like
The mcp package can expose following interfaces
- Add methods to both the
Client and Server to register receiving and sending custom methods. For example:
AddReceivingCustomMethod[P paramsPtr[T], R Result, T any](method string, handler typedServerMethodHandler[P, R])
AddSendingCustomMethod[P paramsPtr[T], R Result, T any](method string, handler typedClientMethodHandler[P, R])
- Export other internal components that are necessary to implement these custom handlers, such as
Params.isParams, Result.isResult, typedServerMethodHandler, typedClientMethodHandler, paramsPtr, etc.
Describe alternatives you've considered
N/A
Additional context
For reference, we have already implemented AddReceivingCustomMethod for the server in a vendored version of the library. You can view the implementation details here:
happy to contribute once agreed.
Is your feature request related to a problem? Please describe.
I'm contributing about SEP-2624 in modelcontextprotocol/experimental-ext-interceptors, which implements interceptors for MCP protocols. This feature requires extending the protocol with custom JSON-RPC methods.
Although the Golang SDK provides a solid interface, it currently does not allow to extend handlers for custom JSON-RPC methods.
Describe the solution you'd like
The
mcppackage can expose following interfacesClientandServerto register receiving and sending custom methods. For example:AddReceivingCustomMethod[P paramsPtr[T], R Result, T any](method string, handler typedServerMethodHandler[P, R])AddSendingCustomMethod[P paramsPtr[T], R Result, T any](method string, handler typedClientMethodHandler[P, R])Params.isParams,Result.isResult,typedServerMethodHandler,typedClientMethodHandler,paramsPtr, etc.Describe alternatives you've considered
N/A
Additional context
For reference, we have already implemented AddReceivingCustomMethod for the server in a vendored version of the library. You can view the implementation details here:
happy to contribute once agreed.