Files
wehub-resource-sync 49b9bb6724
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:10:27 +08:00

33 lines
1.2 KiB
Python

"""Call a tool whose SSE stream the server closes mid-flight; the call still completes. HTTP-only — no SSE on stdio."""
import anyio
from mcp_types import TextContent
from mcp.client import Client
from stories._harness import Target, run_client
async def main(target: Target, *, mode: str = "auto") -> None:
async with Client(target, mode=mode) as client:
messages: list[str | None] = []
async def on_progress(progress: float, total: float | None, message: str | None) -> None:
messages.append(message)
with anyio.fail_after(10):
result = await client.call_tool("long_operation", {}, progress_callback=on_progress)
# The result arrived — the client transport survived the server-initiated close,
# reconnected with Last-Event-ID, and received the replayed response.
assert not result.is_error, result
assert isinstance(result.content[0], TextContent)
assert result.content[0].text == "resumed"
# "after-close" was emitted while no SSE stream was open; receiving it proves the
# event store buffered it and the reconnect replayed it.
assert messages == ["before-close", "after-close"], messages
if __name__ == "__main__":
run_client(main)