Learn how to use the FastMCP command-line interface
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 MCP client applications | Creates an isolated environment; dependencies must be explicitly specified with --with and/or --with-editable |
inspect | Generate a JSON report about a FastMCP server | Uses your current environment; you are responsible for ensuring all dependencies are available |
version | Display version information | N/A |
run
Option | Flag | Description |
---|---|---|
Transport | --transport , -t | Transport protocol to use (stdio , 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) |
Path | --path | Path to bind to when using http transport (default: /mcp/ or /sse/ for SSE) |
Log Level | --log-level , -l | Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
No Banner | --no-banner | Disable the startup banner display |
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 named mcp
, server
, or app
. Errors if no such object is found.server.py:custom_name
- imports and uses the specified server objecthttp://server-url/path
or https://server-url/path
- connects to a remote server and creates a proxyfastmcp 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.__main__
block:
dev
--with
and/or --with-editable
options.dev
command is a shortcut for testing a server over STDIO only. When the Inspector launches, you may need to: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 |
install
New in version: 2.10.3
Install a MCP server in MCP client applications. FastMCP currently supports the following clients:
--with
and/or --with-editable
options (following uv
conventions) or by attaching them to your server in code via the dependencies
parameter. You should not assume that the MCP server will have access to your local environment.
uv
must be installed and available in your system PATH. Both Claude Desktop and Cursor run in isolated environments and need uv
to manage dependencies. On macOS, install uv
globally with Homebrew for Claude Desktop compatibility: brew install uv
.install
commands focus on local server files with STDIO transport. For remote servers running with HTTP or SSE transport, use your client’s native configuration - FastMCP’s value is simplifying the complex local setup with dependencies and uv
commands.install
command supports the same file.py:object
notation as the run
command:
server.py
- imports the module and looks for a FastMCP object named mcp
, server
, or app
. Errors if no such object is found.server.py:custom_name
- imports and uses the specified server objectOption | Flag | Description |
---|---|---|
Server Name | --name , -n | Custom name for the server (defaults to server’s name attribute or file name) |
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) |
Environment Variables | --env | Environment variables in KEY=VALUE format (can be used multiple times) |
Environment File | --env-file , -f | Load environment variables from a .env file |
mcp-json
subcommand generates standard MCP JSON configuration that can be used with any MCP-compatible client. This is useful when:
mcpServers
object. Consult your client’s documentation for any specific configuration requirements or formatting needs.Option | Flag | Description |
---|---|---|
Copy to Clipboard | --copy | Copy configuration to clipboard instead of printing to stdout |
inspect
New in version: 2.9.0
Generate a detailed JSON report about a FastMCP server, including information about its tools, prompts, resources, and capabilities.
run
and install
:
version
Option | Flag | Description |
---|---|---|
Copy to Clipboard | --copy | Copy version information to clipboard |