-
Notifications
You must be signed in to change notification settings - Fork 893
[Draft] Introduce a module for rewriting Tools #599
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.
Pull Request Overview
This PR introduces a new module for rewriting and transforming existing FastMCP tools by allowing modifications to tool arguments, hooking pre- and post-call logic, and loading transformation configurations via YAML.
- Introduces new types and protocols for extra parameters and hooks in tools.
- Implements core functions to transform tools and apply parameter overrides.
- Provides loader utilities and example scripts demonstrating programmatic and YAML-based tool transformations.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/fastmcp/contrib/tool_transformer/types.py | Adds new extra parameter types and hook protocols. |
src/fastmcp/contrib/tool_transformer/tool_transformer.py | Implements the tool transformation logic and transformed tool creation. |
src/fastmcp/contrib/tool_transformer/loader.py | Provides YAML parsing for tool overrides and tooling to reconfigure tools from a server. |
src/fastmcp/contrib/tool_transformer/example-*.py | Example scripts demonstrating various usages of tool transformation. |
src/fastmcp/contrib/tool_transformer/base.py | Defines base classes for parameter overrides and extra parameters. |
src/fastmcp/contrib/tool_transformer/README.md | Documents the module’s purpose, structure, and usage. |
pyproject.toml | Updates dependencies with jsonschema. |
@jlowin I have cleaned this up a bunch |
The latest version of this is vendored into here https://github.com/strawgate/fastmcp-agents/tree/main/src/fastmcp_agents/vendored/tool_transformer The new setup is to either call
And then you can apply it to any FastMCP Tool:
|
Closed via #745 (comment) |
In this PR, I've collected some of my thoughts on tool re-writing.
The
tool_transform
function in this PR offers the ability to:pre_call_hook
).post_call_hook
).It does it entirely within the existing tool infrastructure without any changes to FastMCP.
Simple transformations look like this (update name):