Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/getting-started/FAQ.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
11 changes: 9 additions & 2 deletions examples/07_configure_http_timeout_example.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()


Expand Down