You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# With timeout (aborts if execution takes longer than 2 seconds)
125
+
result =await client.call_tool("long_running_task", {"param": "value"}, timeout=2.0)
123
126
```
124
127
* Arguments are passed as a dictionary. FastMCP servers automatically handle JSON string parsing for complex types if needed.
125
128
* Returns a list of content objects (usually `TextContent` or `ImageContent`).
129
+
* The optional `timeout` parameter limits the maximum execution time (in seconds) for this specific call, overriding any client-level timeout.
126
130
127
131
#### Resource Operations
128
132
@@ -191,6 +195,45 @@ These methods are especially useful for debugging or when you need to access met
191
195
192
196
MCP allows servers to interact with clients in order to provide additional capabilities. The `Client` constructor accepts additional configuration to handle these server requests.
193
197
198
+
#### Timeout Control
199
+
200
+
<VersionBadgeversion="2.3.4" />
201
+
202
+
You can control request timeouts at both the client level and individual request level:
203
+
204
+
```python
205
+
from fastmcp import Client
206
+
from fastmcp.exceptions import McpError
207
+
208
+
# Client with a global 5-second timeout for all requests
- With **SSE** transport, the per-request (tool call) timeout **always** takes precedence, regardless of which is lower.
233
+
- With **HTTP** transport, the **lower** of the two timeouts (client or tool call) takes precedence.
234
+
235
+
For consistent behavior across all transports, we recommend explicitly setting timeouts at the individual tool call level when needed, rather than relying on client-level timeouts.
0 commit comments