fastmcp 2.2.6__tar.gz → 2.2.8__tar.gz

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.
Files changed (165) hide show
  1. {fastmcp-2.2.6 → fastmcp-2.2.8}/.github/workflows/run-tests.yml +1 -1
  2. fastmcp-2.2.8/PKG-INFO +407 -0
  3. fastmcp-2.2.8/README.md +378 -0
  4. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/clients/client.mdx +37 -1
  5. fastmcp-2.2.8/docs/getting-started/installation.mdx +94 -0
  6. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/getting-started/welcome.mdx +16 -8
  7. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/patterns/composition.mdx +50 -7
  8. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/servers/context.mdx +28 -2
  9. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/servers/fastmcp.mdx +74 -1
  10. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/servers/prompts.mdx +16 -15
  11. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/servers/resources.mdx +4 -0
  12. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/servers/tools.mdx +46 -2
  13. fastmcp-2.2.8/examples/serializer.py +32 -0
  14. fastmcp-2.2.8/examples/smart_home/README.md +15 -0
  15. {fastmcp-2.2.6 → fastmcp-2.2.8}/justfile +1 -1
  16. {fastmcp-2.2.6 → fastmcp-2.2.8}/pyproject.toml +1 -1
  17. fastmcp-2.2.8/src/fastmcp/client/client.py +427 -0
  18. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/bulk_tool_caller/bulk_tool_caller.py +1 -3
  19. fastmcp-2.2.8/src/fastmcp/prompts/__init__.py +9 -0
  20. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/prompts/prompt.py +55 -53
  21. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/prompts/prompt_manager.py +10 -3
  22. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/resources/template.py +29 -18
  23. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/resources/types.py +4 -7
  24. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/server/context.py +12 -1
  25. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/server/openapi.py +28 -12
  26. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/server/proxy.py +7 -9
  27. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/server/server.py +243 -19
  28. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/settings.py +7 -0
  29. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/tools/tool.py +79 -62
  30. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/tools/tool_manager.py +16 -3
  31. fastmcp-2.2.8/src/fastmcp/utilities/http.py +44 -0
  32. fastmcp-2.2.8/src/fastmcp/utilities/json_schema.py +59 -0
  33. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/utilities/openapi.py +147 -36
  34. fastmcp-2.2.8/src/fastmcp/utilities/types.py +131 -0
  35. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/client/test_client.py +110 -2
  36. fastmcp-2.2.6/tests/prompts/test_base.py → fastmcp-2.2.8/tests/prompts/test_prompt.py +72 -49
  37. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/prompts/test_prompt_manager.py +138 -7
  38. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/resources/test_function_resources.py +1 -1
  39. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/resources/test_resource_template.py +142 -4
  40. fastmcp-2.2.8/tests/server/test_auth_integration.py +1263 -0
  41. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_import_server.py +4 -2
  42. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_mount.py +110 -1
  43. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_openapi.py +737 -0
  44. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_proxy.py +4 -4
  45. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_server.py +12 -12
  46. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_server_interactions.py +35 -20
  47. fastmcp-2.2.8/tests/server/test_tool_annotations.py +219 -0
  48. fastmcp-2.2.8/tests/tools/test_tool.py +266 -0
  49. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/tools/test_tool_manager.py +111 -21
  50. fastmcp-2.2.8/tests/utilities/test_json_schema.py +110 -0
  51. fastmcp-2.2.8/tests/utilities/test_typeadapter.py +244 -0
  52. fastmcp-2.2.8/tests/utilities/test_types.py +266 -0
  53. fastmcp-2.2.8/uv.lock +1359 -0
  54. fastmcp-2.2.6/PKG-INFO +0 -810
  55. fastmcp-2.2.6/README.md +0 -781
  56. fastmcp-2.2.6/docs/getting-started/installation.mdx +0 -62
  57. fastmcp-2.2.6/examples/smart_home/README.md +0 -0
  58. fastmcp-2.2.6/src/fastmcp/client/client.py +0 -224
  59. fastmcp-2.2.6/src/fastmcp/prompts/__init__.py +0 -4
  60. fastmcp-2.2.6/src/fastmcp/utilities/func_metadata.py +0 -229
  61. fastmcp-2.2.6/src/fastmcp/utilities/types.py +0 -66
  62. fastmcp-2.2.6/tests/utilities/test_func_metadata.py +0 -481
  63. fastmcp-2.2.6/uv.lock +0 -1319
  64. {fastmcp-2.2.6 → fastmcp-2.2.8}/.cursor/rules/core-mcp-objects.mdc +0 -0
  65. {fastmcp-2.2.6 → fastmcp-2.2.8}/.github/ISSUE_TEMPLATE/bug.yml +0 -0
  66. {fastmcp-2.2.6 → fastmcp-2.2.8}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  67. {fastmcp-2.2.6 → fastmcp-2.2.8}/.github/ISSUE_TEMPLATE/enhancement.yml +0 -0
  68. {fastmcp-2.2.6 → fastmcp-2.2.8}/.github/release.yml +0 -0
  69. {fastmcp-2.2.6 → fastmcp-2.2.8}/.github/workflows/publish.yml +0 -0
  70. {fastmcp-2.2.6 → fastmcp-2.2.8}/.github/workflows/run-static.yml +0 -0
  71. {fastmcp-2.2.6 → fastmcp-2.2.8}/.gitignore +0 -0
  72. {fastmcp-2.2.6 → fastmcp-2.2.8}/.pre-commit-config.yaml +0 -0
  73. {fastmcp-2.2.6 → fastmcp-2.2.8}/LICENSE +0 -0
  74. {fastmcp-2.2.6 → fastmcp-2.2.8}/Windows_Notes.md +0 -0
  75. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/assets/demo-inspector.png +0 -0
  76. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/clients/transports.mdx +0 -0
  77. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/docs.json +0 -0
  78. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/getting-started/quickstart.mdx +0 -0
  79. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/patterns/contrib.mdx +0 -0
  80. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/patterns/decorating-methods.mdx +0 -0
  81. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/patterns/fastapi.mdx +0 -0
  82. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/patterns/openapi.mdx +0 -0
  83. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/patterns/proxy.mdx +0 -0
  84. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/patterns/testing.mdx +0 -0
  85. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/snippets/version-badge.mdx +0 -0
  86. {fastmcp-2.2.6 → fastmcp-2.2.8}/docs/style.css +0 -0
  87. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/complex_inputs.py +0 -0
  88. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/desktop.py +0 -0
  89. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/echo.py +0 -0
  90. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/memory.py +0 -0
  91. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/mount_example.py +0 -0
  92. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/readme-quickstart.py +0 -0
  93. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/sampling.py +0 -0
  94. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/screenshot.py +0 -0
  95. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/simple_echo.py +0 -0
  96. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/pyproject.toml +0 -0
  97. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/__init__.py +0 -0
  98. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/__main__.py +0 -0
  99. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/hub.py +0 -0
  100. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/lights/__init__.py +0 -0
  101. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/lights/hue_utils.py +0 -0
  102. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/lights/server.py +0 -0
  103. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/py.typed +0 -0
  104. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/src/smart_home/settings.py +0 -0
  105. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/smart_home/uv.lock +0 -0
  106. {fastmcp-2.2.6 → fastmcp-2.2.8}/examples/text_me.py +0 -0
  107. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/__init__.py +0 -0
  108. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/cli/__init__.py +0 -0
  109. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/cli/claude.py +0 -0
  110. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/cli/cli.py +0 -0
  111. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/client/__init__.py +0 -0
  112. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/client/base.py +0 -0
  113. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/client/logging.py +0 -0
  114. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/client/roots.py +0 -0
  115. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/client/sampling.py +0 -0
  116. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/client/transports.py +0 -0
  117. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/README.md +0 -0
  118. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/bulk_tool_caller/README.md +0 -0
  119. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/bulk_tool_caller/__init__.py +0 -0
  120. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/bulk_tool_caller/example.py +0 -0
  121. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/mcp_mixin/README.md +0 -0
  122. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/mcp_mixin/__init__.py +0 -0
  123. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/mcp_mixin/example.py +0 -0
  124. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/contrib/mcp_mixin/mcp_mixin.py +0 -0
  125. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/exceptions.py +0 -0
  126. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/py.typed +0 -0
  127. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/resources/__init__.py +0 -0
  128. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/resources/resource.py +0 -0
  129. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/resources/resource_manager.py +0 -0
  130. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/server/__init__.py +0 -0
  131. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/tools/__init__.py +0 -0
  132. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/utilities/__init__.py +0 -0
  133. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/utilities/decorators.py +0 -0
  134. {fastmcp-2.2.6 → fastmcp-2.2.8}/src/fastmcp/utilities/logging.py +0 -0
  135. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/__init__.py +0 -0
  136. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/cli/test_run.py +0 -0
  137. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/client/__init__.py +0 -0
  138. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/client/test_logs.py +0 -0
  139. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/client/test_roots.py +0 -0
  140. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/client/test_sampling.py +0 -0
  141. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/conftest.py +0 -0
  142. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/contrib/__init__.py +0 -0
  143. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/contrib/test_bulk_tool_caller.py +0 -0
  144. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/contrib/test_mcp_mixin.py +0 -0
  145. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/prompts/__init__.py +0 -0
  146. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/resources/__init__.py +0 -0
  147. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/resources/test_file_resources.py +0 -0
  148. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/resources/test_resource_manager.py +0 -0
  149. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/resources/test_resources.py +0 -0
  150. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/__init__.py +0 -0
  151. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_file_server.py +0 -0
  152. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_lifespan.py +0 -0
  153. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/server/test_run_server.py +0 -0
  154. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/test_servers/fastmcp_server.py +0 -0
  155. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/test_servers/sse.py +0 -0
  156. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/test_servers/stdio.py +0 -0
  157. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/tools/__init__.py +0 -0
  158. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/__init__.py +0 -0
  159. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/openapi/__init__.py +0 -0
  160. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/openapi/conftest.py +0 -0
  161. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/openapi/test_openapi.py +0 -0
  162. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/openapi/test_openapi_advanced.py +0 -0
  163. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/openapi/test_openapi_fastapi.py +0 -0
  164. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/test_decorated_function.py +0 -0
  165. {fastmcp-2.2.6 → fastmcp-2.2.8}/tests/utilities/test_logging.py +0 -0
@@ -59,4 +59,4 @@ jobs:
59
59
  uv pip install pyreadline3
60
60
 
61
61
  - name: Run tests
62
- run: uv run pytest -vv
62
+ run: uv run --frozen pytest -vv
fastmcp-2.2.8/PKG-INFO ADDED
@@ -0,0 +1,407 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastmcp
3
+ Version: 2.2.8
4
+ Summary: The fast, Pythonic way to build MCP servers.
5
+ Project-URL: Homepage, https://gofastmcp.com
6
+ Project-URL: Repository, https://github.com/jlowin/fastmcp
7
+ Project-URL: Documentation, https://gofastmcp.com
8
+ Author: Jeremiah Lowin
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: agent,fastmcp,llm,mcp,mcp client,mcp server,model context protocol
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: exceptiongroup>=1.2.2
21
+ Requires-Dist: httpx>=0.28.1
22
+ Requires-Dist: mcp<2.0.0,>=1.7.1
23
+ Requires-Dist: openapi-pydantic>=0.5.1
24
+ Requires-Dist: python-dotenv>=1.1.0
25
+ Requires-Dist: rich>=13.9.4
26
+ Requires-Dist: typer>=0.15.2
27
+ Requires-Dist: websockets>=14.0
28
+ Description-Content-Type: text/markdown
29
+
30
+ <div align="center">
31
+
32
+ <!-- omit in toc -->
33
+ # FastMCP v2 🚀
34
+ <strong>The fast, Pythonic way to build MCP servers and clients.</strong>
35
+
36
+ [![Docs](https://img.shields.io/badge/docs-gofastmcp.com-blue)](https://gofastmcp.com)
37
+ [![PyPI - Version](https://img.shields.io/pypi/v/fastmcp.svg)](https://pypi.org/project/fastmcp)
38
+ [![Tests](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml/badge.svg)](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
39
+ [![License](https://img.shields.io/github/license/jlowin/fastmcp.svg)](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
40
+
41
+ <a href="https://trendshift.io/repositories/13266" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13266" alt="jlowin%2Ffastmcp | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
42
+ </div>
43
+
44
+ > [!NOTE]
45
+ > #### FastMCP 2.0 & The Official MCP SDK
46
+ >
47
+ > Recognize the `FastMCP` name? You might have used the version integrated into the [official MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk), which was based on **FastMCP 1.0**.
48
+ >
49
+ > **Welcome to FastMCP 2.0!** This is the actively developed successor, and it significantly expands on 1.0 by introducing powerful client capabilities, server proxying & composition, OpenAPI/FastAPI integration, and more advanced features.
50
+ >
51
+ > FastMCP 2.0 is the recommended path for building modern, powerful MCP applications. Ready to upgrade or get started? Follow the [installation instructions](https://gofastmcp.com/getting-started/installation), which include specific steps for upgrading from the official MCP SDK.
52
+
53
+ ---
54
+
55
+ 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.
56
+
57
+ ```python
58
+ # server.py
59
+ from fastmcp import FastMCP
60
+
61
+ mcp = FastMCP("Demo 🚀")
62
+
63
+ @mcp.tool()
64
+ def add(a: int, b: int) -> int:
65
+ """Add two numbers"""
66
+ return a + b
67
+
68
+ if __name__ == "__main__":
69
+ mcp.run()
70
+ ```
71
+
72
+ Run the server locally:
73
+ ```bash
74
+ fastmcp run server.py
75
+ ```
76
+
77
+ ### 📚 Documentation
78
+
79
+ This readme provides only a high-level overview. For detailed guides, API references, and advanced patterns, please refer to the complete FastMCP documentation at **[gofastmcp.com](https://gofastmcp.com)**.
80
+
81
+ ---
82
+
83
+ <!-- omit in toc -->
84
+ ## Table of Contents
85
+
86
+ - [What is MCP?](#what-is-mcp)
87
+ - [Why FastMCP?](#why-fastmcp)
88
+ - [Installation](#installation)
89
+ - [Core Concepts](#core-concepts)
90
+ - [The `FastMCP` Server](#the-fastmcp-server)
91
+ - [Tools](#tools)
92
+ - [Resources \& Templates](#resources--templates)
93
+ - [Prompts](#prompts)
94
+ - [Context](#context)
95
+ - [MCP Clients](#mcp-clients)
96
+ - [Advanced Features](#advanced-features)
97
+ - [Proxy Servers](#proxy-servers)
98
+ - [Composing MCP Servers](#composing-mcp-servers)
99
+ - [OpenAPI \& FastAPI Generation](#openapi--fastapi-generation)
100
+ - [Running Your Server](#running-your-server)
101
+ - [Contributing](#contributing)
102
+ - [Prerequisites](#prerequisites)
103
+ - [Setup](#setup)
104
+ - [Unit Tests](#unit-tests)
105
+ - [Static Checks](#static-checks)
106
+ - [Pull Requests](#pull-requests)
107
+
108
+ ---
109
+
110
+ ## What is MCP?
111
+
112
+ 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:
113
+
114
+ - Expose data through **Resources** (similar to `GET` requests; load info into context)
115
+ - Provide functionality through **Tools** (similar to `POST`/`PUT` requests; execute actions)
116
+ - Define interaction patterns through **Prompts** (reusable templates)
117
+ - And more!
118
+
119
+ FastMCP provides a high-level, Pythonic interface for building and interacting with these servers.
120
+
121
+ ## Why FastMCP?
122
+
123
+ 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.
124
+
125
+ While the core server concepts of FastMCP 1.0 laid the groundwork and were contributed to the official MCP SDK, **FastMCP 2.0 (this project) is the actively developed successor**, adding significant enhancements and entirely new capabilities like a powerful **client library**, server **proxying**, **composition** patterns, **OpenAPI/FastAPI integration**, and much more.
126
+
127
+ FastMCP aims to be:
128
+
129
+ 🚀 **Fast:** High-level interface means less code and faster development
130
+
131
+ 🍀 **Simple:** Build MCP servers with minimal boilerplate
132
+
133
+ 🐍 **Pythonic:** Feels natural to Python developers
134
+
135
+ 🔍 **Complete:** FastMCP aims to provide a full implementation of the core MCP specification for both servers and clients
136
+
137
+ ## Installation
138
+
139
+ We recommend installing FastMCP with [uv](https://docs.astral.sh/uv/):
140
+
141
+ ```bash
142
+ uv pip install fastmcp
143
+ ```
144
+
145
+ For full installation instructions, including verification, upgrading from the official MCPSDK, and developer setup, see the [**Installation Guide**](https://gofastmcp.com/getting-started/installation).
146
+
147
+ ## Core Concepts
148
+
149
+ These are the building blocks for creating MCP servers and clients with FastMCP.
150
+
151
+ ### The `FastMCP` Server
152
+
153
+ The central object representing your MCP application. It holds your tools, resources, and prompts, manages connections, and can be configured with settings like [authentication providers](https://gofastmcp.com/servers/fastmcp#authentication).
154
+
155
+ ```python
156
+ from fastmcp import FastMCP
157
+
158
+ # Create a server instance
159
+ mcp = FastMCP(name="MyAssistantServer")
160
+ ```
161
+
162
+ Learn more in the [**FastMCP Server Documentation**](https://gofastmcp.com/servers/fastmcp).
163
+
164
+ ### Tools
165
+
166
+ Tools allow LLMs to perform actions by executing your Python functions (sync or async). Ideal for computations, API calls, or side effects (like `POST`/`PUT`). FastMCP handles schema generation from type hints and docstrings. Tools can return various types, including text, JSON-serializable objects, and even images using the [`fastmcp.Image`](https://gofastmcp.com/servers/tools#return-values) helper.
167
+
168
+ ```python
169
+ @mcp.tool()
170
+ def multiply(a: float, b: float) -> float:
171
+ """Multiplies two numbers."""
172
+ return a * b
173
+ ```
174
+
175
+ Learn more in the [**Tools Documentation**](https://gofastmcp.com/servers/tools).
176
+
177
+ ### Resources & Templates
178
+
179
+ Resources expose read-only data sources (like `GET` requests). Use `@mcp.resource("your://uri")`. Use `{placeholders}` in the URI to create dynamic templates that accept parameters, allowing clients to request specific data subsets.
180
+
181
+ ```python
182
+ # Static resource
183
+ @mcp.resource("config://version")
184
+ def get_version():
185
+ return "2.0.1"
186
+
187
+ # Dynamic resource template
188
+ @mcp.resource("users://{user_id}/profile")
189
+ def get_profile(user_id: int):
190
+ # Fetch profile for user_id...
191
+ return {"name": f"User {user_id}", "status": "active"}
192
+ ```
193
+
194
+ Learn more in the [**Resources & Templates Documentation**](https://gofastmcp.com/servers/resources).
195
+
196
+ ### Prompts
197
+
198
+ Prompts define reusable message templates to guide LLM interactions. Decorate functions with `@mcp.prompt()`. Return strings or `Message` objects.
199
+
200
+ ```python
201
+ @mcp.prompt()
202
+ def summarize_request(text: str) -> str:
203
+ """Generate a prompt asking for a summary."""
204
+ return f"Please summarize the following text:\n\n{text}"
205
+ ```
206
+
207
+ Learn more in the [**Prompts Documentation**](https://gofastmcp.com/servers/prompts).
208
+
209
+ ### Context
210
+
211
+ Access MCP session capabilities within your tools, resources, or prompts by adding a `ctx: Context` parameter. Context provides methods for:
212
+ * **Logging:** Log messages to MCP clients with `ctx.info()`, `ctx.error()`, etc.
213
+ * **LLM Sampling:** Use `ctx.sample()` to request completions from the client's LLM.
214
+ * **HTTP Request:** Use `ctx.http_request()` to make HTTP requests to other servers.
215
+ * **Resource Access:** Use `ctx.read_resource()` to access resources on the server
216
+ * **Progress Reporting:** Use `ctx.report_progress()` to report progress to the client.
217
+ * and more...
218
+
219
+ To access the context, add a parameter annotated as `Context` to any mcp-decorated function. FastMCP will automatically inject the correct context object when the function is called.
220
+
221
+ ```python
222
+ from fastmcp import FastMCP, Context
223
+
224
+ mcp = FastMCP("My MCP Server")
225
+
226
+ @mcp.tool()
227
+ async def process_data(uri: str, ctx: Context):
228
+ # Log a message to the client
229
+ await ctx.info(f"Processing {uri}...")
230
+
231
+ # Read a resource from the server
232
+ data = await ctx.read_resource(uri)
233
+
234
+ # Ask client LLM to summarize the data
235
+ summary = await ctx.sample(f"Summarize: {data.content[:500]}")
236
+
237
+ # Return the summary
238
+ return summary.text
239
+ ```
240
+
241
+ Learn more in the [**Context Documentation**](https://gofastmcp.com/servers/context).
242
+
243
+ ### MCP Clients
244
+
245
+ Interact with *any* MCP server programmatically using the `fastmcp.Client`. It supports various transports (Stdio, SSE, In-Memory) and often auto-detects the correct one. The client can also handle advanced patterns like server-initiated **LLM sampling requests** if you provide an appropriate handler.
246
+
247
+ Critically, the client allows for efficient **in-memory testing** of your servers by connecting directly to a `FastMCP` server instance via the `FastMCPTransport`, eliminating the need for process management or network calls during tests.
248
+
249
+ ```python
250
+ from fastmcp import Client
251
+
252
+ async def main():
253
+ # Connect via stdio to a local script
254
+ async with Client("my_server.py") as client:
255
+ tools = await client.list_tools()
256
+ print(f"Available tools: {tools}")
257
+ result = await client.call_tool("add", {"a": 5, "b": 3})
258
+ print(f"Result: {result.text}")
259
+
260
+ # Connect via SSE
261
+ async with Client("http://localhost:8000/sse") as client:
262
+ # ... use the client
263
+ pass
264
+ ```
265
+
266
+ To use clients to test servers, use the following pattern:
267
+
268
+ ```python
269
+ from fastmcp import FastMCP, Client
270
+
271
+ mcp = FastMCP("My MCP Server")
272
+
273
+ async def main():
274
+ # Connect via in-memory transport
275
+ async with Client(mcp) as client:
276
+ # ... use the client
277
+ ```
278
+
279
+ Learn more in the [**Client Documentation**](https://gofastmcp.com/clients/client) and [**Transports Documentation**](https://gofastmcp.com/clients/transports).
280
+
281
+ ## Advanced Features
282
+
283
+ FastMCP introduces powerful ways to structure and deploy your MCP applications.
284
+
285
+ ### Proxy Servers
286
+
287
+ Create a FastMCP server that acts as an intermediary for another local or remote MCP server using `FastMCP.from_client()`. This is especially useful for bridging transports (e.g., remote SSE to local Stdio) or adding a layer of logic to a server you don't control.
288
+
289
+ Learn more in the [**Proxying Documentation**](https://gofastmcp.com/patterns/proxy).
290
+
291
+ ### Composing MCP Servers
292
+
293
+ Build modular applications by mounting multiple `FastMCP` instances onto a parent server using `mcp.mount()` (live link) or `mcp.import_server()` (static copy).
294
+
295
+ Learn more in the [**Composition Documentation**](https://gofastmcp.com/patterns/composition).
296
+
297
+ ### OpenAPI & FastAPI Generation
298
+
299
+ Automatically generate FastMCP servers from existing OpenAPI specifications (`FastMCP.from_openapi()`) or FastAPI applications (`FastMCP.from_fastapi()`), instantly bringing your web APIs to the MCP ecosystem.
300
+
301
+ Learn more: [**OpenAPI Integration**](https://gofastmcp.com/patterns/openapi) | [**FastAPI Integration**](https://gofastmcp.com/patterns/fastapi).
302
+
303
+ ## Running Your Server
304
+
305
+ You can run your FastMCP server in several ways:
306
+
307
+ 1. **Development (`fastmcp dev`)**: Recommended for building and testing. Provides an interactive testing environment with the MCP Inspector.
308
+ ```bash
309
+ fastmcp dev server.py
310
+ # Optionally add temporary dependencies
311
+ fastmcp dev server.py --with pandas numpy
312
+ ```
313
+
314
+ 2. **FastMCP CLI**: Run your server with the FastMCP CLI. This can autodetect and load your server object and run it with any transport configuration you want.
315
+ ```bash
316
+ fastmcp run path/to/server.py:server_object
317
+
318
+ # Run as SSE on port 4200
319
+ fastmcp run path/to/server.py:server_object --transport sse --port 4200
320
+ ```
321
+ FastMCP will auto-detect the server object if it's named `mcp`, `app`, or `server`. In these cases, you can omit the `:server_object` part unless you need to select a specific object.
322
+
323
+ 3. **Direct Execution**: For maximum compatibility with the MCP ecosystem, you can run your server directly as part of a Python script. You will typically do this within an `if __name__ == "__main__":` block in your script:
324
+ ```python
325
+ # Add this to server.py
326
+ if __name__ == "__main__":
327
+ # Default: runs stdio transport
328
+ mcp.run()
329
+
330
+ # Example: Run with SSE transport on a specific port
331
+ mcp.run(transport="sse", host="127.0.0.1", port=9000)
332
+ ```
333
+ Run your script:
334
+ ```bash
335
+ python server.py
336
+ # or using uv to manage the environment
337
+ uv run python server.py
338
+ ```
339
+ 4. **Claude Desktop Integration (`fastmcp install`)**: The easiest way to make your server persistently available in the Claude Desktop app. It handles creating an isolated environment using `uv`.
340
+ ```bash
341
+ fastmcp install server.py --name "My Analysis Tool"
342
+ # Optionally add dependencies and environment variables
343
+ fastmcp install server.py --with requests -v API_KEY=123 -f .env
344
+ ```
345
+
346
+
347
+ See the [**Server Documentation**](https://gofastmcp.com/servers/fastmcp#running-the-server) for more details on transports and configuration.
348
+
349
+
350
+ ## Contributing
351
+
352
+ Contributions are the core of open source! We welcome improvements and features.
353
+
354
+ ### Prerequisites
355
+
356
+ * Python 3.10+
357
+ * [uv](https://docs.astral.sh/uv/) (Recommended for environment management)
358
+
359
+ ### Setup
360
+
361
+ 1. Clone the repository:
362
+ ```bash
363
+ git clone https://github.com/jlowin/fastmcp.git
364
+ cd fastmcp
365
+ ```
366
+ 2. Create and sync the environment:
367
+ ```bash
368
+ uv sync
369
+ ```
370
+ This installs all dependencies, including dev tools.
371
+
372
+ 3. Activate the virtual environment (e.g., `source .venv/bin/activate` or via your IDE).
373
+
374
+ ### Unit Tests
375
+
376
+ FastMCP has a comprehensive unit test suite. All PRs must introduce or update tests as appropriate and pass the full suite.
377
+
378
+ Run tests using pytest:
379
+ ```bash
380
+ pytest
381
+ ```
382
+
383
+ ### Static Checks
384
+
385
+ FastMCP uses `pre-commit` for code formatting, linting, and type-checking. All PRs must pass these checks (they run automatically in CI).
386
+
387
+ Install the hooks locally:
388
+ ```bash
389
+ uv run pre-commit install
390
+ ```
391
+ The hooks will now run automatically on `git commit`. You can also run them manually at any time:
392
+ ```bash
393
+ pre-commit run --all-files
394
+ # or via uv
395
+ uv run pre-commit run --all-files
396
+ ```
397
+
398
+ ### Pull Requests
399
+
400
+ 1. Fork the repository on GitHub.
401
+ 2. Create a feature branch from `main`.
402
+ 3. Make your changes, including tests and documentation updates.
403
+ 4. Ensure tests and pre-commit hooks pass.
404
+ 5. Commit your changes and push to your fork.
405
+ 6. Open a pull request against the `main` branch of `jlowin/fastmcp`.
406
+
407
+ Please open an issue or discussion for questions or suggestions before starting significant work!