From 7fa8459d42d0ca38c69cd932e208c1228e2fbe9e Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Wed, 30 Apr 2025 08:35:42 -0400 Subject: [PATCH] Update docs --- docs/patterns/fastapi.mdx | 13 +++++++++++++ docs/patterns/openapi.mdx | 17 +++++++++++++++++ src/fastmcp/server/openapi.py | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/patterns/fastapi.mdx b/docs/patterns/fastapi.mdx index a5501a225..78591a1e0 100644 --- a/docs/patterns/fastapi.mdx +++ b/docs/patterns/fastapi.mdx @@ -44,6 +44,19 @@ if __name__ == "__main__": mcp.run() # Start the MCP server ``` +## Configuration Options + +### Timeout + +You can set a timeout for all API requests: + +```python +# Set a 5 second timeout for all requests +mcp = FastMCP.from_fastapi(app=app, timeout=5.0) +``` + +This timeout is applied to all requests made by tools, resources, and resource templates. + ## Route Mapping By default, FastMCP will map FastAPI routes to MCP components according to the following rules: diff --git a/docs/patterns/openapi.mdx b/docs/patterns/openapi.mdx index ca8df1983..1eb6835d0 100644 --- a/docs/patterns/openapi.mdx +++ b/docs/patterns/openapi.mdx @@ -27,6 +27,23 @@ if __name__ == "__main__": mcp.run() ``` +## Configuration Options + +### Timeout + +You can set a timeout for all API requests: + +```python +# Set a 5 second timeout for all requests +mcp = FastMCP.from_openapi( + openapi_spec=spec, + client=api_client, + timeout=5.0 +) +``` + +This timeout is applied to all requests made by tools, resources, and resource templates. + ## Route Mapping By default, OpenAPI routes are mapped to MCP components based on these rules: diff --git a/src/fastmcp/server/openapi.py b/src/fastmcp/server/openapi.py index 4fe5532d0..861257fbb 100644 --- a/src/fastmcp/server/openapi.py +++ b/src/fastmcp/server/openapi.py @@ -448,7 +448,7 @@ class FastMCPOpenAPI(FastMCP): client: httpx AsyncClient for making HTTP requests name: Optional name for the server route_maps: Optional list of RouteMap objects defining route mappings - default_mime_type: Default MIME type for resources + timeout: Optional timeout (in seconds) for all requests **settings: Additional settings for FastMCP """ super().__init__(name=name or "OpenAPI FastMCP", **settings)