chore: import upstream snapshot with attribution
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) Has been cancelled
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) Has been cancelled
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Receive `notifications/resources/list_changed` over the standalone GET stream, then re-list."""
|
||||
|
||||
import anyio
|
||||
import mcp_types as types
|
||||
|
||||
from mcp.client import Client
|
||||
from stories._harness import Target, run_client
|
||||
|
||||
|
||||
async def main(target: Target, *, mode: str = "auto") -> None:
|
||||
# `message_handler` is constructor-only on `Client`, so the event it sets
|
||||
# has to exist before the connection does.
|
||||
received: list[types.ResourceListChangedNotification] = []
|
||||
seen = anyio.Event()
|
||||
|
||||
async def on_message(message: object) -> None:
|
||||
if isinstance(message, types.ResourceListChangedNotification):
|
||||
received.append(message)
|
||||
seen.set()
|
||||
|
||||
async with Client(target, mode=mode, message_handler=on_message) as client:
|
||||
before = await client.list_resources()
|
||||
assert len(before.resources) >= 1, before
|
||||
|
||||
result = await client.call_tool("add_note", {"content": "hello"})
|
||||
assert not result.is_error, result
|
||||
|
||||
# The notification rides the standalone GET stream, not the call's POST stream —
|
||||
# delivery order vs the tool result is not guaranteed, so wait.
|
||||
with anyio.fail_after(5):
|
||||
await seen.wait()
|
||||
assert len(received) == 1, received
|
||||
|
||||
after = await client.list_resources()
|
||||
assert len(after.resources) == len(before.resources) + 1, after
|
||||
assert {r.name for r in after.resources} >= {"initial", "note-1"}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_client(main)
|
||||
Reference in New Issue
Block a user