Skip to content

Commit c891fe4

Browse files
author
shiraayal-tadata
committed
added http custom timeout example
1 parent 9d746c2 commit c891fe4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
This example shows how to configure the HTTP client timeout for the MCP server.
3+
In case you have API endpoints that take longer than 5 seconds to respond, you can increase the timeout.
4+
"""
5+
import httpx
6+
7+
from examples.shared.apps.items import app
8+
from examples.shared.setup import setup_logging
9+
10+
from fastapi_mcp import FastApiMCP
11+
12+
setup_logging()
13+
14+
mcp = FastApiMCP(
15+
app,
16+
http_client=httpx.AsyncClient(timeout=10)
17+
)
18+
mcp.mount(mcp)
19+
20+
21+
if __name__ == "__main__":
22+
import uvicorn
23+
24+
uvicorn.run(app, host="0.0.0.0", port=8000)

0 commit comments

Comments
 (0)