-
Notifications
You must be signed in to change notification settings - Fork 1.6k
McpMixin for decorating Class methods #177
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!! This feels great!
Few minor thoughts:
- I know I suggested it yesterday but
McpRegisterableas a class name feels a little awkward to me -- it describes what the class can do but not what it's intended for. What do you think aboutMCPPluginorMCPComponent? - hardly critical, but if you made the prefix optional this could be an interesting way to ship MCP objects without a server (e.g. just import them into your server without a prefix)
- I'm ok merging without tests, but in that case would prefer to put it in a new
src/contrib/directory (e.g.src/contrib/mcp_plugin/mcp_plugin.py, which can collect any contributed functionality without the burden of maintenance with the rest of the repo. Otherwise it's hard to know if changes to main classes inadvertently break it;contribis a way of relaxing that requirement. If you agree, I'll also add documentation to that effect and to promote this! Having that folder also gives you a chance to (optionally) add a readme or any other info - please move
sample.pytosrc/contrib/mcp_plugin/example.pyand remove thesrcimport
|
It was originally just supposed to be an example but I'll go ahead and clean it up (including thinking of a new name, adjust the prefix handling, move some stuff, and add tests |
|
Oh :) I like it as more than just an example! Either way I think contrib/ will be the best home as its more framework-y than "just" an example script. |
|
@jlowin let me know what you think |
jlowin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@strawgate this is awesome! Thanks so much and welcome to the repo officially :) I made some minor changes because of some upstream method changes but LGTM!
McpMixin Example
Decorate class methods in Python, instantiate the class, and then turn the methods of the instantiated class into MCP Tools, Resources and prompts!
Example: