docs/python-sdk/fastmcp-tools-function_tool.mdx
fastmcp.tools.function_toolStandalone @tool decorator for FastMCP.
tool <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L381" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>tool(name_or_fn: str | Callable[..., Any] | None = None) -> Any
Standalone decorator to mark a function as an MCP tool.
Returns the original function with metadata attached. Register with a server using mcp.add_tool().
DecoratedTool <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Protocol for functions decorated with @tool.
ToolMeta <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L68" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Metadata attached to functions by the @tool decorator.
FunctionTool <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L90" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
from_function <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L95" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>from_function(cls, fn: Callable[..., Any]) -> FunctionTool
Create a FunctionTool from a function.
Args:
fn: The function to wrapmetadata: ToolMeta object with all configuration. If provided,
individual parameters must not be passed.name, title, etc.: Individual parameters for backwards compatibility.
Cannot be used together with metadata parameter.run <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L240" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>run(self, arguments: dict[str, Any]) -> ToolResult
Run the tool with arguments.
register_with_docket <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L303" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>register_with_docket(self, docket: Docket) -> None
Register this tool with docket for background execution.
Registers the raw function so Docket sees and resolves ALL dependencies — both FastMCP's (CurrentContext, Progress) and Docket-native ones (Retry, Timeout, ConcurrencyLimit).
add_to_docket <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/tools/function_tool.py#L314" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>add_to_docket(self, docket: Docket, arguments: dict[str, Any], **kwargs: Any) -> Execution
Schedule this tool for background execution via docket.
FunctionTool splats the arguments dict since .fn expects **kwargs.
Args:
docket: The Docket instancearguments: Tool argumentsfn_key: Function lookup key in Docket registry (defaults to self.key)task_key: Redis storage key for the result**kwargs: Additional kwargs passed to docket.add()