diff --git a/docs/getting-started/FAQ.mdx b/docs/getting-started/FAQ.mdx index e8e3b5c..d18fd41 100644 --- a/docs/getting-started/FAQ.mdx +++ b/docs/getting-started/FAQ.mdx @@ -6,7 +6,7 @@ icon: question ## Usage ### How do I configure HTTP request timeouts? -By default, HTTP requests timeout after 5 seconds. If you have API endpoints that take longer to respond, you can configure a custom timeout by injecting your own httpx client. +By default, HTTP requests timeout after 10 seconds. If you have API endpoints that take longer to respond, you can configure a custom timeout by injecting your own httpx client. For a working example, see [Configure HTTP Timeout Example](https://github.com/tadata-org/fastapi_mcp/blob/main/examples/07_configure_http_timeout_example.py). diff --git a/examples/07_configure_http_timeout_example.py b/examples/07_configure_http_timeout_example.py index f225774..ed31c21 100644 --- a/examples/07_configure_http_timeout_example.py +++ b/examples/07_configure_http_timeout_example.py @@ -1,6 +1,6 @@ """ This example shows how to configure the HTTP client timeout for the MCP server. -In case you have API endpoints that take longer than 5 seconds to respond, you can increase the timeout. +In case you have API endpoints that take longer than 10 seconds to respond, you can increase the timeout. """ from examples.shared.apps.items import app # The FastAPI app @@ -13,7 +13,14 @@ setup_logging() -mcp = FastApiMCP(app, http_client=httpx.AsyncClient(timeout=20)) +mcp = FastApiMCP( + app, + http_client=httpx.AsyncClient( + transport=httpx.ASGITransport(app=app, raise_app_exceptions=False), + base_url="http://apiserver", + timeout=60.0, + ), +) mcp.mount_http()