1212import logging
1313from collections .abc import Callable
1414from dataclasses import dataclass
15- from datetime import timedelta
1615from types import TracebackType
1716from typing import Any , TypeAlias , overload
1817
@@ -41,11 +40,11 @@ class SseServerParameters(BaseModel):
4140 # Optional headers to include in requests.
4241 headers : dict [str , Any ] | None = None
4342
44- # HTTP timeout for regular operations.
45- timeout : float = 5
43+ # HTTP timeout for regular operations (in seconds) .
44+ timeout : float = 5.0
4645
47- # Timeout for SSE read operations.
48- sse_read_timeout : float = 60 * 5
46+ # Timeout for SSE read operations (in seconds) .
47+ sse_read_timeout : float = 300.0
4948
5049
5150class StreamableHttpParameters (BaseModel ):
@@ -57,11 +56,11 @@ class StreamableHttpParameters(BaseModel):
5756 # Optional headers to include in requests.
5857 headers : dict [str , Any ] | None = None
5958
60- # HTTP timeout for regular operations.
61- timeout : timedelta = timedelta ( seconds = 30 )
59+ # HTTP timeout for regular operations (in seconds) .
60+ timeout : float = 30.0
6261
63- # Timeout for SSE read operations.
64- sse_read_timeout : timedelta = timedelta ( seconds = 60 * 5 )
62+ # Timeout for SSE read operations (in seconds) .
63+ sse_read_timeout : float = 300.0
6564
6665 # Close the client session when the transport closes.
6766 terminate_on_close : bool = True
@@ -76,7 +75,7 @@ class StreamableHttpParameters(BaseModel):
7675class ClientSessionParameters :
7776 """Parameters for establishing a client session to an MCP server."""
7877
79- read_timeout_seconds : timedelta | None = None
78+ read_timeout_seconds : float | None = None
8079 sampling_callback : SamplingFnT | None = None
8180 elicitation_callback : ElicitationFnT | None = None
8281 list_roots_callback : ListRootsFnT | None = None
@@ -197,7 +196,7 @@ async def call_tool(
197196 self ,
198197 name : str ,
199198 arguments : dict [str , Any ],
200- read_timeout_seconds : timedelta | None = None ,
199+ read_timeout_seconds : float | None = None ,
201200 progress_callback : ProgressFnT | None = None ,
202201 * ,
203202 meta : dict [str , Any ] | None = None ,
@@ -210,7 +209,7 @@ async def call_tool(
210209 name : str ,
211210 * ,
212211 args : dict [str , Any ],
213- read_timeout_seconds : timedelta | None = None ,
212+ read_timeout_seconds : float | None = None ,
214213 progress_callback : ProgressFnT | None = None ,
215214 meta : dict [str , Any ] | None = None ,
216215 ) -> types .CallToolResult : ...
@@ -219,7 +218,7 @@ async def call_tool(
219218 self ,
220219 name : str ,
221220 arguments : dict [str , Any ] | None = None ,
222- read_timeout_seconds : timedelta | None = None ,
221+ read_timeout_seconds : float | None = None ,
223222 progress_callback : ProgressFnT | None = None ,
224223 * ,
225224 meta : dict [str , Any ] | None = None ,
@@ -314,8 +313,8 @@ async def _establish_session(
314313 httpx_client = create_mcp_http_client (
315314 headers = server_params .headers ,
316315 timeout = httpx .Timeout (
317- server_params .timeout . total_seconds () ,
318- read = server_params .sse_read_timeout . total_seconds () ,
316+ server_params .timeout ,
317+ read = server_params .sse_read_timeout ,
319318 ),
320319 )
321320 await session_stack .enter_async_context (httpx_client )
0 commit comments