--- title: tool sidebarTitle: tool --- # `fastmcp.tools.tool` ## Functions ### `default_serializer` ```python default_serializer(data: Any) -> str ``` ## Classes ### `ToolResult` **Methods:** #### `to_mcp_result` ```python to_mcp_result(self) -> list[ContentBlock] | tuple[list[ContentBlock], dict[str, Any]] ``` ### `Tool` Internal tool registration info. **Methods:** #### `enable` ```python enable(self) -> None ``` #### `disable` ```python disable(self) -> None ``` #### `to_mcp_tool` ```python to_mcp_tool(self, **overrides: Any) -> MCPTool ``` Convert the FastMCP tool to an MCP tool. #### `from_function` ```python from_function(fn: Callable[..., Any], name: str | None = None, title: str | None = None, description: str | None = None, icons: list[Icon] | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, exclude_args: list[str] | None = None, output_schema: dict[str, Any] | None | NotSetT | Literal[False] = NotSet, serializer: ToolResultSerializerType | None = None, meta: dict[str, Any] | None = None, enabled: bool | None = None) -> FunctionTool ``` Create a Tool from a function. #### `run` ```python run(self, arguments: dict[str, Any]) -> ToolResult ``` Run the tool with arguments. This method is not implemented in the base Tool class and must be implemented by subclasses. `run()` can EITHER return a list of ContentBlocks, or a tuple of (list of ContentBlocks, dict of structured output). #### `from_tool` ```python from_tool(cls, tool: Tool) -> TransformedTool ``` ### `FunctionTool` **Methods:** #### `from_function` ```python from_function(cls, fn: Callable[..., Any], name: str | None = None, title: str | None = None, description: str | None = None, icons: list[Icon] | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, exclude_args: list[str] | None = None, output_schema: dict[str, Any] | None | NotSetT | Literal[False] = NotSet, serializer: ToolResultSerializerType | None = None, meta: dict[str, Any] | None = None, enabled: bool | None = None) -> FunctionTool ``` Create a Tool from a function. #### `run` ```python run(self, arguments: dict[str, Any]) -> ToolResult ``` Run the tool with arguments. ### `ParsedFunction` **Methods:** #### `from_function` ```python from_function(cls, fn: Callable[..., Any], exclude_args: list[str] | None = None, validate: bool = True, wrap_non_object_output_schema: bool = True) -> ParsedFunction ```