Skip to content

Custom MCP requests + hooks #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

cmrfrd
Copy link

@cmrfrd cmrfrd commented Apr 17, 2025

Allow users to opt-in to defining custom message types for MCP and server/client side hooks for how to process them.

Motivation and Context

This change allows users to define their own opt-in sub-protocols extending MCP to fit their needs outside the specification. With custom messages, users don't need to fork the MCP sdk's in order to extend the protocol.

Our specific use case for is so we can define sub-protocols for sensitive data transfer (ex: payment information, PII, credentials, etc.) but there are other users that may want to implement their own systems.

How Has This Been Tested?

See examples/custom_requests or updated readme.

Breaking Changes

This feature is opt-in via experimental_capabilities and won't break existing code / configs.

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

This PR only applies to the python sdk, so in order to provide this to MCP as a whole, we would need similar PR's for the other MCP sdk's. Consider this implementation a POC, and we can replicate this approach across the other sdks's.

@cmrfrd cmrfrd changed the title Support custom MCP requests Custom MCP requests + hooks Apr 23, 2025
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.

1 participant