Add the client-side subscriptions/listen driver (#3047)

This commit is contained in:
Max 2026-07-07 14:26:09 +01:00 • committed by GitHub
commit 9bdc03d54e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,7 +35,7 @@ from mcp_types import (
from mcp_types.version import LATEST_HANDSHAKE_VERSION
from pydantic import FileUrl
from mcp import MCPError
from mcp import MCPDeprecationWarning, MCPError
from mcp.client._memory import InMemoryTransport
from mcp.client._transport import TransportStreams
from mcp.client.client import Client
@ -310,13 +310,15 @@ async def test_client_send_progress_notification():
async def test_client_subscribe_resource(simple_server: Server):
async with Client(simple_server, mode="legacy") as client:
result = await client.subscribe_resource("memory://test")
with pytest.warns(MCPDeprecationWarning, match="use Client.listen"):
result = await client.subscribe_resource("memory://test") # pyright: ignore[reportDeprecated]
assert result == snapshot(EmptyResult())
async def test_client_unsubscribe_resource(simple_server: Server):
async with Client(simple_server, mode="legacy") as client:
result = await client.unsubscribe_resource("memory://test")
with pytest.warns(MCPDeprecationWarning, match="use Client.listen"):
result = await client.unsubscribe_resource("memory://test") # pyright: ignore[reportDeprecated]
assert result == snapshot(EmptyResult())