New in version: 2.12.0
FastMCP supports declarative configuration through fastmcp.json
files. This is the canonical and preferred way to configure FastMCP projects, providing a single source of truth for server settings, dependencies, and deployment options that replaces complex command-line arguments.
The fastmcp.json
file is designed to be a portable description of your server configuration that can be shared across environments and teams. When running from a fastmcp.json
file, you can override any configuration values using CLI arguments.
Overview
Thefastmcp.json
configuration file allows you to define all aspects of your FastMCP server in a structured, shareable format. Instead of remembering command-line arguments or writing shell scripts, you declare your server’s configuration once and use it everywhere.
When you have a fastmcp.json
file, running your server becomes as simple as:
File Structure
Thefastmcp.json
configuration answers three fundamental questions about your server:
- Source = WHERE does your server code live?
- Environment = WHAT environment setup does it require?
- Deployment = HOW should the server run?
source
field is required. The environment
and deployment
sections are optional and provide additional configuration when needed.
JSON Schema Support
FastMCP provides JSON schemas for IDE autocomplete and validation. Add the schema reference to yourfastmcp.json
for enhanced developer experience:
- Version-specific:
https://gofastmcp.com/public/schemas/fastmcp.json/v1.json
- Latest version:
https://gofastmcp.com/public/schemas/fastmcp.json/latest.json
Source Configuration
The source configuration determines WHERE your server code lives. It tells FastMCP how to find and load your server, whether it’s a local Python file, a remote repository, or hosted in the cloud. This section is required and forms the foundation of your configuration.Source
The server source configuration that determines where your server code lives.
The source type identifier that determines which implementation to use. Currently supports
"filesystem"
for local files. Future releases will add support for "git"
and "cloud"
source types.Future Source TypesFuture releases will support additional source types:
- Git repositories (
type: "git"
) for loading server code directly from version control - FastMCP Cloud (
type: "cloud"
) for hosted servers with automatic scaling and management
Environment Configuration
The environment configuration determines WHAT environment setup your server requires. It controls the build-time setup of your Python environment, ensuring your server runs with the exact Python version and dependencies it requires. This section creates isolated, reproducible environments across different systems. FastMCP uses an extensible environment system with a baseEnvironment
class that can be implemented by different environment providers. Currently, FastMCP supports the UVEnvironment
for Python environment management using uv
’s powerful dependency resolver.
Environment
Optional environment configuration. When specified, FastMCP uses the appropriate environment implementation to set up your server’s runtime.
The environment type identifier that determines which implementation to use. Currently supports
"uv"
for Python environments managed by uv. If omitted, defaults to "uv"
.- Detects the environment type (defaults to
"uv"
if not specified) - Creates an isolated environment using the appropriate provider
- Installs the specified dependencies
- Runs your server in this clean environment
Future Environment TypesSimilar to source types, future releases may support additional environment types for different runtime requirements, such as Docker containers or language-specific environments beyond Python.
Deployment Configuration
The deployment configuration controls HOW your server runs. It defines the runtime behavior including network settings, environment variables, and execution context. These settings determine how your server operates when it executes, from transport protocols to logging levels. Environment variables are included in this section because they’re runtime configuration that affects how your server behaves when it executes, not how its environment is built. The deployment configuration is applied every time your server starts, controlling its operational characteristics.Deployment Fields
Optional runtime configuration for the server.
Environment Variable Interpolation
Theenv
field in deployment configuration supports runtime interpolation of environment variables using ${VAR_NAME}
syntax. This enables dynamic configuration based on your deployment environment:
${ENVIRONMENT}
, ${DB_USER}
, etc. with values from your system’s environment variables. If a variable doesn’t exist, the placeholder is preserved as-is.
Example: If your system has ENVIRONMENT=production
and DB_HOST=db.example.com
:
- Deploying the same configuration across development, staging, and production
- Keeping sensitive values out of configuration files
- Building dynamic URLs and connection strings
- Creating environment-specific prefixes or suffixes
Usage with CLI Commands
FastMCP automatically detects and uses a file specifically namedfastmcp.json
in the current directory, making server execution simple and consistent. Files with FastMCP configuration format but different names are not auto-detected and must be specified explicitly:
Pre-building Environments
You can usefastmcp project prepare
to create a persistent uv project with all dependencies pre-installed:
Using an Existing Environment
By default, FastMCP creates an isolated environment withuv
based on your configuration. When you already have a suitable Python environment, use the --skip-env
flag to skip environment creation:
- You’re in an activated virtual environment with all dependencies installed
- You’re inside a Docker container with pre-installed dependencies
- You’re in a CI/CD pipeline that pre-builds the environment
- You’re using a system-wide installation with all required packages
- You’re in a uv-managed environment (prevents infinite recursion)
Using an Existing Source
When working with source types that require preparation (future support for git repositories or cloud sources), use the--skip-source
flag when you already have the source code available:
- You’ve previously cloned a git repository and don’t need to re-fetch
- You have a cached copy of a cloud-hosted server
- You’re in a CI/CD pipeline where source checkout is a separate step
- You’re iterating locally on already-downloaded code
run
- Start the server in production modedev
- Launch with the Inspector UI for developmentinspect
- View server capabilities and configurationinstall
- Install to Claude Desktop, Cursor, or other MCP clients
fastmcp.json
. This means you can simply navigate to your project directory and run fastmcp run
to start your server with all its configured settings.
CLI Override Behavior
Command-line arguments take precedence over configuration file values, allowing ad-hoc adjustments without modifying the file:- Quick testing of different settings
- Environment-specific overrides in deployment scripts
- Debugging with increased log levels
- Temporary configuration changes
Custom Naming Patterns
You can use different configuration files for different environments:fastmcp.json
- Default configurationdev.fastmcp.json
- Development settingsprod.fastmcp.json
- Production settingstest_fastmcp.json
- Test configuration
Examples
- Basic Configuration
- Development Configuration
- Production Configuration
- Data Science Server
- Multi-Environment Setup
A minimal configuration for a simple server:This configuration explicitly specifies the server entrypoint (
mcp
), making it clear which server instance or factory function to use. Uses all defaults: STDIO transport, no special dependencies, standard logging.Migrating from CLI Arguments
If you’re currently using command-line arguments or shell scripts, migrating tofastmcp.json
simplifies your workflow. Here’s how common CLI patterns map to configuration:
CLI Command: