Introduction to FastMCP
FastMCP JSON Configurations
While the CLI and environment variables are great for quick development and testing, managing multiple configuration options via command-line arguments can become cumbersome, especially when working in teams or across different environments (development, staging, production).
The fastmcp.json file is the canonical and preferred way to configure FastMCP projects. It provides a single source of truth that replaces complex command-line arguments and makes your configuration portable, version-controlled, and shareable.
Why Use fastmcp.json?
Instead of running a long command like this:
FASTMCP_HOST=localhost FASTMCP_PORT=8000 \
FASTMCP_DEBUG=true FASTMCP_SHOW_SERVER_BANNER=false \
uv run fastmcp run server.py:mcp \
--transport http \
--with pandas --with requests
You can create a fastmcp.json file with all these settings in a structured format, and then simply run:
uv run fastmcp run
Structure Overview
The configuration file answers 3 fundamental questions:
- Source (WHERE) = Where does your server code live?
- Environment (WHAT) = What environment setup does it require?
- Deployment (HOW) = How should the server run?
Here's a minimal fastmcp.json configuration for our demo server:
{
"$schema": "https://gofastmcp.com/public/schemas/fastmcp.json/v1.json",
"source": {
"path": "server.py",
"entrypoint": "mcp" // Optional: defaults to auto-detect (mcp/server/app)
},
"environment": { // Optional
"python": ">=3.12",
"dependencies": [] // List of pip packages or use requirements/project
},
"deployment": { // Optional
"transport": "http",
"host": "localhost",
"port": 8000,
"log_level": "INFO"
}
}
Only
sourceis required, everything else is optional. If you omit theenvironmentanddeploymentsections, FastMCP will use sensible defaults (STDIO transport, no special dependencies, standard logging).
Next, we're going to see a description of each section and how to use it effectively.
Source (Required)
This section specifies where your FastMCP server code lives. This is the same concept as the server.py:mcp we used in the CLI commands earlier:
"source": {
"type": "filesystem", // Optional, default
"path": "server.py", // Path to Python file
"entrypoint": "mcp" // Variable name (or auto-detect: mcp/server/app)
}
Reminder: If your server instance is named
mcp,server, orapp, you can omit theentrypointfield and FastMCP will auto-detect it - just like howfastmcp run server.pyworks without explicitly specifying:mcp.
Environment (Optional)
Controls dependency management using uv. Here is another example with different options:
"environment": {
"type": "uv", // Optional, default
"python": ">=3.10", // Python version constraint
"dependencies": ["pandas>=2.0", "requests"], // Pip packages
"requirements": "requirements.txt", // Or use requirements file
"project": "." // When using pyproject.toml for dependencies
}
Deployment (Optional)
This represents the runtime configuration. These are the same settings you can control via FASTMCP_* environment variables or CLI flags. For example:
"deployment": {
"transport": "http", // stdio | http | sse
"host": "127.0.0.1", // HTTP only (replaces FASTMCP_HOST)
"port": 8000, // HTTP onlPractical MCP with FastMCP & LangChain
Engineering the Agentic ExperienceEnroll now to unlock current content and receive all future updates for free. Your purchase supports the author and fuels the creation of more exciting content. Act fast, as the price will rise as the course nears completion!
