Closed
Labels
bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.
Description
What happened?
Tools created from a functools.partial get the name partial (the functools.partial class name) instead of the wrapped function's name, and their description becomes the functools.partial class docstring. Registering two partial-based tools therefore collides on the name partial and the second tool replaces the first (with only a generic "Component already exists" warning).
Expected: each tool takes the wrapped function's name and docstring, as it does when the same function is registered directly.
Example Code
import asyncio
import functools
from fastmcp import Client, FastMCP
def multiply(x: int, y: int) -> int:
"""Multiply two numbers."""
return x * y
def greet(name: str) -> str:
"""Greet a person."""
return f"Hello, {name}!"
mcp = FastMCP()
mcp.add_tool(functools.partial(multiply, y=2))
mcp.add_tool(functools.partial(greet))
async def main():
async with Client(mcp) as client:
for tool in await client.list_tools():
print(tool.name, "--", tool.description)
asyncio.run(main())This prints a single tool named partial with the description partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. — multiply is gone.
Version Information
FastMCP version: 4.0.10.dev2+edc991e4 (current main)
MCP version: 2.0.0
Python version: 3.12.14
Platform: macOS-26.6-arm64-arm-64bit
Metadata
Metadata
Assignees
Labels
bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.
Activity
fix(tools): take partial tool names and docstrings from the wrapped f…