Build Your First FastMCP Server in Python
Write a single-file server with a tool, a resource and a prompt, run it locally or over HTTP and call it from Python.
Read articleCheck your Python version, install the package with uv or pip, confirm it works and fix the problems people meet most often.

uv add fastmcp or pip install fastmcp inside a virtual environment.fastmcp version.FastMCP is distributed as an ordinary Python package on PyPI, so installing it takes only a few commands. This guide walks through every step on Windows, macOS and Linux, then covers verification, optional extras, version pinning, upgrades and the problems people run into most often.
By the end you will have FastMCP installed in an isolated environment, the fastmcp command-line tool available in your terminal and a clear idea of how to keep the installation up to date.
The current release of FastMCP requires Python 3.11 or later; the package classifiers list support up to Python 3.15. Open a terminal and check which version you have:
python --version
# On macOS and Linux the command is often python3
python3 --versionIf the output shows 3.10 or older, install a newer interpreter before continuing. You will also need an internet connection for the first installation, as packages are downloaded from PyPI.
Download the latest installer from python.org and tick Add python.exe to PATH during setup. Windows also installs the py launcher, which lets you choose a version explicitly, for example py -3.12 --version. Use PowerShell or Windows Terminal for the commands in this guide.
macOS ships with an older system Python that you should leave alone. Install a current version from python.org or with Homebrew (brew install python@3.12), then use python3 in the Terminal app.
Most distributions offer a recent Python through their package manager. On Debian or Ubuntu, for example, sudo apt install python3 python3-venv provides both the interpreter and the venv module. If your distribution only offers an older release, uv can download a suitable interpreter for you.
Both tools install exactly the same package. The difference lies in how they manage your project.
| uv | pip | |
|---|---|---|
| Recommended by the FastMCP documentation | Yes | Fully supported |
| Creates the virtual environment | Automatically | You create it with venv |
| Records dependencies | pyproject.toml and a lockfile | Manually, for example in requirements.txt |
| Speed | Very fast | Moderate |
| Best for | New projects and teams | Existing pip-based workflows |
If you are starting from scratch, uv is the simpler path. If your organisation already standardises on pip, there is no need to change.
Keeping each project in its own environment prevents version clashes between packages. Choose one of the two options below.
# Option A: uv creates the project and its environment
uv init my-mcp-project
cd my-mcp-project
# Option B: the built-in venv module
mkdir my-mcp-project && cd my-mcp-project
python -m venv .venv
source .venv/bin/activate # macOS and Linux
.venv\Scripts\activate # Windows PowerShellWhen a virtual environment is active, most shells show its name in brackets at the start of the prompt. That is a quick way to confirm you are installing into the right place.
Inside your project folder, add FastMCP as a dependency:
uv add fastmcpuv resolves the dependency tree, installs everything into the project’s environment, records FastMCP in pyproject.toml and writes uv.lock. Commit both files: anyone who clones the project can recreate the identical environment with uv sync.
To run commands inside the environment without activating it, prefix them with uv run, for example uv run fastmcp version.
With your virtual environment active, run:
pip install fastmcpTo make the installation reproducible, record the exact version afterwards:
pip freeze > requirements.txtBoth methods install the same package from PyPI, together with the fastmcp command-line tool.
Confirm that the package and its CLI are available:
fastmcp versionThe output lists the FastMCP version, the MCP protocol library version, your Python version, the platform and the installation path. If you see these details, the installation is complete.
For a final check, create a two-line server and run it. If it starts without errors, everything is wired up correctly:
# check.py
from fastmcp import FastMCP
mcp = FastMCP("Check")fastmcp run check.py:mcpPress Ctrl+C to stop it.
Some features depend on additional packages that are not installed by default. They are published as extras, which you request in square brackets:
pip install "fastmcp[tasks]" # background tasks
pip install "fastmcp[apps]" # interactive app interfaces
uv add "fastmcp[apps]" # the same with uvPyPI also lists extras for openai, anthropic, gemini, azure and code-mode, among others. Install only those you need; each one adds dependencies to your environment and to anything you deploy.
FastMCP follows semantic versioning, but its documentation notes that breaking changes may appear in minor releases so that the framework can keep pace with the protocol. For anything other people rely on, pin the version deliberately.
# pip
pip install "fastmcp==4.2.0"
# uv
uv add "fastmcp==4.2.0"pip install --upgrade fastmcp
# or, with uv
uv add fastmcp --upgradeMost servers written for FastMCP 3 run on version 4 without changes, and the official upgrade notes list the exceptions. If you are moving from FastMCP 2, read its separate upgrade guide first. Code that uses the copy of FastMCP 1.0 bundled in the official MCP SDK (from mcp.server.fastmcp import FastMCP) usually needs only an import change.
A sensible routine is to upgrade on a branch, run your test suite, read the release notes for anything relevant and only then merge.
pip uninstall fastmcp
# or, with uv
uv remove fastmcpDeleting the project’s .venv folder removes everything that was installed into it.
uv run fastmcp version.py -3.12 -m venv .venv on Windows.pip install --force-reinstall fastmcp. If that does not help, uninstall both fastmcp and fastmcp-slim, then install again. uv upgrades are not affected.which python on macOS and Linux, or where python on Windows, to see which interpreter runs first on your path.sudo pip. Use a virtual environment instead, which needs no administrator rights.pip install -U cyclopts rich-rst resolves this in existing environments, and fresh installs are unaffected.With FastMCP installed, the natural next move is to write a small server. The guide on building your first FastMCP server picks up exactly where this one ends, and the article on tools, resources and prompts explains which component to use for each job.
No. Installing into a virtual environment requires no administrator rights on Windows, macOS or Linux. Avoid sudo pip, which can damage the system Python and cause permission problems later.
You can, but it is not recommended. Separate environments stop one project's dependencies from breaking another's, and they make deployments reproducible. uv creates and manages these environments for you automatically.
Run fastmcp version. It prints the FastMCP version together with the MCP library version, your Python version and the platform, which is also useful information to include in a bug report.
No. The ZIP contains the full source repository, which is useful for reading the code or contributing. For building servers, installing from PyPI with pip or uv is simpler and keeps updates straightforward.
Write a single-file server with a tool, a resource and a prompt, run it locally or over HTTP and call it from Python.
Read articleThe three MCP building blocks compared: what each one does, how to declare it and which to choose for a given job.
Read articleHow the STDIO and HTTP transports differ, when to use each and how to switch between them with a single argument.
Read article