fastmcp.utilities.mcp_server_config.v1.mcp_server_config
FastMCP Configuration File Support.
This module provides support for fastmcp.json configuration files that allow
users to specify server settings in a declarative format instead of using
command-line arguments.
Functions
generate_schema
output_path: Optional path to write the schema to. If provided, writes the schema and returns None. If not provided, returns the schema as a dictionary.
- JSON schema as a dictionary if output_path is None, otherwise None
Classes
Deployment
Configuration for server deployment and runtime settings.
Methods:
apply_runtime_settings
config_path: Path to config file for resolving relative paths
MCPServerConfig
Configuration for a FastMCP server.
This configuration file allows you to specify all settings needed to run
a FastMCP server in a declarative format.
Methods:
validate_source
- Dict format:
{"path": "server.py", "entrypoint": "app"} - FileSystemSource instance (passed through)
validate_environment
validate_deployment
- Deployment instance
- dict that can be converted to Deployment
from_file
file_path: Path to the configuration file
- MCPServerConfig instance
FileNotFoundError: If the file doesn’t existjson.JSONDecodeError: If the file is not valid JSONpydantic.ValidationError: If the configuration is invalid
from_cli_args
source: Server source (FileSystemSource instance)transport: Transport protocolhost: Host for HTTP transportport: Port for HTTP transportpath: URL path for serverlog_level: Logging levelpython: Python versiondependencies: Python packages to installrequirements: Path to requirements fileproject: Path to project directoryeditable: Path to install in editable modeenv: Environment variablescwd: Working directoryargs: Server arguments
- MCPServerConfig instance
find_config
start_path: Directory to look in (defaults to current directory)
- Path to the configuration file, or None if not found
prepare
skip_source: Skip source preparation if Trueoutput_dir: Directory to create the persistent uv project in (optional)
prepare_environment
output_dir: If provided, creates a persistent uv project in this directory. If None, just populates uv’s cache for ephemeral use.
prepare_source
run_server
**kwargs: Additional arguments to pass to server.run_async() These override config settings

