@@ -106,13 +106,11 @@ def __init__(
106106 ** self .headers ,
107107 }
108108
109- async def _update_headers_with_session (
109+ def _update_headers_with_session (
110110 self , base_headers : dict [str , str ]
111111 ) -> dict [str , str ]:
112- """Update headers with session ID."""
112+ """Update headers with session ID if available ."""
113113 headers = base_headers .copy ()
114-
115- # Add session ID if available
116114 if self .session_id :
117115 headers [MCP_SESSION_ID ] = self .session_id
118116 return headers
@@ -189,7 +187,7 @@ async def handle_get_stream(
189187 if not self .session_id :
190188 return
191189
192- headers = await self ._update_headers_with_session (self .request_headers )
190+ headers = self ._update_headers_with_session (self .request_headers )
193191
194192 async with aconnect_sse (
195193 client ,
@@ -211,7 +209,7 @@ async def handle_get_stream(
211209
212210 async def _handle_resumption_request (self , ctx : RequestContext ) -> None :
213211 """Handle a resumption request using GET with SSE."""
214- headers = await self ._update_headers_with_session (ctx .headers )
212+ headers = self ._update_headers_with_session (ctx .headers )
215213 if ctx .metadata and ctx .metadata .resumption_token :
216214 headers [LAST_EVENT_ID ] = ctx .metadata .resumption_token
217215 else :
@@ -246,7 +244,7 @@ async def _handle_resumption_request(self, ctx: RequestContext) -> None:
246244
247245 async def _handle_post_request (self , ctx : RequestContext ) -> None :
248246 """Handle a POST request with response processing."""
249- headers = await self ._update_headers_with_session (ctx .headers )
247+ headers = self ._update_headers_with_session (ctx .headers )
250248 message = ctx .session_message .message
251249 is_initialization = self ._is_initialization_request (message )
252250
@@ -410,7 +408,7 @@ async def terminate_session(self, client: httpx.AsyncClient) -> None:
410408 return
411409
412410 try :
413- headers = await self ._update_headers_with_session (self .request_headers )
411+ headers = self ._update_headers_with_session (self .request_headers )
414412 response = await client .delete (self .url , headers = headers )
415413
416414 if response .status_code == 405 :
@@ -447,14 +445,6 @@ async def streamablehttp_client(
447445 `sse_read_timeout` determines how long (in seconds) the client will wait for a new
448446 event before disconnecting. All other HTTP operations are controlled by `timeout`.
449447
450- Args:
451- url: StreamableHTTP endpoint URL
452- headers: Optional HTTP headers
453- timeout: HTTP request timeout
454- sse_read_timeout: SSE read timeout
455- terminate_on_close: Whether to terminate session on close
456- auth: Optional HTTPX authentication handler
457-
458448 Yields:
459449 Tuple containing:
460450 - read_stream: Stream for reading messages from the server
0 commit comments