Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423---title: MCP JSON Configuration 🤝 FastMCPsidebarTitle: MCP.jsondescription: Generate standard MCP configuration files for any compatible clienticon: brackets-curly---
import { VersionBadge } from "/snippets/version-badge.mdx"
<VersionBadge version="2.10.3" />
FastMCP can generate standard MCP JSON configuration files that work with any MCP-compatible client including Claude Desktop, VS Code, Cursor, and other applications that support the Model Context Protocol.
## MCP JSON Configuration Standard
The MCP JSON configuration format is an **emergent standard** that has developed across the MCP ecosystem. This format defines how MCP clients should configure and launch MCP servers, providing a consistent way to specify server commands, arguments, and environment variables.
### Configuration Structure
The standard uses a `mcpServers` object where each key represents a server name and the value contains the server's configuration:
```json{ "mcpServers": { "server-name": { "command": "executable", "args": ["arg1", "arg2"], "env": { "VAR": "value" } } }}```
### Server Configuration Fields
#### `command` (required)The executable command to run the MCP server. This should be an absolute path or a command available in the system PATH.
```json{ "command": "python"}```
#### `args` (optional)An array of command-line arguments passed to the server executable. Arguments are passed in order.
```json{ "args": ["server.py", "--verbose", "--port", "8080"]}```
#### `env` (optional)An object containing environment variables to set when launching the server. All values must be strings.
```json{ "env": { "API_KEY": "secret-key", "DEBUG": "true", "PORT": "8080" }}```
### Client Adoption
This format is widely adopted across the MCP ecosystem:
- **Claude Desktop**: Uses `~/.claude/claude_desktop_config.json`- **Cursor**: Uses `~/.cursor/mcp.json`- **VS Code**: Uses workspace `.vscode/mcp.json`- **Other clients**: Many MCP-compatible applications follow this standard
## Overview
<Note>**For the best experience, use FastMCP's first-class integrations:** [`fastmcp install claude-code`](/integrations/claude-code), [`fastmcp install claude-desktop`](/integrations/claude-desktop), or [`fastmcp install cursor`](/integrations/cursor). Use MCP JSON generation for advanced use cases and unsupported clients.</Note>
The `fastmcp install mcp-json` command generates configuration in the standard `mcpServers` format used across the MCP ecosystem. This is useful when:
- **Working with unsupported clients** - Any MCP client not directly integrated with FastMCP- **CI/CD environments** - Automated configuration generation for deployments - **Configuration sharing** - Easy distribution of server setups to team members- **Custom tooling** - Integration with your own MCP management tools- **Manual setup** - When you prefer to manually configure your MCP client
## Basic Usage
Generate configuration and output to stdout (useful for piping):
```bashfastmcp install mcp-json server.py```
This outputs the server configuration JSON with the server name as the root key:
```json{ "My Server": { "command": "uv", "args": [ "run", "--with", "fastmcp", "fastmcp", "run", "/absolute/path/to/server.py" ] }}```
To use this in a client configuration file, add it to the `mcpServers` object in your client's configuration:
```json{ "mcpServers": { "My Server": { "command": "uv", "args": [ "run", "--with", "fastmcp", "fastmcp", "run", "/absolute/path/to/server.py" ] } }}```
<Note>When using `--python`, `--project`, or `--with-requirements`, the generated configuration will include these options in the `uv run` command, ensuring your server runs with the correct Python version and dependencies.</Note>
<Note>Different MCP clients may have specific configuration requirements or formatting needs. Always consult your client's documentation to ensure proper integration.</Note>
## Configuration Options
### Server Naming
```bash# Use server's built-in name (from FastMCP constructor)fastmcp install mcp-json server.py
# Override with custom namefastmcp install mcp-json server.py --name "Custom Server Name"```
### Dependencies
Add Python packages your server needs:
```bash# Single packagefastmcp install mcp-json server.py --with pandas
# Multiple packages fastmcp install mcp-json server.py --with pandas --with requests --with httpx
# Editable local packagefastmcp install mcp-json server.py --with-editable ./my-package
# From requirements filefastmcp install mcp-json server.py --with-requirements requirements.txt```
You can also use a `fastmcp.json` configuration file (recommended):
```json fastmcp.json{ "$schema": "https://gofastmcp.com/public/schemas/fastmcp.json/v1.json", "source": { "path": "server.py", "entrypoint": "mcp" }, "environment": { "dependencies": ["pandas", "matplotlib", "seaborn"] }}```
Then simply install with:```bashfastmcp install mcp-json fastmcp.json```
### Environment Variables
```bash# Individual environment variablesfastmcp install mcp-json server.py \ --env API_KEY=your-secret-key \ --env DEBUG=true
# Load from .env filefastmcp install mcp-json server.py --env-file .env```
### Python Version and Project Directory
Specify Python version or run within a specific project:
```bash# Use specific Python versionfastmcp install mcp-json server.py --python 3.11
# Run within a project directoryfastmcp install mcp-json server.py --project /path/to/project```
### Server Object Selection
Use the same `file.py:object` notation as other FastMCP commands:
```bash# Auto-detects server object (looks for 'mcp', 'server', or 'app')fastmcp install mcp-json server.py
# Explicit server objectfastmcp install mcp-json server.py:my_custom_server```
## Clipboard Integration
Copy configuration directly to your clipboard for easy pasting:
```bashfastmcp install mcp-json server.py --copy```
<Note>The `--copy` flag requires the `pyperclip` Python package. If not installed, you'll see an error message with installation instructions.</Note>
## Usage Examples
### Basic Server
```bashfastmcp install mcp-json dice_server.py```
Output:```json{ "Dice Server": { "command": "uv", "args": [ "run", "--with", "fastmcp", "fastmcp", "run", "/home/user/dice_server.py" ] }}```
### Production Server with Dependencies
```bashfastmcp install mcp-json api_server.py \ --name "Production API Server" \ --with requests \ --with python-dotenv \ --env API_BASE_URL=https://api.example.com \ --env TIMEOUT=30```
### Advanced Configuration
```bashfastmcp install mcp-json ml_server.py \ --name "ML Analysis Server" \ --python 3.11 \ --with-requirements requirements.txt \ --project /home/user/ml-project \ --env GPU_DEVICE=0```
Output:```json{ "Production API Server": { "command": "uv", "args": [ "run", "--with", "fastmcp", "--with", "python-dotenv", "--with", "requests", "fastmcp", "run", "/home/user/api_server.py" ], "env": { "API_BASE_URL": "https://api.example.com", "TIMEOUT": "30" } }}```
The advanced configuration example generates:```json{ "ML Analysis Server": { "command": "uv", "args": [ "run", "--python", "3.11", "--project", "/home/user/ml-project", "--with", "fastmcp", "--with-requirements", "requirements.txt", "fastmcp", "run", "/home/user/ml_server.py" ], "env": { "GPU_DEVICE": "0" } }}```
### Pipeline Usage
Save configuration to file:
```bashfastmcp install mcp-json server.py > mcp-config.json```
Use in shell scripts:
```bash#!/bin/bashCONFIG=$(fastmcp install mcp-json server.py --name "CI Server")echo "$CONFIG" | jq '."CI Server".command'# Output: "uv"```
## Integration with MCP Clients
The generated configuration works with any MCP-compatible application:
### Claude Desktop<Note>**Prefer [`fastmcp install claude-desktop`](/integrations/claude-desktop)** for automatic installation. Use MCP JSON for advanced configuration needs.</Note>Copy the `mcpServers` object into `~/.claude/claude_desktop_config.json`
### Cursor<Note>**Prefer [`fastmcp install cursor`](/integrations/cursor)** for automatic installation. Use MCP JSON for advanced configuration needs.</Note>Add to `~/.cursor/mcp.json`
### VS Code Add to your workspace's `.vscode/mcp.json` file
### Custom ApplicationsUse the JSON configuration with any application that supports the MCP protocol
## Configuration Format
The generated configuration outputs a server object with the server name as the root key:
```json{ "<server-name>": { "command": "<executable>", "args": ["<arg1>", "<arg2>", "..."], "env": { "<ENV_VAR>": "<value>" } }}```
To use this in an MCP client, add it to the client's `mcpServers` configuration object.
**Fields:**- `command`: The executable to run (always `uv` for FastMCP servers)- `args`: Command-line arguments including dependencies and server path- `env`: Environment variables (only included if specified)
<Warning>**All file paths in the generated configuration are absolute paths**. This ensures the configuration works regardless of the working directory when the MCP client starts the server.</Warning>
## Requirements
- **uv**: Must be installed and available in your system PATH- **pyperclip** (optional): Required only for `--copy` functionality
Install uv if not already available:
```bash# macOSbrew install uv
# Linux/Windows curl -LsSf https://astral.sh/uv/install.sh | sh```