Skip to main content
This integration focuses on running local FastMCP server files with STDIO transport. For remote servers running with HTTP or SSE transport, use your client's native configuration - FastMCP's integrations focus on simplifying the complex local setup with dependencies and uv commands.
Claude Code supports MCP servers through multiple transport methods including STDIO, SSE, and HTTP, allowing you to extend Claude’s capabilities with custom tools, resources, and prompts from your FastMCP servers.

Requirements

This integration uses STDIO transport to run your FastMCP server locally. For remote deployments, you can run your FastMCP server with HTTP or SSE transport and configure it directly using Claude Code’s built-in MCP management commands.

Create a Server

The examples in this guide will use the following simple dice-rolling server, saved as server.py.
server.py

Install the Server

FastMCP CLI

New in version 2.10.3 The easiest way to install a FastMCP server in Claude Code is using the fastmcp install claude-code command. This automatically handles the configuration, dependency management, and calls Claude Code’s built-in MCP management system.
The install command supports the same file.py:object notation as the run command. If no object is specified, it will automatically look for a FastMCP server object named mcp, server, or app in your file:
The command will automatically configure the server with Claude Code’s claude mcp add command.

Dependencies

FastMCP provides flexible dependency management options for your Claude Code servers: Individual packages: Use the --with flag to specify packages your server needs. You can use this flag multiple times:
Requirements file: If you maintain a requirements.txt file with all your dependencies, use --with-requirements to install them:
Editable packages: For local packages under development, use --with-editable to install them in editable mode:
Alternatively, you can use a fastmcp.json configuration file (recommended):
fastmcp.json
Pass the configuration file to the install command in place of the server file:

Python Version and Project Configuration

Control the Python environment for your server with these options: Python version: Use --python to specify which Python version your server requires. This ensures compatibility when your server needs specific Python features:
Project directory: Use --project to select the directory containing your MCP server’s pyproject.toml. FastMCP passes this to uv run --project, which discovers the project’s configuration and installs its dependencies into the project environment:
--project selects the Python environment without changing the server’s working directory. If your server reads local files, use absolute paths or resolve them relative to the server file.

Environment Variables

If your server needs environment variables (like API keys), you must include them:
Or load them from a .env file:
Claude Code must be installed. The integration looks for the claude executable on your PATH, then in common install locations such as ~/.claude/local/claude, and uses the claude mcp add command to register servers.

Manual Configuration

For more control over the configuration, you can manually use Claude Code’s built-in MCP management commands. This gives you direct control over how your server is launched:
You can also manually specify Python versions and project directories in your Claude Code commands:

Using the Server

Once your server is installed, you can start using your FastMCP server with Claude Code. Try asking Claude something like:
“Roll some dice for me”
Claude will automatically detect your roll_dice tool and use it to fulfill your request, returning something like:
I’ll roll some dice for you! Here are your results: [4, 2, 6] You rolled three dice and got a 4, a 2, and a 6!
Claude Code can now access all the tools, resources, and prompts you’ve defined in your FastMCP server. If your server provides resources, you can reference them with @ mentions using the format @server:protocol://resource/path. If your server provides prompts, you can use them as slash commands with /mcp__servername__promptname.