@@ -188,11 +188,35 @@ async def main():
188
188
For example for a server running locally, this might be `http://localhost:3001/sse`.
189
189
"""
190
190
191
+ headers : dict [str , Any ] | None = None
192
+ """Optional HTTP headers to be sent with each request to the SSE endpoint.
193
+
194
+ These headers will be passed directly to the underlying `httpx.AsyncClient`.
195
+ Useful for authentication, custom headers, or other HTTP-specific configurations.
196
+ """
197
+
198
+ timeout : float = 5
199
+ """Initial connection timeout in seconds for establishing the SSE connection.
200
+
201
+ This timeout applies to the initial connection setup and handshake.
202
+ If the connection cannot be established within this time, the operation will fail.
203
+ """
204
+
205
+ sse_read_timeout : float = 60 * 5
206
+ """Maximum time in seconds to wait for new SSE messages before timing out.
207
+
208
+ This timeout applies to the long-lived SSE connection after it's established.
209
+ If no new messages are received within this time, the connection will be considered stale
210
+ and may be closed. Defaults to 5 minutes (300 seconds).
211
+ """
212
+
191
213
@asynccontextmanager
192
214
async def client_streams (
193
215
self ,
194
216
) -> AsyncIterator [
195
217
tuple [MemoryObjectReceiveStream [JSONRPCMessage | Exception ], MemoryObjectSendStream [JSONRPCMessage ]]
196
218
]: # pragma: no cover
197
- async with sse_client (url = self .url ) as (read_stream , write_stream ):
219
+ async with sse_client (
220
+ url = self .url , headers = self .headers , timeout = self .timeout , sse_read_timeout = self .sse_read_timeout
221
+ ) as (read_stream , write_stream ):
198
222
yield read_stream , write_stream
0 commit comments