Skip to content

Commit 37384fc

Browse files
Clean up verbose comments and docstrings
- Remove SEP-1699 header comment from tests - Remove verbose Args docstrings from StreamableHTTPTransport.__init__ and streamablehttp_client - Remove Note comment about _handle_sse_response return value
1 parent aac5fab commit 37384fc

File tree

2 files changed

+4
-42
lines changed

2 files changed

+4
-42
lines changed

src/mcp/client/streamable_http.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,7 @@ def __init__(
100100
auth: httpx.Auth | None = None,
101101
reconnection_options: StreamableHTTPReconnectionOptions | None = None,
102102
) -> None:
103-
"""Initialize the StreamableHTTP transport.
104-
105-
Args:
106-
url: The endpoint URL.
107-
headers: Optional headers to include in requests.
108-
timeout: HTTP timeout for regular operations.
109-
sse_read_timeout: Timeout for SSE read operations.
110-
auth: Optional HTTPX authentication handler.
111-
reconnection_options: Options for configuring reconnection behavior.
112-
"""
103+
"""Initialize the StreamableHTTP transport."""
113104
self.url = url
114105
self.headers = headers or {}
115106
self.timeout = timeout.total_seconds() if isinstance(timeout, timedelta) else timeout
@@ -344,11 +335,7 @@ async def _handle_post_request(self, ctx: RequestContext) -> None:
344335
if content_type.startswith(JSON):
345336
await self._handle_json_response(response, ctx.read_stream_writer, is_initialization)
346337
elif content_type.startswith(SSE):
347-
# Note: _handle_sse_response returns (has_priming_event, last_event_id)
348-
# which can be used for reconnection logic if needed
349-
_has_priming_event, _last_event_id = await self._handle_sse_response(
350-
response, ctx, is_initialization
351-
)
338+
await self._handle_sse_response(response, ctx, is_initialization)
352339
else:
353340
await self._handle_unexpected_content_type( # pragma: no cover
354341
content_type, # pragma: no cover
@@ -598,22 +585,6 @@ async def streamablehttp_client(
598585
599586
`sse_read_timeout` determines how long (in seconds) the client will wait for a new
600587
event before disconnecting. All other HTTP operations are controlled by `timeout`.
601-
602-
Args:
603-
url: The endpoint URL.
604-
headers: Optional headers to include in requests.
605-
timeout: HTTP timeout for regular operations.
606-
sse_read_timeout: Timeout for SSE read operations.
607-
terminate_on_close: Whether to terminate the session on close.
608-
httpx_client_factory: Factory function to create the HTTP client.
609-
auth: Optional HTTPX authentication handler.
610-
reconnection_options: Options for configuring reconnection behavior.
611-
612-
Yields:
613-
Tuple containing:
614-
- read_stream: Stream for reading messages from the server
615-
- write_stream: Stream for sending messages to the server
616-
- get_session_id_callback: Function to retrieve the current session ID
617588
"""
618589
transport = StreamableHTTPTransport(url, headers, timeout, sse_read_timeout, auth, reconnection_options)
619590

tests/shared/test_streamable_http.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,11 +1608,6 @@ async def bad_client():
16081608
assert tools.tools
16091609

16101610

1611-
# =============================================================================
1612-
# SEP-1699: SSE Polling Support Tests
1613-
# =============================================================================
1614-
1615-
16161611
@pytest.mark.anyio
16171612
async def test_reconnection_delay_with_server_retry():
16181613
"""Test _get_next_reconnection_delay uses server-provided retry value."""
@@ -1769,9 +1764,7 @@ async def test_resume_stream_without_session_id():
17691764
assert transport.session_id is None
17701765

17711766
# Create a dummy stream writer with type annotation
1772-
read_stream_writer, read_stream_reader = anyio.create_memory_object_stream[
1773-
SessionMessage | Exception
1774-
](0)
1767+
read_stream_writer, read_stream_reader = anyio.create_memory_object_stream[SessionMessage | Exception](0)
17751768

17761769
async with httpx.AsyncClient() as client:
17771770
# Should return early without making request
@@ -1806,9 +1799,7 @@ async def test_resume_stream_with_405_response(basic_server: None, basic_server_
18061799
transport.session_id = get_session_id()
18071800

18081801
# Now try to resume with the session - server might return 405
1809-
read_stream_writer, read_stream_reader = anyio.create_memory_object_stream[
1810-
SessionMessage | Exception
1811-
](0)
1802+
read_stream_writer, read_stream_reader = anyio.create_memory_object_stream[SessionMessage | Exception](0)
18121803

18131804
async with httpx.AsyncClient() as client:
18141805
# This should handle the 405 gracefully

0 commit comments

Comments
 (0)