Skip to main content

fastmcp.tools.tool

Functions

default_serializer

Classes

ToolResult

Methods:

to_mcp_result

Tool

Internal tool registration info. Methods:

to_mcp_tool

Convert the FastMCP tool to an MCP tool.

from_function

Create a Tool from a function.

run

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).

convert_result

Convert a raw result to ToolResult. Handles ToolResult passthrough and converts raw values using the tool’s attributes (serializer, output_schema) for proper conversion.

register_with_docket

Register this tool with docket for background execution.

add_to_docket

Schedule this tool for background execution via docket. Args:
  • docket: The Docket instance
  • arguments: Tool arguments
  • fn_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()

from_tool

get_span_attributes