fastmcp.client.mixins.tools
Tool-related methods for FastMCP Client.
Classes
ClientToolsMixin
Mixin providing tool-related methods for Client.
Methods:
list_tools_mcp
cursor: Optional pagination cursor from a previous request’s nextCursor.
- mcp.types.ListToolsResult: The complete response object from the protocol, containing the list of tools and any additional metadata.
RuntimeError: If called while the client is not connected.McpError: If the request results in a TimeoutError | JSONRPCError
list_tools
- list[mcp.types.Tool]: A list of all Tool objects.
RuntimeError: If called while the client is not connected.McpError: If the request results in a TimeoutError | JSONRPCError
call_tool_mcp
name: The name of the tool to call.arguments: Arguments to pass to the tool.timeout: The timeout for the tool call. Defaults to None.progress_handler: The progress handler to use for the tool call. Defaults to None.meta: Additional metadata to include with the request. This is useful for passing contextual information (like user IDs, trace IDs, or preferences) that shouldn’t be tool arguments but may influence server-side processing. The server can access this viacontext.request_context.meta. Defaults to None.
- mcp.types.CallToolResult: The complete response object from the protocol, containing the tool result and any additional metadata.
RuntimeError: If called while the client is not connected.McpError: If the tool call requests results in a TimeoutError | JSONRPCError
call_tool
call_tool
call_tool
name: The name of the tool to call.arguments: Arguments to pass to the tool. Defaults to None.version: Specific tool version to call. If None, calls highest version.timeout: The timeout for the tool call. Defaults to None.progress_handler: The progress handler to use for the tool call. Defaults to None.raise_on_error: Whether to raise an exception if the tool call results in an error. Defaults to True.meta: Additional metadata to include with the request. This is useful for passing contextual information (like user IDs, trace IDs, or preferences) that shouldn’t be tool arguments but may influence server-side processing. The server can access this viacontext.request_context.meta. Defaults to None.task: If True, execute as background task (SEP-1686). Defaults to False.task_id: Optional client-provided task ID (auto-generated if not provided).ttl: Time to keep results available in milliseconds (default 60s).
- CallToolResult | ToolTask: The content returned by the tool if task=False, or a ToolTask object if task=True. If the tool returns structured outputs, they are returned as a dataclass (if an output schema is available) or a dictionary; otherwise, a list of content blocks is returned. Note: to receive both structured and unstructured outputs, use call_tool_mcp instead and access the raw result object.
ToolError: If the tool call results in an error.McpError: If the tool call request results in a TimeoutError | JSONRPCErrorRuntimeError: If called while the client is not connected.

