Discover and execute server-side tools with the FastMCP client.
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.
list_tools()
to retrieve all tools available on the server:
New in version: 2.11.0
You can use the meta
field to filter tools based on their tags:
_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.call_tool()
with the tool name and arguments:
call_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)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.
TextContent
, ImageContent
, AudioContent
, etc.) available from all MCP servers..data
property provides fully hydrated Python objects, not just JSON dictionaries. This includes complex type reconstruction:
.data
will be None
:
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.call_tool()
raises a ToolError
if the tool execution fails:
call_tool_mcp()
which returns the raw MCP protocol object:
weather_get_forecast
for a tool named get_forecast
on the weather
server).