Skip to content
Discussion options

You must be logged in to vote

Great question — this tripped me up too when migrating. In FastMCP v2+ the add_tool method expects a Tool object (specifically a FunctionTool), not a bare callable. The easiest way to create one without using the @mcp.tool() decorator is Tool.from_function():

from fastmcp import FastMCP
from fastmcp.tools import Tool

mcp = FastMCP("my-server")

def greet(name: str) -> str:
    """Say hello to someone."""
    return f"Hello, {name}!"

# Create a FunctionTool from a plain function
tool = Tool.from_function(greet)
mcp.add_tool(tool)

Tool.from_function() accepts all the same optional kwargs as the decorator: name, description, title, tags, annotations, timeout, etc.

tool = Tool.from_function(…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yarnabrina
Comment options

Answer selected by yarnabrina
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants