run
fastmcp.cli.run
FastMCP run command implementation.
Functions
is_url
Check if a string is a URL.
parse_file_path
Parse a file path that may include a server object specification.
Args:
server_spec
: Path to file, optionally with :object suffix
Returns:
- Tuple of (file_path, server_object)
import_server
Import a MCP server from a file.
Args:
file
: Path to the fileserver_object
: Optional object name in format “module:object” or just “object”
Returns:
- The server object
create_client_server
Create a FastMCP server from a client URL.
Args:
url
: The URL to connect to
Returns:
- A FastMCP server instance
import_server_with_args
Import a server with optional command line arguments.
Args:
file
: Path to the server fileserver_object
: Optional server object nameserver_args
: Optional command line arguments to inject
Returns:
- The imported server object
run_command
Run a MCP server or connect to a remote one.
Args:
server_spec
: Python file, object specification (file:obj), or URLtransport
: Transport protocol to usehost
: Host to bind to when using http transportport
: Port to bind to when using http transportlog_level
: Log levelserver_args
: Additional arguments to pass to the server