Spaces:
Running
Running
Jeremiah Lowin commited on
Commit Β·
f80ec7c
1
Parent(s): 0332908
update readme
Browse files- README.md +68 -48
- docs/getting-started/welcome.mdx +7 -4
README.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
| 4 |
# FastMCP v2 π
|
| 5 |
<strong>The fast, Pythonic way to build MCP servers.</strong>
|
| 6 |
|
|
|
|
| 7 |
[](https://pypi.org/project/fastmcp)
|
| 8 |
[](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
|
| 9 |
[](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
|
|
@@ -27,48 +28,27 @@ if __name__ == "__main__":
|
|
| 27 |
mcp.run()
|
| 28 |
```
|
| 29 |
|
| 30 |
-
Run it locally for testing:
|
| 31 |
-
```bash
|
| 32 |
-
fastmcp dev server.py
|
| 33 |
-
```
|
| 34 |
|
| 35 |
-
|
| 36 |
```bash
|
| 37 |
-
fastmcp
|
| 38 |
```
|
| 39 |
|
| 40 |
FastMCP handles the complex protocol details and server management, letting you focus on building great tools and applications. It's designed to feel natural to Python developers.
|
| 41 |
|
| 42 |
-
## Key Features:
|
| 43 |
-
|
| 44 |
-
* **Simple Server Creation:** Build MCP servers with minimal boilerplate using intuitive decorators (`@tool`, `@resource`, `@prompt`).
|
| 45 |
-
* **Proxy MCP Servers:** Create proxy servers to expose existing MCP servers or clients with modifications, or convert between transport protocols (e.g., expose a Stdio server via SSE for web access).
|
| 46 |
-
* **Compose MCP Servers:** Compose complex applications by mounting multiple FastMCP servers together.
|
| 47 |
-
* **API Generation:** Automatically create MCP servers from existing **OpenAPI specifications** or **FastAPI applications**.
|
| 48 |
-
* **Powerful Clients:** Programmatically interact with *any* MCP server, regardless of how it was built.
|
| 49 |
-
* **LLM Sampling:** Request completions from client LLMs directly within your MCP tools.
|
| 50 |
-
* **Pythonic Interface:** Designed with familiar Python patterns like decorators and type hints.
|
| 51 |
-
* **Context Injection:** Easily access core MCP capabilities like sampling, logging, and progress reporting within your functions.
|
| 52 |
-
|
| 53 |
-
---
|
| 54 |
-
|
| 55 |
-
### What's New in v2?
|
| 56 |
-
|
| 57 |
-
FastMCP 1.0 made it so easy to build MCP servers that it's now part of the [official Model Context Protocol Python SDK](https://github.com/modelcontextprotocol/python-sdk)! For basic use cases, you can use the upstream version by importing `mcp.server.fastmcp.FastMCP` (or installing `fastmcp=1.0`).
|
| 58 |
-
|
| 59 |
-
Based on how the MCP ecosystem is evolving, FastMCP 2.0 builds on that foundation to introduce a variety of new features (and more experimental ideas). It adds advanced features like proxying and composing MCP servers, as well as automatically generating them from OpenAPI specs or FastAPI objects. FastMCP 2.0 also introduces new client-side functionality like LLM sampling.
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
---
|
| 63 |
|
| 64 |
<!-- omit in toc -->
|
| 65 |
## Table of Contents
|
| 66 |
|
| 67 |
-
- [Key Features:](#key-features)
|
| 68 |
-
- [What's New in v2?](#whats-new-in-v2)
|
| 69 |
-
- [Installation](#installation)
|
| 70 |
-
- [Quickstart](#quickstart)
|
| 71 |
- [What is MCP?](#what-is-mcp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
- [Core Concepts](#core-concepts)
|
| 73 |
- [The `FastMCP` Server](#the-fastmcp-server)
|
| 74 |
- [Tools](#tools)
|
|
@@ -98,7 +78,62 @@ Based on how the MCP ecosystem is evolving, FastMCP 2.0 builds on that foundatio
|
|
| 98 |
- [Formatting \& Linting](#formatting--linting)
|
| 99 |
- [Pull Requests](#pull-requests)
|
| 100 |
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
We strongly recommend installing FastMCP with [uv](https://docs.astral.sh/uv/), as it is required for deploying servers via the CLI:
|
| 104 |
|
|
@@ -117,7 +152,7 @@ cd fastmcp
|
|
| 117 |
uv sync
|
| 118 |
```
|
| 119 |
|
| 120 |
-
## Quickstart
|
| 121 |
|
| 122 |
Let's create a simple MCP server that exposes a calculator tool and some data:
|
| 123 |
|
|
@@ -146,23 +181,8 @@ You can install this server in [Claude Desktop](https://claude.ai/download) and
|
|
| 146 |
fastmcp install server.py
|
| 147 |
```
|
| 148 |
|
| 149 |
-
Alternatively, you can test it with the MCP Inspector:
|
| 150 |
-
```bash
|
| 151 |
-
fastmcp dev server.py
|
| 152 |
-
```
|
| 153 |
-
|
| 154 |

|
| 155 |
|
| 156 |
-
## What is MCP?
|
| 157 |
-
|
| 158 |
-
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
|
| 159 |
-
|
| 160 |
-
- Expose data through **Resources** (think GET endpoints; load info into context)
|
| 161 |
-
- Provide functionality through **Tools** (think POST/PUT endpoints; execute actions)
|
| 162 |
-
- Define interaction patterns through **Prompts** (reusable templates)
|
| 163 |
-
- And more!
|
| 164 |
-
|
| 165 |
-
FastMCP provides a high-level, Pythonic interface for building and interacting with these servers.
|
| 166 |
|
| 167 |
## Core Concepts
|
| 168 |
|
|
|
|
| 4 |
# FastMCP v2 π
|
| 5 |
<strong>The fast, Pythonic way to build MCP servers.</strong>
|
| 6 |
|
| 7 |
+
[](https://gofastmcp.com)
|
| 8 |
[](https://pypi.org/project/fastmcp)
|
| 9 |
[](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
|
| 10 |
[](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
|
|
|
|
| 28 |
mcp.run()
|
| 29 |
```
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
Run the server locally:
|
| 33 |
```bash
|
| 34 |
+
fastmcp run server.py
|
| 35 |
```
|
| 36 |
|
| 37 |
FastMCP handles the complex protocol details and server management, letting you focus on building great tools and applications. It's designed to feel natural to Python developers.
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
<!-- omit in toc -->
|
| 41 |
## Table of Contents
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
- [What is MCP?](#what-is-mcp)
|
| 44 |
+
- [Why FastMCP?](#why-fastmcp)
|
| 45 |
+
- [Key Features](#key-features)
|
| 46 |
+
- [Servers](#servers)
|
| 47 |
+
- [Clients](#clients)
|
| 48 |
+
- [What's New in v2?](#whats-new-in-v2)
|
| 49 |
+
- [Documentation](#documentation)
|
| 50 |
+
- [Installation](#installation)
|
| 51 |
+
- [Quickstart](#quickstart)
|
| 52 |
- [Core Concepts](#core-concepts)
|
| 53 |
- [The `FastMCP` Server](#the-fastmcp-server)
|
| 54 |
- [Tools](#tools)
|
|
|
|
| 78 |
- [Formatting \& Linting](#formatting--linting)
|
| 79 |
- [Pull Requests](#pull-requests)
|
| 80 |
|
| 81 |
+
|
| 82 |
+
## What is MCP?
|
| 83 |
+
|
| 84 |
+
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
|
| 85 |
+
|
| 86 |
+
- Expose data through **Resources** (think GET endpoints; load info into context)
|
| 87 |
+
- Provide functionality through **Tools** (think POST/PUT endpoints; execute actions)
|
| 88 |
+
- Define interaction patterns through **Prompts** (reusable templates)
|
| 89 |
+
- And more!
|
| 90 |
+
|
| 91 |
+
FastMCP provides a high-level, Pythonic interface for building and interacting with these servers.
|
| 92 |
+
|
| 93 |
+
## Why FastMCP?
|
| 94 |
+
|
| 95 |
+
The MCP protocol is powerful but implementing it involves a lot of boilerplate - server setup, protocol handlers, content types, error management. FastMCP handles all the complex protocol details and server management, so you can focus on building great tools. Itβs designed to be high-level and Pythonic; in most cases, decorating a function is all you need.
|
| 96 |
+
|
| 97 |
+
FastMCP aims to be:
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
π **Fast:** High-level interface means less code and faster development
|
| 101 |
+
|
| 102 |
+
π **Simple:** Build MCP servers with minimal boilerplate
|
| 103 |
+
|
| 104 |
+
π **Pythonic:** Feels natural to Python developers
|
| 105 |
+
|
| 106 |
+
π **Complete:** FastMCP aims to provide a full implementation of the core MCP specification for both servers and clients
|
| 107 |
+
|
| 108 |
+
## Key Features
|
| 109 |
+
|
| 110 |
+
### Servers
|
| 111 |
+
- **Create** servers with minimal boilerplate using intuitive decorators
|
| 112 |
+
- **Proxy** existing servers to modify configuration or transport
|
| 113 |
+
- **Compose** servers by into complex applications
|
| 114 |
+
- **Generate** servers from OpenAPI specs or FastAPI objects
|
| 115 |
+
|
| 116 |
+
### Clients
|
| 117 |
+
- **Interact** with MCP servers programmatically
|
| 118 |
+
- **Connect** to any MCP server using any transport
|
| 119 |
+
- **Test** your servers without manual intervention
|
| 120 |
+
- **Innovate** with core MCP capabilities like LLM sampling
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
## What's New in v2?
|
| 124 |
+
|
| 125 |
+
FastMCP 1.0 made it so easy to build MCP servers that it's now part of the [official Model Context Protocol Python SDK](https://github.com/modelcontextprotocol/python-sdk)! For basic use cases, you can use the upstream version by importing `mcp.server.fastmcp.FastMCP` (or installing `fastmcp=1.0`).
|
| 126 |
+
|
| 127 |
+
Based on how the MCP ecosystem is evolving, FastMCP 2.0 builds on that foundation to introduce a variety of new features (and more experimental ideas). It adds advanced features like proxying and composing MCP servers, as well as automatically generating them from OpenAPI specs or FastAPI objects. FastMCP 2.0 also introduces new client-side functionality like LLM sampling.
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
## Documentation
|
| 131 |
+
|
| 132 |
+
π FastMCP's documentation is available at [gofastmcp.com](https://gofastmcp.com).
|
| 133 |
+
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
### Installation
|
| 137 |
|
| 138 |
We strongly recommend installing FastMCP with [uv](https://docs.astral.sh/uv/), as it is required for deploying servers via the CLI:
|
| 139 |
|
|
|
|
| 152 |
uv sync
|
| 153 |
```
|
| 154 |
|
| 155 |
+
### Quickstart
|
| 156 |
|
| 157 |
Let's create a simple MCP server that exposes a calculator tool and some data:
|
| 158 |
|
|
|
|
| 181 |
fastmcp install server.py
|
| 182 |
```
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |

|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
## Core Concepts
|
| 188 |
|
docs/getting-started/welcome.mdx
CHANGED
|
@@ -47,10 +47,13 @@ The MCP protocol is powerful but implementing it involves a lot of boilerplate -
|
|
| 47 |
|
| 48 |
FastMCP aims to be:
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
**FastMCP v1** focused on abstracting the most common boilerplate of exposing MCP server functionality, and is now included in the official MCP Python SDK. **FastMCP v2** expands on that foundation to introduce novel functionality mainly focused on simplifying server interactions, including flexible clients, proxying and composition, and deployment.
|
| 56 |
|
|
|
|
| 47 |
|
| 48 |
FastMCP aims to be:
|
| 49 |
|
| 50 |
+
π **Fast**: High-level interface means less code and faster development
|
| 51 |
+
|
| 52 |
+
π **Simple**: Build MCP servers with minimal boilerplate
|
| 53 |
+
|
| 54 |
+
π **Pythonic**: Feels natural to Python developers
|
| 55 |
+
|
| 56 |
+
π **Complete**: FastMCP aims to provide a full implementation of the core MCP specification
|
| 57 |
|
| 58 |
**FastMCP v1** focused on abstracting the most common boilerplate of exposing MCP server functionality, and is now included in the official MCP Python SDK. **FastMCP v2** expands on that foundation to introduce novel functionality mainly focused on simplifying server interactions, including flexible clients, proxying and composition, and deployment.
|
| 59 |
|