New in version: 2.0.0
Tools are executable functions exposed by MCP servers. The FastMCP client provides methods to discover available tools and execute them with arguments.
Discovering Tools
Uselist_tools() to retrieve all tools available on the server:
Filtering by Tags
New in version: 2.11.0
You can use the meta field to filter tools based on their tags:
The
meta field is part of the standard MCP specification. FastMCP servers include tags and other metadata within a _fastmcp namespace (e.g., meta._fastmcp.tags) to avoid conflicts with user-defined metadata. This behavior can be controlled with the server’s include_fastmcp_meta setting - when disabled, the _fastmcp namespace won’t be included. Other MCP server implementations may not provide this metadata structure.Executing Tools
Basic Execution
Execute a tool usingcall_tool() with the tool name and arguments:
Advanced Execution Options
Thecall_tool() method supports additional parameters for timeout control and progress monitoring:
name: The tool name (string)arguments: Dictionary of arguments to pass to the tool (optional)timeout: Maximum execution time in seconds (optional, overrides client-level timeout)progress_handler: Progress callback function (optional, overrides client-level handler)meta: Dictionary of metadata to send with the request (optional, see below)
Sending Metadata
New in version: 2.13.1
The meta parameter sends ancillary information alongside tool calls. This can be used for various purposes like observability, debugging, client identification, or any context the server may need beyond the tool’s primary arguments.
meta is determined by your application. See Client Metadata in the server documentation to learn how to access this data in your tool implementations.
Handling Results
New in version: 2.10.0
Tool execution returns a CallToolResult object with both structured and traditional content. FastMCP’s standout feature is the .data property, which doesn’t just provide raw JSON but actually hydrates complete Python objects including complex types like datetimes, UUIDs, and custom classes.
CallToolResult Properties
CallToolResult Properties
FastMCP exclusive: Fully hydrated Python objects with complex type support (datetimes, UUIDs, custom classes). Goes beyond JSON to provide complete object reconstruction from output schemas.
Standard MCP content blocks (
TextContent, ImageContent, AudioContent, etc.) available from all MCP servers.Standard MCP structured JSON data as sent by the server, available from all MCP servers that support structured outputs.
Boolean indicating if the tool execution failed.
Structured Data Access
FastMCP’s.data property provides fully hydrated Python objects, not just JSON dictionaries. This includes complex type reconstruction:
Fallback Behavior
For tools without output schemas or when deserialization fails,.data will be None:
Primitive Type Unwrapping
FastMCP servers automatically wrap non-object results (like
int, str, bool) in a {"result": value} structure to create valid structured outputs. FastMCP clients understand this convention and automatically unwrap the value in .data for convenience, so you get the original primitive value instead of a wrapper object.Error Handling
Exception-Based Error Handling
By default,call_tool() raises a ToolError if the tool execution fails:
Manual Error Checking
You can disable automatic error raising and manually check the result:Raw MCP Protocol Access
For complete control, usecall_tool_mcp() which returns the raw MCP protocol object:
Argument Handling
Arguments are passed as a dictionary to the tool:For multi-server clients, tool names are automatically prefixed with the server name (e.g.,
weather_get_forecast for a tool named get_forecast on the weather server).
