Skip to content

Allow registration of custom JSON-RPC methods #954

@jeongukjae

Description

@jeongukjae

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions