docs/python-sdk/fastmcp-cli-run.mdx
fastmcp.cli.runFastMCP run command implementation with enhanced type hints.
is_url <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L84" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_url(path: str) -> bool
Check if a string is a URL.
create_client_server <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L90" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create_client_server(url: str) -> Any
Create a FastMCP server from a client URL.
Args:
url: The URL to connect toReturns:
create_mcp_config_server <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L110" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
Create a FastMCP server from a MCPConfig.
load_mcp_server_config <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L119" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load_mcp_server_config(config_path: Path) -> MCPServerConfig
Load a FastMCP configuration from a fastmcp.json file.
Args:
config_path: Path to fastmcp.json fileReturns:
run_command <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L136" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>run_command(server_spec: str, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, server_args: list[str] | None = None, show_banner: bool = True, use_direct_import: bool = False, skip_source: bool = False, stateless: bool = False) -> None
Run a MCP server or connect to a remote one.
Args:
server_spec: Python file, object specification (file:obj), config file, or URLtransport: Transport protocol to usehost: Host to bind to when using http transportport: Port to bind to when using http transportpath: Path to bind to when using http transportlog_level: Log levelserver_args: Additional arguments to pass to the servershow_banner: Whether to show the server banneruse_direct_import: Whether to use direct import instead of subprocessskip_source: Whether to skip source preparation stepstateless: Whether to run in stateless mode (no session)run_module_command <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L272" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>run_module_command(module_name: str) -> None
Run a Python module directly using python -m <module>.
When -m is used, the module manages its own server startup.
No server-object discovery or transport overrides are applied.
Args:
module_name: Dotted module name (e.g. my_package).env_command_builder: An optional callable that wraps a command list
with environment setup (e.g. UVEnvironment.build_command).extra_args: Extra arguments forwarded after the module name.run_v1_server_async <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L311" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>run_v1_server_async(server: FastMCP1x, host: str | None = None, port: int | None = None, transport: TransportType | None = None) -> None
Run a FastMCP 1.x server using async methods.
Args:
server: FastMCP 1.x server instancehost: Host to bind toport: Port to bind totransport: Transport protocol to userun_with_reload <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/cli/run.py#L376" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>run_with_reload(cmd: list[str], reload_dirs: list[Path] | None = None, is_stdio: bool = False) -> None
Run a command with file watching and auto-reload.
Args:
cmd: Command to run as subprocess (should include --no-reload)reload_dirs: Directories to watch for changes (default: cwd)is_stdio: Whether this is stdio transport