Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136---title: clientsidebarTitle: client---
# `fastmcp.cli.client`
Client-side CLI commands for querying and invoking MCP servers.
## Functions
### `resolve_server_spec` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py#L43" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonresolve_server_spec(server_spec: str | None) -> str | dict[str, Any] | ClientTransport```
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` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py#L264" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythoncoerce_value(raw: str, schema: dict[str, Any]) -> Any```
Coerce a string CLI value according to a JSON-Schema type hint.
### `parse_tool_arguments` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py#L298" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonparse_tool_arguments(raw_args: tuple[str, ...], input_json: str | None, input_schema: dict[str, Any]) -> dict[str, Any]```
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` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py#L370" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonformat_tool_signature(tool: mcp_types.Tool) -> str```
Build ``name(param: type, ...) -> return_type`` from a tool's JSON schemas.
### `list_command` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py#L641" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonlist_command(server_spec: Annotated[str | None, cyclopts.Parameter(help='Server URL, Python file, MCPConfig JSON, or .js file')] = None) -> None```
List tools available on an MCP server.
**Examples:**
fastmcp list http://localhost:8000/mcpfastmcp list server.pyfastmcp list mcp.json --jsonfastmcp list --command 'npx -y @mcp/server' --resourcesfastmcp list http://server/mcp --transport sse
### `call_command` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py#L796" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythoncall_command(server_spec: Annotated[str | None, cyclopts.Parameter(help='Server URL, Python file, MCPConfig JSON, or .js file')] = None, target: Annotated[str, cyclopts.Parameter(help='Tool name, resource URI, or prompt name (with --prompt)')] = '', *arguments: str) -> None```
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 targetcontains ``://`` 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 complexor nested arguments.
**Examples:**
```fastmcp call server.py greet name=Worldfastmcp call server.py resource://docs/readmefastmcp call server.py analyze --prompt data='[1,2,3]'fastmcp call http://server/mcp create --input-json '{"tags": ["a","b"]}'```
### `discover_command` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py#L897" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythondiscover_command() -> None```
Discover MCP servers configured in editor and project configs.
Scans Claude Desktop, Claude Code, Cursor, Gemini CLI, Goose, andproject-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 discoverfastmcp discover --source claude-codefastmcp discover --source cursor --source gemini --jsonfastmcp list weatherfastmcp call cursor:weather get_forecast city=London