Package: src:python-mcp
Version: 1.28.1-1
Tags: patch
I noticed the autopkgtest check on riscv64 failed for python3-mcp, and
had a look. I was able to build the package on ricci.debian.org, and
trigger a failure by running pybuild-autopkgtest, but this time it only
failed in one test. The problem seem to be performace related, and the
following patch got the failed test working.
--- python-mcp-1.28.1.orig/tests/shared/test_streamable_http.py
+++ python-mcp-1.28.1/tests/shared/test_streamable_http.py
@@ -2133,7 +2133,7 @@ async def test_streamable_http_multiple_
params=types.CallToolRequestParams(
name="tool_with_multiple_stream_closes",
# retry_interval=500ms, so sleep 600ms to ensure
reconnect completes
- arguments={"checkpoints": 3, "sleep_time": 0.6},
+ arguments={"checkpoints": 3, "sleep_time": 1.2},
),
)
),
Without this patch, the testing fail with this error message:
_______________ test_streamable_http_multiple_reconnections ________________
[gw3] linux -- Python 3.14.6 /usr/bin/python3.14
event_server = (<test_streamable_http.SimpleEventStore object at 0x3f9d4c3250>,
'http://127.0.0.1:42719')
@pytest.mark.anyio
async def test_streamable_http_multiple_reconnections(
event_server: tuple[SimpleEventStore, str],
):
"""Verify multiple close_sse_stream() calls each trigger a client
reconnect.
Server uses retry_interval=500ms, tool sleeps 600ms after each close to
ensure
client has time to reconnect before the next checkpoint.
With 3 checkpoints, we expect 8 resumption tokens:
- 1 priming (initial POST connection)
- 3 notifications (checkpoint_0, checkpoint_1, checkpoint_2)
- 3 priming (one per reconnect after each close)
- 1 response
"""
_, server_url = event_server
resumption_tokens: list[str] = []
async def on_resumption_token(token: str) -> None:
resumption_tokens.append(token)
async with streamable_http_client(f"{server_url}/mcp") as (read_stream,
write_stream, _):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
# Use send_request with metadata to track resumption tokens
metadata =
ClientMessageMetadata(on_resumption_token_update=on_resumption_token)
result = await session.send_request(
types.ClientRequest(
types.CallToolRequest(
method="tools/call",
params=types.CallToolRequestParams(
name="tool_with_multiple_stream_closes",
# retry_interval=500ms, so sleep 600ms to
ensure reconnect completes
arguments={"checkpoints": 3, "sleep_time": 0.6},
),
)
),
types.CallToolResult,
metadata=metadata,
)
assert result.content[0].type == "text"
assert isinstance(result.content[0], TextContent)
assert "Completed 3 checkpoints" in result.content[0].text
# 4 priming + 3 notifications + 1 response = 8 tokens
> assert len(resumption_tokens) == 8, ( # pragma: no cover
f"Expected 8 resumption tokens (4 priming + 3 notifs + 1 response),
"
f"got {len(resumption_tokens)}: {resumption_tokens}"
)
E AssertionError: Expected 8 resumption tokens (4 priming + 3 notifs + 1
response), got 7: ['3', '4', '5', '6', '7', '8', '9']
E assert 7 == 8
E + where 7 = len(['3', '4', '5', '6', '7', '8', ...])
tests/shared/test_streamable_http.py:2149: AssertionError
Perhaps there are other preformance related tests that are failing on
riscv64 too?
--
Happy hacking
Petter Reinholdtsen