Skip to main content

fastmcp.cli.client

Client-side CLI commands for querying and invoking MCP servers.

Functions

resolve_server_spec

Turn CLI inputs into something Client() accepts. Exactly one of server_spec or command should be provided. Resolution order for server_spec:
  1. URLs (http://, https://) — passed through as-is. If --transport is sse, the URL is rewritten to end with /sse so infer_transport picks the right transport.
  2. Existing file paths, or strings ending in .py/.js/.json.
  3. Anything else — name-based resolution via resolve_name.
When command is provided, the string is shell-split into a StdioTransport(command, args).

coerce_value

Coerce a string CLI value according to a JSON-Schema type hint.

parse_tool_arguments

Build a tool-call argument dict from CLI inputs. A single JSON object argument is treated as the full argument dict. --input-json provides the base dict; key=value pairs override. Values are coerced using the tool’s inputSchema.

format_tool_signature

Build name(param: type, ...) -> return_type from a tool’s JSON schemas.

list_command

List tools available on an MCP server. Examples: fastmcp list http://localhost:8000/mcp fastmcp list server.py fastmcp list mcp.json —json fastmcp list —command ‘npx -y @mcp/server’ —resources fastmcp list http://server/mcp —transport sse

call_command

Call a tool, read a resource, or get a prompt on an MCP server. By default the target is treated as a tool name. If the target contains :// it is treated as a resource URI. Pass --prompt to treat it as a prompt name. Arguments are passed as key=value pairs. Use —input-json for complex or nested arguments. Examples:

discover_command

Discover MCP servers configured in editor and project configs. Scans Claude Desktop, Claude Code, Cursor, Gemini CLI, Goose, and project-level mcp.json files for MCP server definitions. Discovered server names can be used directly with fastmcp list and fastmcp call instead of specifying a URL or file path. Examples: fastmcp discover fastmcp discover —source claude-code fastmcp discover —source cursor —source gemini —json fastmcp list weather fastmcp call cursor:weather get_forecast city=London