mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 07:09:11 +02:00
126 lines
5.1 KiB
Text
126 lines
5.1 KiB
Text
---
|
|
title: Installation
|
|
description: Install FastMCP and verify your setup
|
|
icon: arrow-down-to-line
|
|
---
|
|
## Install FastMCP
|
|
|
|
We recommend using [uv](https://docs.astral.sh/uv/getting-started/installation/) to install and manage FastMCP.
|
|
|
|
```bash
|
|
uv add fastmcp
|
|
```
|
|
|
|
Or with pip:
|
|
|
|
```bash
|
|
pip install fastmcp
|
|
```
|
|
|
|
<Note>
|
|
**FastMCP 4 is in prerelease.** The commands above install the latest stable release, which is still 3.x. To get v4, pin the beta explicitly with `pip install "fastmcp==4.0.0b1"`, or see [Install the v4 Prerelease](/getting-started/upgrading/from-fastmcp-3#install-the-v4-prerelease) for the uv constraint you'll need.
|
|
</Note>
|
|
|
|
### Optional Dependencies
|
|
|
|
FastMCP provides optional extras for specific features. For example, to install the background tasks extra:
|
|
|
|
```bash
|
|
pip install "fastmcp[tasks]"
|
|
```
|
|
|
|
See [Background Tasks](/servers/tasks) for details on the task system.
|
|
|
|
### Verify Installation
|
|
|
|
To verify that FastMCP is installed correctly, you can run the following command:
|
|
|
|
```bash
|
|
fastmcp version
|
|
```
|
|
|
|
You should see output like the following:
|
|
|
|
```bash
|
|
$ fastmcp version
|
|
|
|
FastMCP version: 4.0.0b1
|
|
MCP version: 2.0.0
|
|
Python version: 3.12.2
|
|
Platform: macOS-15.3.1-arm64-arm-64bit
|
|
FastMCP root path: ~/Developer/fastmcp
|
|
```
|
|
|
|
### Dependency Licensing
|
|
|
|
<Info>
|
|
FastMCP depends on Cyclopts for CLI functionality. Cyclopts v4 includes docutils as a transitive dependency, which has complex licensing that may trigger compliance reviews in some organizations.
|
|
|
|
If this is a concern, you can install Cyclopts v5 alpha which removes this dependency:
|
|
|
|
```bash
|
|
pip install "cyclopts>=5.0.0a1"
|
|
```
|
|
|
|
Alternatively, wait for the stable v5 release. See [this issue](https://github.com/BrianPugh/cyclopts/issues/672) for details.
|
|
</Info>
|
|
## Upgrading
|
|
|
|
### From FastMCP 3.0
|
|
|
|
Most FastMCP 3 servers run on 4 without changes. See [Upgrading from FastMCP 3](/getting-started/upgrading/from-fastmcp-3) for the breaks that do exist, and [What's New](/getting-started/whats-new) for what the new version adds.
|
|
|
|
### From FastMCP 2.0
|
|
|
|
See the [Upgrade Guide](/getting-started/upgrading/from-fastmcp-2) for a complete list of breaking changes and migration steps.
|
|
|
|
### From the MCP SDK
|
|
|
|
Which guide you want depends on which `mcp` version you're on and which of its two server APIs you used.
|
|
|
|
#### From the high-level server
|
|
|
|
If you're using FastMCP 1.0 via SDK v1 (meaning you import FastMCP as `from mcp.server.fastmcp import FastMCP`), upgrading is straightforward — for most servers it's a single import change. See [Upgrading from MCP SDK v1](/getting-started/upgrading/from-mcp-sdk-v1), which also explains why that route is usually easier than moving to MCP SDK v2.
|
|
|
|
If you already moved to SDK v2 and write against `MCPServer`, see [Upgrading from MCP SDK v2](/getting-started/upgrading/from-mcp-sdk-v2) — that migration is mostly renaming.
|
|
|
|
#### From the low-level server
|
|
|
|
If you built your server directly on the `mcp` package's `Server` class, the guide you want depends on how its handlers are registered. Decorators like `@server.list_tools()` mean SDK v1 — see [Upgrading from the Low-Level SDK v1](/getting-started/upgrading/from-low-level-sdk-v1). Handlers passed to the constructor as `on_list_tools=` mean SDK v2 — see [Upgrading from the Low-Level SDK v2](/getting-started/upgrading/from-low-level-sdk-v2).
|
|
|
|
## Troubleshooting
|
|
|
|
### `import fastmcp` fails after a pip upgrade
|
|
|
|
This affects one specific case: upgrading to FastMCP 3.3 or later from FastMCP 3.2 or earlier with `pip`. Fresh installs and `uv` upgrades are unaffected, so you can skip this unless you did exactly that.
|
|
|
|
If `import fastmcp` raises `ModuleNotFoundError`, or `from fastmcp import FastMCP` raises `ImportError`, immediately after the upgrade, your install is in a half-removed state. Reinstall in a single step:
|
|
|
|
```bash
|
|
pip install --force-reinstall fastmcp
|
|
```
|
|
|
|
If that doesn't resolve it, remove both distributions and reinstall from a clean state:
|
|
|
|
```bash
|
|
pip uninstall -y fastmcp fastmcp-slim
|
|
pip install fastmcp
|
|
```
|
|
|
|
FastMCP 3.3 moved the importable code from the `fastmcp` distribution into `fastmcp-slim`. During a single-command `pip` upgrade, pip can install the new files and then delete them while uninstalling the old `fastmcp` distribution, whose file manifest still lists those paths. `uv` uninstalls before it installs, so it is unaffected.
|
|
|
|
## Versioning Policy
|
|
|
|
FastMCP follows semantic versioning with pragmatic adaptations for the rapidly evolving MCP ecosystem. Breaking changes may occur in minor versions (e.g., 2.3.x to 2.4.0) when necessary to stay current with the MCP Protocol.
|
|
|
|
For production use, always pin to exact versions:
|
|
```
|
|
fastmcp==4.0.0b1 # Good - an exact version
|
|
fastmcp>=4.0.0 # Bad - may install breaking changes
|
|
```
|
|
|
|
See the full [versioning and release policy](/development/releases#versioning-policy) for details on our public API, deprecation practices, and breaking change philosophy.
|
|
|
|
## Contributing to FastMCP
|
|
|
|
The [Contributing Guide](/development/contributing) covers setting up a development environment, running the test suite and pre-commit hooks, and the standards we hold contributed code to.
|