MCP Servers · Publisher repository

FastMCP

A Python MCP application framework for building servers, clients, and interactive apps through one API, with stdio and Streamable HTTP transports.

27.6k StarsApache-2.0PythonUpdated 1 day ago
01

Project overview

FastMCP is a Python application framework for the Model Context Protocol. It puts server-side tool, resource, and prompt declarations, client connections, and interactive apps behind one Python API. A minimal server creates a FastMCP instance and registers a typed function; stdio works locally, while Streamable HTTP supports remote deployments.

02

Core capabilities

01

Define MCP tools, resources, and prompts with Python functions

Create a FastMCP instance and use decorators to register typed Python functions as tools while organizing resources and prompts in the same framework.

02

Build MCP clients for local or remote servers

The Client API supports in-process connections, stdio subprocesses, and HTTP endpoints for testing or orchestration.

03

Extend servers with middleware, authentication, providers, and transforms

Server documentation describes extension points for controlling requests, capability sources, and exposed behavior.

04

Build interactive MCP apps for supported clients

FastMCP Apps can provide in-conversation interfaces inside clients that support the capability.

03

Setup and connection

Install FastMCP with uv or pip in an isolated Python 3.10 or newer environment, then create a minimal server and launch it over stdio.

AI AGENT INSTALL

Let an AI Agent install it

Send this prompt to Codex, Claude Code, or another AI agent that can work with your local environment.

Help me install FastMCP from https://github.com/PrefectHQ/fastmcp. First read README.md, docs/getting-started/installation.mdx, docs/getting-started/quickstart.mdx, and pyproject.toml. Confirm that Python is at least 3.10 and use an isolated environment. Follow the documented uv add fastmcp command; if the project does not use uv, use pip install fastmcp instead. Explain and recommend an exact compatible pin before changing a production project's lockfile, and do not overwrite existing dependency files without permission. After installation, run fastmcp version, create the official minimal greet server, and run fastmcp run my_server.py:mcp. Report the installed version, changed files, startup result, and any unverified items. Ask before requesting credentials, expanding file or network access, opening an HTTP port, overwriting files, or taking any risky action.
01Before you start
  • Python 3.10 or newer
  • uv or pip and an isolated Python virtual environment
  • Permission to create a Python file and start a local process
02Copy the install command or configuration
uv add fastmcp
03Complete the setup steps
  1. 1
    Install and check the CLI

    Run uv add fastmcp in an isolated environment, then run fastmcp version. If using pip, follow the documented alternative command pip install fastmcp.

  2. 2
    Create a minimal MCP server

    Create my_server.py, import FastMCP, set mcp = FastMCP("My MCP Server"), and decorate a typed Python function that accepts a name and returns a greeting with @mcp.tool.

  3. 3
    Launch over stdio

    Run fastmcp run my_server.py:mcp. stdio is the default transport and works for a local MCP client that starts the server as a subprocess.

  4. 4
    Switch to HTTP when needed

    For a remote or self-hosted deployment, run fastmcp run my_server.py:mcp --transport http --port 8000. Configure authentication, error masking, and network controls before exposure.

How to verify the setup

Run fastmcp version to confirm the CLI is available. Save the quickstart example as my_server.py and run fastmcp run my_server.py:mcp. A process that remains running without import or startup errors passes the minimal installation check.

Before using it
  • Pin an exact tested version in production; v4.0.3 was the latest stable release when this page was verified.
  • Prefer stdio or Streamable HTTP for new projects; SSE is a legacy transport.
  • Install the tasks extra only when background task support is required.
04

Use cases

SCENARIO 01

Wrap internal Python capabilities as MCP tools

Expose typed inputs and outputs from existing functions to agents while keeping business dependencies and access controls inside the server process.

SCENARIO 02

Write automated clients for MCP services

Use the Client API in tests or orchestration code to list and call tools through in-process, stdio, or HTTP connections.

SCENARIO 03

Deploy an authenticated remote MCP endpoint

Combine Streamable HTTP, middleware, and authentication extensions for a self-hosted service while retaining responsibility for network and credential boundaries.

05

Assessment

FastMCP's main advantage is one Python API spanning server, client, and app development, with a clear path from local stdio to HTTP deployment. It is still a framework that executes business code with process-level permissions, so production adoption requires version pins, transport and authentication review, and an audit of each real tool.

Why it may be useful

  • The minimal example is short and registers ordinary Python functions as MCP tools.
  • It covers servers, clients, apps, middleware, authentication, and providers in one project.
  • Installation, quickstart, and core API documentation are available, and the repository remains actively maintained.

What to know first

  • It does not provide managed hosting, default business-level isolation, or automatic security review.
  • Production deployments must handle authentication, network exposure, credentials, and tool permissions.
  • The docs warn that ecosystem compatibility can cause minor-version breaks, while the current SECURITY.md support table still trails the v4 release.
06

README

FastMCP


Overview

A Python MCP application framework for building servers, clients, and interactive apps through one API, with stdio and Streamable HTTP transports. 🚀 The fast, Pythonic way to build MCP servers and clients.

Getting started

  • Install FastMCP with uv or pip in an isolated Python 3.10 or newer environment, then create a minimal server and launch it over stdio.
  • Servers can expose Python functions, resources, and prompt templates as MCP capabilities, with authentication, middleware, providers, and transforms available as extensions.
  • Clients can connect to in-memory servers, stdio subprocesses, or remote HTTP endpoints and use an asynchronous API to list and call capabilities.
  • Run fastmcp version to confirm the CLI is available. Save the quickstart example as my_server.py and run fastmcp run my_server.py:mcp. A process that remains running without import or startup errors passes the minimal installation check.

Configuration

uv add fastmcp
Read the complete README on GitHub