FastMCP CLI
Learn how to use the FastMCP command-line interface
FastMCP provides a command-line interface (CLI) that makes it easy to run, develop, and install your MCP servers. The CLI is automatically installed when you install FastMCP.
Commands Overview
Command | Purpose | Dependency Management |
---|---|---|
run | Run a FastMCP server directly | Uses your current environment; you are responsible for ensuring all dependencies are available |
dev | Run a server with the MCP Inspector for testing | Creates an isolated environment; dependencies must be explicitly specified with --with and/or --with-editable |
install | Install a server in the Claude desktop app | Creates an isolated environment; dependencies must be explicitly specified with --with and/or --with-editable |
version | Display version information | N/A |
Command Details
run
Run a FastMCP server directly or proxy a remote server.
This command runs the server directly in your current Python environment. You are responsible for ensuring all dependencies are available.
Options
Option | Flag | Description |
---|---|---|
Transport | --transport , -t | Transport protocol to use (stdio , streamable-http , or sse ) |
Host | --host | Host to bind to when using http transport (default: 127.0.0.1) |
Port | --port , -p | Port to bind to when using http transport (default: 8000) |
Log Level | --log-level , -l | Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
Server Specification
New in version: 2.3.5
The server can be specified in three ways:
server.py
- imports the module and looks for a FastMCP object namedmcp
,server
, orapp
. Errors if no such object is found.server.py:custom_name
- imports and uses the specified server objecthttp://server-url/path
orhttps://server-url/path
- connects to a remote server and creates a proxy
When using fastmcp run
with a local file, it ignores the if __name__ == "__main__"
block entirely. Instead, it finds your server object and calls its run()
method directly with the transport options you specify. This means you can use fastmcp run
to override the transport specified in your code.
For example, if your code contains:
You can run it with Streamable HTTP transport regardless of what’s in the __main__
block:
Examples
dev
Run a MCP server with the MCP Inspector for testing.
This command runs your server in an isolated environment. All dependencies must be explicitly specified using the --with
and/or --with-editable
options.
The dev
command is a shortcut for testing a server over STDIO only. When the Inspector launches, you may need to:
- Select “STDIO” from the transport dropdown
- Connect manually
This command does not support HTTP testing. To test a server over HTTP:
- Start your server manually with HTTP transport using either:
or
- Open the MCP Inspector separately and connect to your running server
Options
Option | Flag | Description |
---|---|---|
Editable Package | --with-editable , -e | Directory containing pyproject.toml to install in editable mode |
Additional Packages | --with | Additional packages to install (can be used multiple times) |
Inspector Version | --inspector-version | Version of the MCP Inspector to use |
UI Port | --ui-port | Port for the MCP Inspector UI |
Server Port | --server-port | Port for the MCP Inspector Proxy server |
Example
install
Install a MCP server in the Claude desktop app.
Note that for security reasons, Claude runs every MCP server in a completely isolated environment. Therefore, all dependencies must be explicitly specified using the --with
and/or --with-editable
options (following uv
conventions) or by attaching them to your server in code via the dependencies
parameter.
uv
must be installed and available in your system PATH. Claude Desktop runs in its own isolated environment and needsuv
to manage dependencies.- On macOS, it is recommended to install
uv
globally with Homebrew so that Claude Desktop will detect it:brew install uv
. Installinguv
with other methods may not make it accessible to Claude Desktop.
The install
command currently only sets up servers for STDIO transport. When installed in the Claude desktop app, your server will be run using STDIO regardless of any transport configuration in your code.
Server Specification
The install
command supports the same file.py:object
notation as the run
command:
server.py
- imports the module and looks for a FastMCP object namedmcp
,server
, orapp
. Errors if no such object is found.server.py:custom_name
- imports and uses the specified server object
Examples
version
Display version information about FastMCP and related components.