fastmcp 2.0.0__py3-none-any.whl → 2.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,21 @@
2
2
 
3
3
  import base64
4
4
  from pathlib import Path
5
+ from typing import TypeVar
5
6
 
6
7
  from mcp.types import ImageContent
7
8
 
9
+ T = TypeVar("T")
10
+
11
+
12
+ def _convert_set_defaults(maybe_set: set[T] | list[T] | None) -> set[T]:
13
+ """Convert a set or list to a set, defaulting to an empty set if None."""
14
+ if maybe_set is None:
15
+ return set()
16
+ if isinstance(maybe_set, set):
17
+ return maybe_set
18
+ return set(maybe_set)
19
+
8
20
 
9
21
  class Image:
10
22
  """Helper class for returning images from tools."""
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastmcp
3
- Version: 2.0.0
4
- Summary: An ergonomic MCP interface
3
+ Version: 2.1.1
4
+ Summary: The fast, Pythonic way to build MCP servers.
5
5
  Author: Jeremiah Lowin
6
6
  License: Apache-2.0
7
7
  License-File: LICENSE
@@ -19,15 +19,16 @@ Description-Content-Type: text/markdown
19
19
 
20
20
  <!-- omit in toc -->
21
21
  # FastMCP v2 🚀
22
- <strong>The fast, Pythonic way to build MCP servers.</strong>
22
+ <strong>The fast, Pythonic way to build MCP servers and clients.</strong>
23
23
 
24
+ [![Docs](https://img.shields.io/badge/docs-gofastmcp.com-blue)](https://gofastmcp.com)
24
25
  [![PyPI - Version](https://img.shields.io/pypi/v/fastmcp.svg)](https://pypi.org/project/fastmcp)
25
26
  [![Tests](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml/badge.svg)](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
26
27
  [![License](https://img.shields.io/github/license/jlowin/fastmcp.svg)](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
27
28
 
28
29
  </div>
29
30
 
30
- [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers are a standardized way to provide context and tools to your LLMs, and FastMCP makes building *and interacting with* them simple and intuitive. Create tools, expose resources, define prompts, and connect components with clean, Pythonic code.
31
+ The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) is a new, standardized way to provide context and tools to your LLMs, and FastMCP makes building MCP servers and clients simple and intuitive. Create tools, expose resources, define prompts, and connect components with clean, Pythonic code.
31
32
 
32
33
  ```python
33
34
  # server.py
@@ -44,48 +45,27 @@ if __name__ == "__main__":
44
45
  mcp.run()
45
46
  ```
46
47
 
47
- Run it locally for testing:
48
- ```bash
49
- fastmcp dev server.py
50
- ```
51
48
 
52
- Install it for use with Claude Desktop:
49
+ Run the server locally:
53
50
  ```bash
54
- fastmcp install server.py
51
+ fastmcp run server.py
55
52
  ```
56
53
 
57
54
  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.
58
55
 
59
- ## Key Features:
60
-
61
- * **Simple Server Creation:** Build MCP servers with minimal boilerplate using intuitive decorators (`@tool`, `@resource`, `@prompt`).
62
- * **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).
63
- * **Compose MCP Servers:** Compose complex applications by mounting multiple FastMCP servers together.
64
- * **API Generation:** Automatically create MCP servers from existing **OpenAPI specifications** or **FastAPI applications**.
65
- * **Powerful Clients:** Programmatically interact with *any* MCP server, regardless of how it was built.
66
- * **LLM Sampling:** Request completions from client LLMs directly within your MCP tools.
67
- * **Pythonic Interface:** Designed with familiar Python patterns like decorators and type hints.
68
- * **Context Injection:** Easily access core MCP capabilities like sampling, logging, and progress reporting within your functions.
69
-
70
- ---
71
-
72
- ### What's New in v2?
73
-
74
- 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`).
75
-
76
- 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.
77
-
78
-
79
- ---
80
56
 
81
57
  <!-- omit in toc -->
82
58
  ## Table of Contents
83
59
 
84
- - [Key Features:](#key-features)
85
- - [What's New in v2?](#whats-new-in-v2)
86
- - [Installation](#installation)
87
- - [Quickstart](#quickstart)
88
60
  - [What is MCP?](#what-is-mcp)
61
+ - [Why FastMCP?](#why-fastmcp)
62
+ - [Key Features](#key-features)
63
+ - [Servers](#servers)
64
+ - [Clients](#clients)
65
+ - [What's New in v2?](#whats-new-in-v2)
66
+ - [Documentation](#documentation)
67
+ - [Installation](#installation)
68
+ - [Quickstart](#quickstart)
89
69
  - [Core Concepts](#core-concepts)
90
70
  - [The `FastMCP` Server](#the-fastmcp-server)
91
71
  - [Tools](#tools)
@@ -115,7 +95,62 @@ Based on how the MCP ecosystem is evolving, FastMCP 2.0 builds on that foundatio
115
95
  - [Formatting \& Linting](#formatting--linting)
116
96
  - [Pull Requests](#pull-requests)
117
97
 
118
- ## Installation
98
+
99
+ ## What is MCP?
100
+
101
+ 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:
102
+
103
+ - Expose data through **Resources** (think GET endpoints; load info into context)
104
+ - Provide functionality through **Tools** (think POST/PUT endpoints; execute actions)
105
+ - Define interaction patterns through **Prompts** (reusable templates)
106
+ - And more!
107
+
108
+ FastMCP provides a high-level, Pythonic interface for building and interacting with these servers.
109
+
110
+ ## Why FastMCP?
111
+
112
+ 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.
113
+
114
+ FastMCP aims to be:
115
+
116
+
117
+ 🚀 **Fast:** High-level interface means less code and faster development
118
+
119
+ 🍀 **Simple:** Build MCP servers with minimal boilerplate
120
+
121
+ 🐍 **Pythonic:** Feels natural to Python developers
122
+
123
+ 🔍 **Complete:** FastMCP aims to provide a full implementation of the core MCP specification for both servers and clients
124
+
125
+ ## Key Features
126
+
127
+ ### Servers
128
+ - **Create** servers with minimal boilerplate using intuitive decorators
129
+ - **Proxy** existing servers to modify configuration or transport
130
+ - **Compose** servers by into complex applications
131
+ - **Generate** servers from OpenAPI specs or FastAPI objects
132
+
133
+ ### Clients
134
+ - **Interact** with MCP servers programmatically
135
+ - **Connect** to any MCP server using any transport
136
+ - **Test** your servers without manual intervention
137
+ - **Innovate** with core MCP capabilities like LLM sampling
138
+
139
+
140
+ ## What's New in v2?
141
+
142
+ 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`).
143
+
144
+ 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.
145
+
146
+
147
+ ## Documentation
148
+
149
+ 📚 FastMCP's documentation is available at [gofastmcp.com](https://gofastmcp.com).
150
+
151
+ ---
152
+
153
+ ### Installation
119
154
 
120
155
  We strongly recommend installing FastMCP with [uv](https://docs.astral.sh/uv/), as it is required for deploying servers via the CLI:
121
156
 
@@ -134,7 +169,7 @@ cd fastmcp
134
169
  uv sync
135
170
  ```
136
171
 
137
- ## Quickstart
172
+ ### Quickstart
138
173
 
139
174
  Let's create a simple MCP server that exposes a calculator tool and some data:
140
175
 
@@ -163,23 +198,8 @@ You can install this server in [Claude Desktop](https://claude.ai/download) and
163
198
  fastmcp install server.py
164
199
  ```
165
200
 
166
- Alternatively, you can test it with the MCP Inspector:
167
- ```bash
168
- fastmcp dev server.py
169
- ```
170
-
171
201
  ![MCP Inspector](/docs/assets/demo-inspector.png)
172
202
 
173
- ## What is MCP?
174
-
175
- 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:
176
-
177
- - Expose data through **Resources** (think GET endpoints; load info into context)
178
- - Provide functionality through **Tools** (think POST/PUT endpoints; execute actions)
179
- - Define interaction patterns through **Prompts** (reusable templates)
180
- - And more!
181
-
182
- FastMCP provides a high-level, Pythonic interface for building and interacting with these servers.
183
203
 
184
204
  ## Core Concepts
185
205
 
@@ -0,0 +1,40 @@
1
+ fastmcp/__init__.py,sha256=2bwhjiyLJisyobp1O9tVYMjriHZAx_f4bIKJYOL-Rpk,399
2
+ fastmcp/exceptions.py,sha256=9_KfANmugNdfZTCSZrohSeVmFmILZX5zz1LXI3wr_pw,508
3
+ fastmcp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ fastmcp/settings.py,sha256=r5LT5yAZmwS1Lppro_fzdrCUJ0otnAmgtjsNgDdQIvs,1980
5
+ fastmcp/cli/__init__.py,sha256=Ii284TNoG5lxTP40ETMGhHEq3lQZWxu9m9JuU57kUpQ,87
6
+ fastmcp/cli/claude.py,sha256=IAlcZ4qZKBBj09jZUMEx7EANZE_IR3vcu7zOBJmMOuU,4567
7
+ fastmcp/cli/cli.py,sha256=M3BAkCjtnoGbyorUgaiqmCVSQg7S7_uEXerY-pqnOhk,13997
8
+ fastmcp/client/__init__.py,sha256=BXO9NUhntZ5GnUACfaRCzDJ5IzxqFJs8qKG-CRMSco4,490
9
+ fastmcp/client/base.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10
+ fastmcp/client/client.py,sha256=OMJ1FzrlcRRYKQg3DFxiQpaNDo4uYK3Acs23rxPyE-g,7941
11
+ fastmcp/client/roots.py,sha256=IxI_bHwHTmg6c2H-s1av1ZgrRnNDieHtYwdGFbzXT5c,2471
12
+ fastmcp/client/sampling.py,sha256=WdRhIZbWv54rXYI8lWHv0thXmGCloZYPFpwJK9El_sQ,1613
13
+ fastmcp/client/transports.py,sha256=WVChsDV1UF0I3reiefsT3dipIh-P_K262TXpucwH-YY,14602
14
+ fastmcp/prompts/__init__.py,sha256=LtPAv2JKIu54AwUd3iwv-HUd4DPcwgEqy6itEd3BH_E,194
15
+ fastmcp/prompts/prompt.py,sha256=wy5gHHiTeYDsDufrVlfJzej_A7lTT34WNI9jwsEaNn8,6268
16
+ fastmcp/prompts/prompt_manager.py,sha256=HGwg8vsx1TVh9hBBWwuDdLm-M-FzBU5oB6Xu8nZC524,3505
17
+ fastmcp/resources/__init__.py,sha256=t0x1j8lc74rjUKtXe9H5Gs4fpQt82K4NgBK6Y7A0xTg,467
18
+ fastmcp/resources/resource.py,sha256=MrfRdLA2FEglvRJP7KgduG7na_qgkBo-_iXTzRbil6c,2038
19
+ fastmcp/resources/resource_manager.py,sha256=fIre1GkXhOyWJNGM36qwYoZQC74aEznV4oXfLfCoKdw,10971
20
+ fastmcp/resources/template.py,sha256=Fpjb51_ktWFpS1aQ5CFCt1SFuPe6S7CPuyzQCz7c3Mg,3742
21
+ fastmcp/resources/types.py,sha256=tigil7z-SUJMakGXzDLIGSqTepPrAsRpwqwtBA4yoUY,6168
22
+ fastmcp/server/__init__.py,sha256=pdkghG11VLMZiluQ-4_rl2JK1LMWmV003m9dDRUN8W4,92
23
+ fastmcp/server/context.py,sha256=s1885AZRipKB3VltfaO3VEtMxGefKs8fdZByj-4tbNI,7120
24
+ fastmcp/server/openapi.py,sha256=J7HrAlRziaB2a6pwB0wStbjRJ1E5Lf818yMqD762s5U,22693
25
+ fastmcp/server/proxy.py,sha256=gYcoQFDIBraqWMOpWSsZLqefKjL_v0v74juLW1SU1AU,8058
26
+ fastmcp/server/server.py,sha256=ryN7o7G1gNFE1NsAuZVc3WpcmsBtcKOo-mXACN5NCoc,28814
27
+ fastmcp/tools/__init__.py,sha256=ocw-SFTtN6vQ8fgnlF8iNAOflRmh79xS1xdO0Bc3QPE,96
28
+ fastmcp/tools/tool.py,sha256=yPRqEM8sntDIbWPtZBy9evDg3BXupe0BKqnpvMwy7Sc,3872
29
+ fastmcp/tools/tool_manager.py,sha256=oUT8ExxIKKpJnFxCUDwThRxdK7WADD40e6yjGBYDPmI,3498
30
+ fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
31
+ fastmcp/utilities/decorators.py,sha256=AjhjsetQZF4YOPV5MTZmIxO21iFp_4fDIS3O2_KNCEg,2990
32
+ fastmcp/utilities/func_metadata.py,sha256=uh-u3gAjLD4kCcGf0ZkZZwBTTl-84JuANZTnDqP5ztI,7841
33
+ fastmcp/utilities/logging.py,sha256=1ipiOXzgWUp3Vih_JtEiLX7aAFmrUDZNr4KrZbofZTM,818
34
+ fastmcp/utilities/openapi.py,sha256=HiGCC5nh1sWtJRJ7DrFNhdjf1m-7SgyXWOE4nsRvyOc,48762
35
+ fastmcp/utilities/types.py,sha256=m2rPYMzO-ZFvvZ46N-1-Xqyw693K7yq9Z2xR4pVELyk,2091
36
+ fastmcp-2.1.1.dist-info/METADATA,sha256=Db4PK68mC7j-FCLfkUiyAg4hIaFgYho-X465u0c0sOs,26634
37
+ fastmcp-2.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ fastmcp-2.1.1.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
39
+ fastmcp-2.1.1.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
40
+ fastmcp-2.1.1.dist-info/RECORD,,
@@ -1,39 +0,0 @@
1
- fastmcp/__init__.py,sha256=2bwhjiyLJisyobp1O9tVYMjriHZAx_f4bIKJYOL-Rpk,399
2
- fastmcp/exceptions.py,sha256=q9djUDmpwmGEWcHI8q4UzJBtf7s7UtgL--OB7OaGzyQ,435
3
- fastmcp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- fastmcp/settings.py,sha256=jpmSeDMcak_2ozVm0xkm4aUeGBGcShEvBWz3HtORkCg,1763
5
- fastmcp/cli/__init__.py,sha256=Ii284TNoG5lxTP40ETMGhHEq3lQZWxu9m9JuU57kUpQ,87
6
- fastmcp/cli/claude.py,sha256=IAlcZ4qZKBBj09jZUMEx7EANZE_IR3vcu7zOBJmMOuU,4567
7
- fastmcp/cli/cli.py,sha256=0k1zyTNFPjTe8zdqMhUY8MGAfJIPPoz-Zwylf3uhSCk,13925
8
- fastmcp/client/__init__.py,sha256=BXO9NUhntZ5GnUACfaRCzDJ5IzxqFJs8qKG-CRMSco4,490
9
- fastmcp/client/base.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10
- fastmcp/client/client.py,sha256=hiCc7PAPzHhhLW-L5yQhVMn390nthQESh_PyH7k_gck,6650
11
- fastmcp/client/roots.py,sha256=IxI_bHwHTmg6c2H-s1av1ZgrRnNDieHtYwdGFbzXT5c,2471
12
- fastmcp/client/sampling.py,sha256=WdRhIZbWv54rXYI8lWHv0thXmGCloZYPFpwJK9El_sQ,1613
13
- fastmcp/client/transports.py,sha256=gA_aGjgPY2q_PqaURkes_vUKtuUicViTHYEe4TAkDmU,13864
14
- fastmcp/prompts/__init__.py,sha256=23GNQg1AYPGnz0AfNa0IK7NCpzDOr-arHze-ldWvAg4,106
15
- fastmcp/prompts/base.py,sha256=sPkax0-LZu8EJ__aiD8ZWhCK4Af9j6NPJilH7ZwG_7E,5718
16
- fastmcp/prompts/prompt_manager.py,sha256=lKo6WWeWnAmCpkzXzAMf2jUttwrXKlElPEEKudaAgww,2574
17
- fastmcp/resources/__init__.py,sha256=e4S369jBoJt07ez9_ZaJefzGfz4kr9nGwG4KPMzMHc8,464
18
- fastmcp/resources/base.py,sha256=UFl1SalsiRsicCUw_ItTUl4BnSW4WeV-aMIr0BI7spY,1355
19
- fastmcp/resources/resource_manager.py,sha256=zgEKSbNKDmlsnbnckd76IXFDvEmwxh0AtW2_uAQ8Ij0,5889
20
- fastmcp/resources/templates.py,sha256=EocMjazS0TT7Ef9JO0_QtAjgpFjzH5OQzs1Md17DIic,2961
21
- fastmcp/resources/types.py,sha256=-53oBf9C0wyaHq_Dqos6B1CR_MF0Crv6sFFn0uq2zzM,6186
22
- fastmcp/server/__init__.py,sha256=pdkghG11VLMZiluQ-4_rl2JK1LMWmV003m9dDRUN8W4,92
23
- fastmcp/server/context.py,sha256=SPYr3KUBG9MmKRh6Y6tfzPNgdxR5TmPGfnVwcEMqwMM,7115
24
- fastmcp/server/openapi.py,sha256=6b10nnaaZxGoSyPxQyqLDX7NmcHMlbPms1zQudnbets,22268
25
- fastmcp/server/proxy.py,sha256=Ry3fmIwd6eiOd1rjzgLFMKGIjq-uvLDVdiqpS1G4Wfw,8018
26
- fastmcp/server/server.py,sha256=Qh_pCNKQLFqjEbl9DMMvBMUD5cuktQoQSNjPDF1jrkc,23937
27
- fastmcp/tools/__init__.py,sha256=ZboxhyMJDl87Svjov8YwNYwNZi55P9VhmpTjBZLesnk,96
28
- fastmcp/tools/base.py,sha256=DvHEWuQxBfp8e_FRWS8_oBSq7JL7m2Gm9gkaivk-eb8,3033
29
- fastmcp/tools/tool_manager.py,sha256=zDWeuWAev1uyWO95GkXbRx9sXfJ3Iom7CyVHz0bs5GY,3051
30
- fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
31
- fastmcp/utilities/func_metadata.py,sha256=ODD9ds7bGXED27rx4MiMim1EBPnjNHIcXabJhynVKBA,7739
32
- fastmcp/utilities/logging.py,sha256=1ipiOXzgWUp3Vih_JtEiLX7aAFmrUDZNr4KrZbofZTM,818
33
- fastmcp/utilities/openapi.py,sha256=yl83QsOcLZc00vScdL2LpEopzVCv32gDpC5da9NGkTM,30351
34
- fastmcp/utilities/types.py,sha256=rsNHw-O0IfZrCPkSQbmM-hJ2We8lnqra834HbtD2Clo,1760
35
- fastmcp-2.0.0.dist-info/METADATA,sha256=0-fdfOLJbdvUw-mXCW1Ol_dP4CMyh7-YneErxG3-vdI,26270
36
- fastmcp-2.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
37
- fastmcp-2.0.0.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
38
- fastmcp-2.0.0.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
39
- fastmcp-2.0.0.dist-info/RECORD,,