fastmcp 2.3.0__tar.gz → 2.3.1__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 (172) hide show
  1. {fastmcp-2.3.0 → fastmcp-2.3.1}/PKG-INFO +41 -45
  2. {fastmcp-2.3.0 → fastmcp-2.3.1}/README.md +40 -44
  3. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/clients/transports.mdx +64 -65
  4. fastmcp-2.3.1/docs/deployment/asgi.mdx +171 -0
  5. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/deployment/running-server.mdx +22 -1
  6. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/docs.json +1 -0
  7. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/getting-started/installation.mdx +1 -1
  8. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/getting-started/quickstart.mdx +2 -2
  9. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/getting-started/welcome.mdx +7 -0
  10. {fastmcp-2.3.0 → fastmcp-2.3.1}/pyproject.toml +1 -1
  11. fastmcp-2.3.1/src/fastmcp/low_level/README.md +1 -0
  12. fastmcp-2.3.1/src/fastmcp/low_level/sse_server_transport.py +104 -0
  13. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/server/http.py +19 -15
  14. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/server/proxy.py +1 -1
  15. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/server/server.py +1 -1
  16. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/tools/tool.py +1 -1
  17. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/client/test_sse.py +29 -0
  18. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/client/test_streamable_http.py +39 -0
  19. fastmcp-2.3.1/tests/tools/__init__.py +0 -0
  20. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/tools/test_tool_manager.py +28 -0
  21. fastmcp-2.3.1/tests/utilities/test_cache.py +233 -0
  22. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/test_types.py +51 -0
  23. {fastmcp-2.3.0 → fastmcp-2.3.1}/.cursor/rules/core-mcp-objects.mdc +0 -0
  24. {fastmcp-2.3.0 → fastmcp-2.3.1}/.github/ISSUE_TEMPLATE/bug.yml +0 -0
  25. {fastmcp-2.3.0 → fastmcp-2.3.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  26. {fastmcp-2.3.0 → fastmcp-2.3.1}/.github/ISSUE_TEMPLATE/enhancement.yml +0 -0
  27. {fastmcp-2.3.0 → fastmcp-2.3.1}/.github/release.yml +0 -0
  28. {fastmcp-2.3.0 → fastmcp-2.3.1}/.github/workflows/publish.yml +0 -0
  29. {fastmcp-2.3.0 → fastmcp-2.3.1}/.github/workflows/run-static.yml +0 -0
  30. {fastmcp-2.3.0 → fastmcp-2.3.1}/.github/workflows/run-tests.yml +0 -0
  31. {fastmcp-2.3.0 → fastmcp-2.3.1}/.gitignore +0 -0
  32. {fastmcp-2.3.0 → fastmcp-2.3.1}/.pre-commit-config.yaml +0 -0
  33. {fastmcp-2.3.0 → fastmcp-2.3.1}/LICENSE +0 -0
  34. {fastmcp-2.3.0 → fastmcp-2.3.1}/Windows_Notes.md +0 -0
  35. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/assets/demo-inspector.png +0 -0
  36. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/clients/client.mdx +0 -0
  37. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/deployment/authentication.mdx +0 -0
  38. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/composition.mdx +0 -0
  39. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/contrib.mdx +0 -0
  40. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/decorating-methods.mdx +0 -0
  41. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/fastapi.mdx +0 -0
  42. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/http-requests.mdx +0 -0
  43. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/openapi.mdx +0 -0
  44. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/proxy.mdx +0 -0
  45. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/patterns/testing.mdx +0 -0
  46. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/servers/context.mdx +0 -0
  47. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/servers/fastmcp.mdx +0 -0
  48. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/servers/prompts.mdx +0 -0
  49. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/servers/resources.mdx +0 -0
  50. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/servers/tools.mdx +0 -0
  51. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/snippets/version-badge.mdx +0 -0
  52. {fastmcp-2.3.0 → fastmcp-2.3.1}/docs/style.css +0 -0
  53. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/complex_inputs.py +0 -0
  54. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/desktop.py +0 -0
  55. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/echo.py +0 -0
  56. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/memory.py +0 -0
  57. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/mount_example.py +0 -0
  58. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/sampling.py +0 -0
  59. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/screenshot.py +0 -0
  60. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/serializer.py +0 -0
  61. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/simple_echo.py +0 -0
  62. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/README.md +0 -0
  63. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/pyproject.toml +0 -0
  64. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/__init__.py +0 -0
  65. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/__main__.py +0 -0
  66. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/hub.py +0 -0
  67. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/lights/__init__.py +0 -0
  68. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/lights/hue_utils.py +0 -0
  69. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/lights/server.py +0 -0
  70. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/py.typed +0 -0
  71. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/src/smart_home/settings.py +0 -0
  72. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/smart_home/uv.lock +0 -0
  73. {fastmcp-2.3.0 → fastmcp-2.3.1}/examples/text_me.py +0 -0
  74. {fastmcp-2.3.0 → fastmcp-2.3.1}/justfile +0 -0
  75. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/__init__.py +0 -0
  76. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/cli/__init__.py +0 -0
  77. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/cli/claude.py +0 -0
  78. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/cli/cli.py +0 -0
  79. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/client/__init__.py +0 -0
  80. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/client/base.py +0 -0
  81. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/client/client.py +0 -0
  82. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/client/logging.py +0 -0
  83. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/client/roots.py +0 -0
  84. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/client/sampling.py +0 -0
  85. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/client/transports.py +0 -0
  86. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/README.md +0 -0
  87. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/bulk_tool_caller/README.md +0 -0
  88. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/bulk_tool_caller/__init__.py +0 -0
  89. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/bulk_tool_caller/bulk_tool_caller.py +0 -0
  90. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/bulk_tool_caller/example.py +0 -0
  91. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/mcp_mixin/README.md +0 -0
  92. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/mcp_mixin/__init__.py +0 -0
  93. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/mcp_mixin/example.py +0 -0
  94. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/contrib/mcp_mixin/mcp_mixin.py +0 -0
  95. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/exceptions.py +0 -0
  96. {fastmcp-2.3.0/tests → fastmcp-2.3.1/src/fastmcp/low_level}/__init__.py +0 -0
  97. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/prompts/__init__.py +0 -0
  98. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/prompts/prompt.py +0 -0
  99. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/prompts/prompt_manager.py +0 -0
  100. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/py.typed +0 -0
  101. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/resources/__init__.py +0 -0
  102. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/resources/resource.py +0 -0
  103. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/resources/resource_manager.py +0 -0
  104. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/resources/template.py +0 -0
  105. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/resources/types.py +0 -0
  106. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/server/__init__.py +0 -0
  107. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/server/context.py +0 -0
  108. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/server/dependencies.py +0 -0
  109. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/server/openapi.py +0 -0
  110. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/settings.py +0 -0
  111. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/tools/__init__.py +0 -0
  112. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/tools/tool_manager.py +0 -0
  113. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/__init__.py +0 -0
  114. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/cache.py +0 -0
  115. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/decorators.py +0 -0
  116. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/json_schema.py +0 -0
  117. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/logging.py +0 -0
  118. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/openapi.py +0 -0
  119. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/tests.py +0 -0
  120. {fastmcp-2.3.0 → fastmcp-2.3.1}/src/fastmcp/utilities/types.py +0 -0
  121. {fastmcp-2.3.0 → fastmcp-2.3.1}/test.py +0 -0
  122. {fastmcp-2.3.0/tests/prompts → fastmcp-2.3.1/tests}/__init__.py +0 -0
  123. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/cli/test_run.py +0 -0
  124. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/client/__init__.py +0 -0
  125. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/client/test_client.py +0 -0
  126. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/client/test_logs.py +0 -0
  127. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/client/test_roots.py +0 -0
  128. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/client/test_sampling.py +0 -0
  129. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/conftest.py +0 -0
  130. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/contrib/__init__.py +0 -0
  131. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/contrib/test_bulk_tool_caller.py +0 -0
  132. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/contrib/test_mcp_mixin.py +0 -0
  133. {fastmcp-2.3.0/tests/resources → fastmcp-2.3.1/tests/prompts}/__init__.py +0 -0
  134. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/prompts/test_prompt.py +0 -0
  135. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/prompts/test_prompt_manager.py +0 -0
  136. {fastmcp-2.3.0/tests/server → fastmcp-2.3.1/tests/resources}/__init__.py +0 -0
  137. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/resources/test_file_resources.py +0 -0
  138. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/resources/test_function_resources.py +0 -0
  139. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/resources/test_resource_manager.py +0 -0
  140. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/resources/test_resource_template.py +0 -0
  141. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/resources/test_resources.py +0 -0
  142. {fastmcp-2.3.0/tests/tools → fastmcp-2.3.1/tests/server}/__init__.py +0 -0
  143. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_auth_integration.py +0 -0
  144. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_context.py +0 -0
  145. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_file_server.py +0 -0
  146. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_http_dependencies.py +0 -0
  147. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_import_server.py +0 -0
  148. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_lifespan.py +0 -0
  149. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_mount.py +0 -0
  150. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_openapi.py +0 -0
  151. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_proxy.py +0 -0
  152. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_run_server.py +0 -0
  153. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_server.py +0 -0
  154. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_server_interactions.py +0 -0
  155. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/server/test_tool_annotations.py +0 -0
  156. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/test_examples.py +0 -0
  157. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/test_servers/fastmcp_server.py +0 -0
  158. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/test_servers/sse.py +0 -0
  159. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/test_servers/stdio.py +0 -0
  160. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/tools/test_tool.py +0 -0
  161. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/__init__.py +0 -0
  162. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/openapi/__init__.py +0 -0
  163. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/openapi/conftest.py +0 -0
  164. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/openapi/test_openapi.py +0 -0
  165. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/openapi/test_openapi_advanced.py +0 -0
  166. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/openapi/test_openapi_fastapi.py +0 -0
  167. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/test_decorated_function.py +0 -0
  168. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/test_json_schema.py +0 -0
  169. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/test_logging.py +0 -0
  170. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/test_tests.py +0 -0
  171. {fastmcp-2.3.0 → fastmcp-2.3.1}/tests/utilities/test_typeadapter.py +0 -0
  172. {fastmcp-2.3.0 → fastmcp-2.3.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastmcp
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: The fast, Pythonic way to build MCP servers.
5
5
  Project-URL: Homepage, https://gofastmcp.com
6
6
  Project-URL: Repository, https://github.com/jlowin/fastmcp
@@ -76,7 +76,13 @@ fastmcp run server.py
76
76
 
77
77
  ### 📚 Documentation
78
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)**.
79
+ FastMCP's complete documentation is available at **[gofastmcp.com](https://gofastmcp.com)**, including detailed guides, API references, and advanced patterns. This readme provides only a high-level overview.
80
+
81
+ Documentation is also available in [llms.txt format](https://llmstxt.org/), which is a simple markdown standard that LLMs can consume easily.
82
+
83
+ There are two ways to access the LLM-friendly documentation:
84
+ - [`llms.txt`](https://gofastmcp.com/llms.txt) is essentially a sitemap, listing all the pages in the documentation.
85
+ - [`llms-full.txt`](https://gofastmcp.com/llms-full.txt) contains the entire documentation. Note this may exceed the context window of your LLM.
80
86
 
81
87
  ---
82
88
 
@@ -302,50 +308,40 @@ Learn more: [**OpenAPI Integration**](https://gofastmcp.com/patterns/openapi) |
302
308
 
303
309
  ## Running Your Server
304
310
 
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.
311
+ The main way to run a FastMCP server is by calling the `run()` method on your server instance:
312
+
313
+ ```python
314
+ # server.py
315
+ from fastmcp import FastMCP
316
+
317
+ mcp = FastMCP("Demo 🚀")
318
+
319
+ @mcp.tool()
320
+ def hello(name: str) -> str:
321
+ return f"Hello, {name}!"
322
+
323
+ if __name__ == "__main__":
324
+ mcp.run() # Default: uses STDIO transport
325
+ ```
326
+
327
+ FastMCP supports three transport protocols:
328
+
329
+ **STDIO (Default)**: Best for local tools and command-line scripts.
330
+ ```python
331
+ mcp.run(transport="stdio") # Default, so transport argument is optional
332
+ ```
333
+
334
+ **Streamable HTTP**: Recommended for web deployments.
335
+ ```python
336
+ mcp.run(transport="streamable-http", host="127.0.0.1", port=8000, path="/mcp")
337
+ ```
338
+
339
+ **SSE**: For compatibility with existing SSE clients.
340
+ ```python
341
+ mcp.run(transport="sse", host="127.0.0.1", port=8000)
342
+ ```
348
343
 
344
+ See the [**Running Server Documentation**](https://gofastmcp.com/deployment/running-server) for more details.
349
345
 
350
346
  ## Contributing
351
347
 
@@ -47,7 +47,13 @@ fastmcp run server.py
47
47
 
48
48
  ### 📚 Documentation
49
49
 
50
- 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)**.
50
+ FastMCP's complete documentation is available at **[gofastmcp.com](https://gofastmcp.com)**, including detailed guides, API references, and advanced patterns. This readme provides only a high-level overview.
51
+
52
+ Documentation is also available in [llms.txt format](https://llmstxt.org/), which is a simple markdown standard that LLMs can consume easily.
53
+
54
+ There are two ways to access the LLM-friendly documentation:
55
+ - [`llms.txt`](https://gofastmcp.com/llms.txt) is essentially a sitemap, listing all the pages in the documentation.
56
+ - [`llms-full.txt`](https://gofastmcp.com/llms-full.txt) contains the entire documentation. Note this may exceed the context window of your LLM.
51
57
 
52
58
  ---
53
59
 
@@ -273,50 +279,40 @@ Learn more: [**OpenAPI Integration**](https://gofastmcp.com/patterns/openapi) |
273
279
 
274
280
  ## Running Your Server
275
281
 
276
- You can run your FastMCP server in several ways:
277
-
278
- 1. **Development (`fastmcp dev`)**: Recommended for building and testing. Provides an interactive testing environment with the MCP Inspector.
279
- ```bash
280
- fastmcp dev server.py
281
- # Optionally add temporary dependencies
282
- fastmcp dev server.py --with pandas numpy
283
- ```
284
-
285
- 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.
286
- ```bash
287
- fastmcp run path/to/server.py:server_object
288
-
289
- # Run as SSE on port 4200
290
- fastmcp run path/to/server.py:server_object --transport sse --port 4200
291
- ```
292
- 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.
293
-
294
- 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:
295
- ```python
296
- # Add this to server.py
297
- if __name__ == "__main__":
298
- # Default: runs stdio transport
299
- mcp.run()
300
-
301
- # Example: Run with SSE transport on a specific port
302
- mcp.run(transport="sse", host="127.0.0.1", port=9000)
303
- ```
304
- Run your script:
305
- ```bash
306
- python server.py
307
- # or using uv to manage the environment
308
- uv run python server.py
309
- ```
310
- 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`.
311
- ```bash
312
- fastmcp install server.py --name "My Analysis Tool"
313
- # Optionally add dependencies and environment variables
314
- fastmcp install server.py --with requests -v API_KEY=123 -f .env
315
- ```
316
-
317
-
318
- See the [**Server Documentation**](https://gofastmcp.com/servers/fastmcp#running-the-server) for more details on transports and configuration.
282
+ The main way to run a FastMCP server is by calling the `run()` method on your server instance:
283
+
284
+ ```python
285
+ # server.py
286
+ from fastmcp import FastMCP
287
+
288
+ mcp = FastMCP("Demo 🚀")
289
+
290
+ @mcp.tool()
291
+ def hello(name: str) -> str:
292
+ return f"Hello, {name}!"
293
+
294
+ if __name__ == "__main__":
295
+ mcp.run() # Default: uses STDIO transport
296
+ ```
297
+
298
+ FastMCP supports three transport protocols:
299
+
300
+ **STDIO (Default)**: Best for local tools and command-line scripts.
301
+ ```python
302
+ mcp.run(transport="stdio") # Default, so transport argument is optional
303
+ ```
304
+
305
+ **Streamable HTTP**: Recommended for web deployments.
306
+ ```python
307
+ mcp.run(transport="streamable-http", host="127.0.0.1", port=8000, path="/mcp")
308
+ ```
309
+
310
+ **SSE**: For compatibility with existing SSE clients.
311
+ ```python
312
+ mcp.run(transport="sse", host="127.0.0.1", port=8000)
313
+ ```
319
314
 
315
+ See the [**Running Server Documentation**](https://gofastmcp.com/deployment/running-server) for more details.
320
316
 
321
317
  ## Contributing
322
318
 
@@ -14,6 +14,69 @@ The FastMCP `Client` relies on a `ClientTransport` object to handle the specific
14
14
  While the `Client` often infers the correct transport automatically (see [Client Overview](/clients/client#transport-inference)), you can also instantiate transports explicitly for more control.
15
15
 
16
16
 
17
+ ## Network Transports
18
+
19
+ These transports connect to servers running over a network, typically long-running services accessible via URLs.
20
+
21
+ ### Streamable HTTP
22
+
23
+ <VersionBadge version="2.3.0" />
24
+
25
+ * **Class:** `fastmcp.client.transports.StreamableHttpTransport`
26
+ * **Inferred From:** `http://` or `https://` URLs (default for HTTP URLs as of v2.3.0)
27
+ * **Use Case:** Connecting to persistent MCP servers exposed over HTTP/S using FastMCP's `mcp.run(transport="streamable-http")` mode.
28
+
29
+ Streamable HTTP is the recommended transport for web-based deployments, providing efficient bidirectional communication over HTTP.
30
+
31
+ ```python
32
+ from fastmcp import Client
33
+ from fastmcp.client.transports import StreamableHttpTransport
34
+
35
+ http_url = "http://localhost:8000/mcp"
36
+
37
+ # Option 1: Inferred transport (default for HTTP URLs)
38
+ client_inferred = Client(http_url)
39
+
40
+ # Option 2: Explicit transport (e.g., to add custom headers)
41
+ headers = {"Authorization": "Bearer mytoken"}
42
+ transport_explicit = StreamableHttpTransport(url=http_url, headers=headers)
43
+ client_explicit = Client(transport_explicit)
44
+
45
+ async def use_streamable_http_client(client):
46
+ async with client:
47
+ tools = await client.list_tools()
48
+ print(f"Connected via Streamable HTTP, found tools: {tools}")
49
+
50
+ # asyncio.run(use_streamable_http_client(client_inferred))
51
+ # asyncio.run(use_streamable_http_client(client_explicit))
52
+ ```
53
+
54
+ ### SSE (Server-Sent Events)
55
+
56
+ * **Class:** `fastmcp.client.transports.SSETransport`
57
+ * **Inferred From:** Not automatically inferred for most HTTP URLs (as of v2.3.0)
58
+ * **Use Case:** Connecting to MCP servers using Server-Sent Events, often using FastMCP's `mcp.run(transport="sse")` mode.
59
+
60
+ While SSE is still supported, Streamable HTTP is the recommended transport for new web-based deployments.
61
+
62
+ ```python
63
+ from fastmcp import Client
64
+ from fastmcp.client.transports import SSETransport
65
+
66
+ sse_url = "http://localhost:8000/sse"
67
+
68
+ # Since v2.3.0, HTTP URLs default to StreamableHttpTransport,
69
+ # so you must explicitly use SSETransport for SSE connections
70
+ transport_explicit = SSETransport(url=sse_url)
71
+ client_explicit = Client(transport_explicit)
72
+
73
+ async def use_sse_client(client):
74
+ async with client:
75
+ tools = await client.list_tools()
76
+ print(f"Connected via SSE, found tools: {tools}")
77
+
78
+ # asyncio.run(use_sse_client(client_explicit))
79
+ ```
17
80
  ## Stdio Transports
18
81
 
19
82
  These transports manage an MCP server running as a subprocess, communicating with it via standard input (stdin) and standard output (stdout). This is the standard mechanism used by clients like Claude Desktop.
@@ -133,70 +196,6 @@ client = Client(transport)
133
196
  # async with client:
134
197
  # response = await client.call_tool("get_npm_data", {})
135
198
  ```
136
- ## Network Transports
137
-
138
- These transports connect to servers running over a network, typically long-running services accessible via URLs.
139
-
140
- ### SSE (Server-Sent Events)
141
-
142
- * **Class:** `fastmcp.client.transports.SSETransport`
143
- * **Inferred From:** `http://` or `https://` URLs
144
- * **Use Case:** Connecting to persistent MCP servers exposed over HTTP/S, often using FastMCP's `mcp.run(transport="sse")` mode.
145
-
146
- SSE is a simple, unidirectional protocol where the server pushes messages to the client over a standard HTTP connection.
147
-
148
- ```python
149
- from fastmcp import Client
150
- from fastmcp.client.transports import SSETransport
151
-
152
- sse_url = "http://localhost:8000/sse"
153
-
154
- # Option 1: Inferred transport
155
- client_inferred = Client(sse_url)
156
-
157
- # Option 2: Explicit transport (e.g., to add custom headers)
158
- headers = {"Authorization": "Bearer mytoken"}
159
- transport_explicit = SSETransport(url=sse_url, headers=headers)
160
- client_explicit = Client(transport_explicit)
161
-
162
- async def use_sse_client(client):
163
- async with client:
164
- tools = await client.list_tools()
165
- print(f"Connected via SSE, found tools: {tools}")
166
-
167
- # asyncio.run(use_sse_client(client_inferred))
168
- # asyncio.run(use_sse_client(client_explicit))
169
- ```
170
-
171
- ### WebSocket
172
-
173
- * **Class:** `fastmcp.client.transports.WSTransport`
174
- * **Inferred From:** `ws://` or `wss://` URLs
175
- * **Use Case:** Connecting to MCP servers using the WebSocket protocol for bidirectional communication.
176
-
177
- WebSockets provide a persistent, full-duplex connection between client and server.
178
-
179
- ```python
180
- from fastmcp import Client
181
- from fastmcp.client.transports import WSTransport
182
-
183
- ws_url = "ws://localhost:9000"
184
-
185
- # Option 1: Inferred transport
186
- client_inferred = Client(ws_url)
187
-
188
- # Option 2: Explicit transport
189
- transport_explicit = WSTransport(url=ws_url)
190
- client_explicit = Client(transport_explicit)
191
-
192
- async def use_ws_client(client):
193
- async with client:
194
- tools = await client.list_tools()
195
- print(f"Connected via WebSocket, found tools: {tools}")
196
-
197
- # asyncio.run(use_ws_client(client_inferred))
198
- # asyncio.run(use_ws_client(client_explicit))
199
- ```
200
199
 
201
200
  ## In-Memory Transports
202
201
 
@@ -240,6 +239,6 @@ Communication happens through efficient in-memory queues, making it very fast.
240
239
  ## Choosing a Transport
241
240
 
242
241
  * **Local Development/Testing:** Use `PythonStdioTransport` (inferred from `.py` files) or `FastMCPTransport` (for same-process testing).
243
- * **Connecting to Remote/Persistent Servers:** Use `SSETransport` (for `http/s`) or `WSTransport` (for `ws/s`).
242
+ * **Connecting to Remote/Persistent Servers:** Use `StreamableHttpTransport` (recommended, default for HTTP URLs) or `SSETransport` (legacy option).
244
243
  * **Running Packaged Tools:** Use `UvxStdioTransport` (Python/uv) or `NpxStdioTransport` (Node/npm) if you need to run MCP servers without local installation.
245
244
  * **Integrating with Claude Desktop (or similar):** These tools typically expect to run a Python script, so your server should be runnable via `python your_server.py`, making `PythonStdioTransport` the relevant mechanism on the client side.
@@ -0,0 +1,171 @@
1
+ ---
2
+ title: Integrating FastMCP in ASGI Applications
3
+ sidebarTitle: ASGI Integration
4
+ description: Integrate FastMCP servers into existing Starlette, FastAPI, or other ASGI applications
5
+ icon: plug
6
+ ---
7
+
8
+ While FastMCP provides standalone server capabilities, you can also integrate your FastMCP server into existing web applications. This approach is useful for:
9
+
10
+ - Adding MCP functionality to an existing website or API
11
+ - Mounting MCP servers under specific URL paths
12
+ - Combining multiple services in a single application
13
+ - Leveraging existing authentication and middleware
14
+
15
+ Please note that all FastMCP servers have a `run()` method that can be used to start the server. This guide focuses on integration with broader ASGI frameworks.
16
+
17
+ ## ASGI Server
18
+
19
+
20
+ FastMCP servers can be created as [Starlette](https://www.starlette.io/) ASGI apps for straightforward hosting or integration into existing applications.
21
+
22
+ The first step is to obtain a Starlette application instance from your FastMCP server using either the `streamable_http_app()` (preferred) or `sse_app()` (legacy) methods:
23
+
24
+ ```python
25
+ from fastmcp import FastMCP
26
+
27
+ mcp = FastMCP("MyServer")
28
+
29
+ @mcp.tool()
30
+ def hello(name: str) -> str:
31
+ return f"Hello, {name}!"
32
+
33
+ # Get a Starlette app instance for the preferred transport
34
+ http_app = mcp.streamable_http_app() # For Streamable HTTP transport
35
+ sse_app = mcp.sse_app() # For SSE transport
36
+ ```
37
+
38
+ Both methods return a Starlette application that can be integrated with other ASGI-compatible web frameworks.
39
+
40
+ The MCP server's endpoint is mounted at the root path `/mcp` for Streamable HTTP transport, and `/sse` for SSE transport, though you can change these paths by passing a `path` argument to the `streamable_http_app()` or `sse_app()` methods:
41
+
42
+ ```python
43
+ http_app = mcp.streamable_http_app(path="/custom-mcp-path")
44
+ sse_app = mcp.sse_app(path="/custom-sse-path")
45
+ ```
46
+
47
+ ### Running the Server
48
+
49
+ To run the FastMCP server, you can use the `uvicorn` ASGI server:
50
+
51
+ ```python
52
+ import uvicorn
53
+
54
+ # (define the app here)
55
+
56
+ if __name__ == "__main__":
57
+ uvicorn.run(http_app, host="0.0.0.0", port=8000)
58
+ ```
59
+
60
+ Or, from the command line:
61
+
62
+ ```bash
63
+ uvicorn path.to.your.app:http_app --host 0.0.0.0 --port 8000
64
+ ```
65
+
66
+
67
+
68
+ ## Starlette Integration
69
+
70
+ You can mount your FastMCP server in another Starlette application using the `Mount` class.
71
+
72
+ ```python
73
+ from fastmcp import FastMCP
74
+ from starlette.applications import Starlette
75
+ from starlette.routing import Mount
76
+
77
+ # Create your FastMCP server as well as any tools, resources, etc.
78
+ mcp = FastMCP("MyServer")
79
+
80
+ # Create the ASGI app
81
+ mcp_app = mcp.streamable_http_app(path='/mcp')
82
+
83
+ # Create a Starlette app and mount the MCP server
84
+ app = Starlette(
85
+ routes=[
86
+ Mount("/mcp-server", app=mcp_app),
87
+ # Add other routes as needed
88
+ ],
89
+ lifespan=mcp_app.router.lifespan_context,
90
+ )
91
+ ```
92
+
93
+ The MCP endpoint will be available at `/mcp-server/mcp` of the resulting Starlette app.
94
+
95
+ <Warning>
96
+ For Streamable HTTP transport, you **must** pass the lifespan context from the FastMCP app to the resulting Starlette app, as nested lifespans are not recognized. Otherwise, the FastMCP server's session manager will not be properly initialized.
97
+ </Warning>
98
+
99
+ ### Nested Mounts
100
+
101
+
102
+ You can create complex routing structures by nesting mounts:
103
+
104
+ ```python
105
+ from fastmcp import FastMCP
106
+ from starlette.applications import Starlette
107
+ from starlette.routing import Mount
108
+
109
+ # Create your FastMCP server as well as any tools, resources, etc.
110
+ mcp = FastMCP("MyServer")
111
+
112
+ # Create the ASGI app
113
+ mcp_app = mcp.streamable_http_app(path='/mcp')
114
+
115
+ # Create nested application structure
116
+ inner_app = Starlette(routes=[Mount("/inner", app=mcp_app)])
117
+ app = Starlette(
118
+ routes=[Mount("/outer", app=inner_app)],
119
+ lifespan=mcp_app.router.lifespan_context,
120
+ )
121
+ ```
122
+
123
+ In this setup, the MCP server is accessible at the `/outer/inner/mcp` path of the resulting Starlette app.
124
+
125
+ <Warning>
126
+ For Streamable HTTP transport, you **must** pass the lifespan context from the FastMCP app to the *outer* Starlette app, as nested lifespans are not recognized. Otherwise, the FastMCP server's session manager will not be properly initialized.
127
+ </Warning>
128
+ ## FastAPI Integration
129
+
130
+ FastAPI is built on Starlette, so you can mount your FastMCP server in a similar way:
131
+
132
+ ```python
133
+ from fastmcp import FastMCP
134
+ from fastapi import FastAPI
135
+ from starlette.routing import Mount
136
+
137
+ # Create your FastMCP server as well as any tools, resources, etc.
138
+ mcp = FastMCP("MyServer")
139
+
140
+ # Create the ASGI app
141
+ mcp_app = mcp.streamable_http_app(path='/mcp')
142
+
143
+ # Create a FastAPI app and mount the MCP server
144
+ app = FastAPI(lifespan=mcp_app.router.lifespan_context)
145
+ app.mount("/mcp-server", mcp_app)
146
+ ```
147
+
148
+ The MCP endpoint will be available at `/mcp-server/mcp` of the resulting FastAPI app.
149
+
150
+ <Warning>
151
+ For Streamable HTTP transport, you **must** pass the lifespan context from the FastMCP app to the resulting FastAPI app, as nested lifespans are not recognized. Otherwise, the FastMCP server's session manager will not be properly initialized.
152
+ </Warning>
153
+
154
+
155
+ ## Custom Routes
156
+
157
+ In addition to adding your FastMCP server to an existing ASGI app, you can also add custom web routes to your FastMCP server, which will be exposed alongside the MCP endpoint. To do so, use the `@custom_route` decorator. Note that this is less flexible than using a full ASGI framework, but can be useful for adding simple endpoints like health checks to your standalone server.
158
+
159
+ ```python
160
+ from fastmcp import FastMCP
161
+ from starlette.requests import Request
162
+ from starlette.responses import JSONResponse
163
+
164
+ mcp = FastMCP("MyServer")
165
+
166
+ @mcp.custom_route("/health", methods=["GET"])
167
+ async def health_check(request: Request) -> JSONResponse:
168
+ return JSONResponse({"status": "healthy"})
169
+ ```
170
+
171
+ These routes will be included in the FastMCP app when mounted in your web application.
@@ -189,4 +189,25 @@ if __name__ == "__main__":
189
189
  ```
190
190
  </CodeGroup>
191
191
 
192
- Your client only needs to know the host, port, and "main" path; the message path will be transmitted to it as part of the connection handshake.
192
+ Your client only needs to know the host, port, and "main" path; the message path will be transmitted to it as part of the connection handshake.
193
+
194
+
195
+
196
+ ## Custom Routes
197
+
198
+ You can also add custom web routes to your FastMCP server, which will be exposed alongside the MCP endpoint. To do so, use the `@custom_route` decorator. Note that this is less flexible than using a full ASGI framework, but can be useful for adding simple endpoints like health checks to your standalone server.
199
+
200
+ ```python
201
+ from fastmcp import FastMCP
202
+ from starlette.requests import Request
203
+ from starlette.responses import JSONResponse
204
+
205
+ mcp = FastMCP("MyServer")
206
+
207
+ @mcp.custom_route("/health", methods=["GET"])
208
+ async def health_check(request: Request) -> JSONResponse:
209
+ return JSONResponse({"status": "healthy"})
210
+
211
+ if __name__ == "__main__":
212
+ mcp.run()
213
+ ```
@@ -58,6 +58,7 @@
58
58
  "group": "Deployment",
59
59
  "pages": [
60
60
  "deployment/running-server",
61
+ "deployment/asgi",
61
62
  "deployment/authentication"
62
63
  ]
63
64
  },
@@ -81,7 +81,7 @@ pytest
81
81
 
82
82
  ### Pre-Commit Hooks
83
83
 
84
- FastMCP uses pre-commit to manage code quality, including formatting, linting, and type-safety. All PR's must pass the pre-commit hooks, which are run as a part of the CI process. To install the pre-commit hooks, run:
84
+ FastMCP uses pre-commit to manage code quality, including formatting, linting, and type-safety. All PRs must pass the pre-commit hooks, which are run as a part of the CI process. To install the pre-commit hooks, run:
85
85
 
86
86
  ```bash
87
87
  uv run pre-commit install
@@ -89,7 +89,7 @@ This lets us run the server with `python my_server.py`, using the default `stdio
89
89
  <Tip>
90
90
  Why do we need the `if __name__ == "__main__":` block?
91
91
 
92
- Within the FastMCP ecosystem, this line may be unecessary. However, including it ensures that your FastMCP server runs for all users and clients in a consistent way and is therefore recommended as best practice.
92
+ Within the FastMCP ecosystem, this line may be unnecessary. However, including it ensures that your FastMCP server runs for all users and clients in a consistent way and is therefore recommended as best practice.
93
93
  </Tip>
94
94
 
95
95
  ### Interacting with the Python server
@@ -124,5 +124,5 @@ fastmcp run my_server.py:mcp
124
124
  Note that FastMCP *does not* require the `__main__` block in the server file, and will ignore it if it is present. Instead, it looks for the server object provided in the CLI command (here, `mcp`). If no server object is provided, `fastmcp run` will automatically search for servers called "mcp", "app", or "server" in the file.
125
125
 
126
126
  <Tip>
127
- We pointed our client at the server file, which is recognized as a Python MCP server and executed with `python my_server.py` by default. This exceutes the `__main__` block of the server file. There are other ways to run the server, which are described in the [server configuration](/servers/fastmcp#running-the-server) guide.
127
+ We pointed our client at the server file, which is recognized as a Python MCP server and executed with `python my_server.py` by default. This executes the `__main__` block of the server file. There are other ways to run the server, which are described in the [server configuration](/servers/fastmcp#running-the-server) guide.
128
128
  </Tip>
@@ -65,3 +65,10 @@ FastMCP aims to be:
65
65
  🔍 **Complete**: FastMCP aims to provide a full implementation of the core MCP specification
66
66
 
67
67
 
68
+ ## `llms.txt`
69
+
70
+ This documentation is also available in [llms.txt format](https://llmstxt.org/), which is a simple markdown standard that LLMs can consume easily.
71
+
72
+ There are two ways to access the LLM-friendly documentation:
73
+ - [`llms.txt`](https://gofastmcp.com/llms.txt) is essentially a sitemap, listing all the pages in the documentation.
74
+ - [`llms-full.txt`](https://gofastmcp.com/llms-full.txt) contains the entire documentation. Note this may exceed the context window of your LLM.
@@ -83,7 +83,7 @@ asyncio_mode = "auto"
83
83
  asyncio_default_fixture_loop_scope = "session"
84
84
  asyncio_default_test_loop_scope = "session"
85
85
  filterwarnings = []
86
- timeout = 5
86
+ timeout = 3
87
87
 
88
88
  [tool.pyright]
89
89
  include = ["src", "tests"]
@@ -0,0 +1 @@
1
+ Patched low-level objects. When possible, we prefer the official SDK, but we patch bugs here if necessary.