Skip to main content

fastmcp.cli.run

FastMCP run command implementation with enhanced type hints.

Functions

is_url

Check if a string is a URL.

create_client_server

Create a FastMCP server from a client URL. Args:
  • url: The URL to connect to
Returns:
  • A FastMCP server instance

create_mcp_config_server

Create a FastMCP server from a MCPConfig.

load_mcp_server_config

Load a FastMCP configuration from a fastmcp.json file. Args:
  • config_path: Path to fastmcp.json file
Returns:
  • MCPServerConfig object

run_command

Run a MCP server or connect to a remote one. Args:
  • server_spec: Python file, object specification (file:obj), config file, or URL
  • transport: Transport protocol to use
  • host: Host to bind to when using http transport
  • port: Port to bind to when using http transport
  • path: Path to bind to when using http transport
  • log_level: Log level
  • server_args: Additional arguments to pass to the server
  • show_banner: Whether to show the server banner
  • use_direct_import: Whether to use direct import instead of subprocess
  • skip_source: Whether to skip source preparation step
  • stateless: Whether to run in stateless mode (no session)

run_v1_server_async

Run a FastMCP 1.x server using async methods. Args:
  • server: FastMCP 1.x server instance
  • host: Host to bind to
  • port: Port to bind to
  • transport: Transport protocol to use

run_with_reload

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