Skip to main content
New in version 3.0.0 fastmcp list and fastmcp call are general-purpose — you always specify the server, the tool name, and the arguments from scratch. fastmcp generate-cli goes further: it connects to a server, reads its tool schemas, and writes a standalone Python script where every tool is a proper subcommand with typed flags, help text, and tab completion. The result is a CLI that feels hand-written for that specific server. MCP tool schemas already contain everything a CLI framework needs — parameter names, types, descriptions, required/optional status, and defaults. generate-cli maps that into cyclopts commands, so JSON Schema types become Python type annotations, descriptions become --help text, and required parameters become mandatory flags.

Generating a Script

Point the command at any server target and it writes a CLI script:
The second positional argument sets the output path (defaults to cli.py). If the file already exists, pass -f to overwrite:

What You Get

The generated script is a regular Python file — executable, editable, and yours:
Each tool has typed parameters with help text pulled directly from the server’s schema:
Beyond tool commands, the script includes generic MCP operations — list-tools, list-resources, read-resource, list-prompts, and get-prompt — that always reflect the server’s current state, even if tools have changed since generation.

Parameter Handling

Parameters are mapped based on their JSON Schema type: Simple types (string, integer, number, boolean) become typed flags:
Arrays of simple types become repeatable flags:
Complex types (objects, nested arrays, unions) accept JSON strings. The --help output shows the full schema so you know what structure to pass:

Agent Skill

Alongside the CLI script, generate-cli writes a SKILL.md file — a Claude Code agent skill that documents every tool’s exact invocation syntax, parameter flags, types, and descriptions. An agent can pick up the CLI immediately without running --help or experimenting with flag names. To skip skill generation:

How It Works

The generated script is a client, not a server — it connects to the server on every invocation rather than bundling it. A CLIENT_SPEC variable at the top holds the resolved transport (a URL string or StdioTransport with baked-in command and arguments). The most common edit is changing CLIENT_SPEC — for example, pointing a script generated from a dev server at production. Beyond that, the helper functions (_call_tool, _print_tool_result) are thin wrappers around fastmcp.Client that are easy to adapt. The script requires fastmcp as a dependency. If it lives outside a project that already has FastMCP installed: