Skip to content

Conversation

atesgoral
Copy link
Contributor

@atesgoral atesgoral commented Jul 15, 2025

Closes #2

Adds define_custom_method to Server to allow definition of custom methods (outside the MCP spec). Method blocks that return nil become custom notifications.

Motivation and Context

MCP supports both servers and clients to send notifications. And notifications are not limited to what's defined by the spec.

This PR adds flexibility for servers to receive custom method calls and notifications from clients/hosts.

Servers can implement cutting-edge MCP methods before this gem implements them.

Custom notifications from host to server allow use cases like diagnostic logging, capturing of multimodal LLM transcripts, etc. by piggybacking on MCP instead of implementing custom endpoints.

How Has This Been Tested?

New unit tests

Breaking Changes

None

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

@atesgoral atesgoral marked this pull request as ready for review July 15, 2025 00:12
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.

If I were to raise one minor concern, it would be whether supporting methods outside the MCP specification is entirely suitable. That said, based on the explanation in the PR, it seems there’s a clear rationale for needing such functionality.

Both the documentation and the implementation look solid 👍

Copy link
Contributor

@topherbullock topherbullock left a comment

Choose a reason for hiding this comment

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

yeah, @koic I had a similar feeling initially about extending MCP spec with custom methods. I like that this allows users to add custom capabilities ( that could be proposed as additions to the spec if they prove a useful extension ) without needing to extend Server and override a lot of internals to achieve the same goal.

@atesgoral atesgoral merged commit fcb2a8c into modelcontextprotocol:main Jul 15, 2025
5 checks passed
@atesgoral atesgoral deleted the custom-methods branch July 15, 2025 14:03
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.

support notifications
3 participants