McpMixin for decorating Class methods#177
Merged
jlowin merged 8 commits intoPrefectHQ:mainfrom Apr 18, 2025
Merged
Conversation
jlowin
requested changes
Apr 16, 2025
Member
There was a problem hiding this comment.
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
Collaborator
Author
|
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 |
Member
|
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. |
Collaborator
Author
|
@jlowin let me know what you think |
jlowin
approved these changes
Apr 18, 2025
Member
jlowin
left a comment
There was a problem hiding this comment.
@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!
jordicore
pushed a commit
to jordicore/fastmcp
that referenced
this pull request
Jul 2, 2025
McpMixin Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decorate class methods in Python, instantiate the class, and then turn the methods of the instantiated class into MCP Tools, Resources and prompts!
Example: