forked from modelcontextprotocol/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_memory.py
More file actions
30 lines (23 loc) · 799 Bytes
/
Copy pathtest_memory.py
File metadata and controls
30 lines (23 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest
from mcp import Client
from mcp.server import Server
from mcp.types import EmptyResult, Resource
@pytest.fixture
def mcp_server() -> Server:
server = Server(name="test_server")
@server.list_resources()
async def handle_list_resources(): # pragma: no cover
return [
Resource(
uri="memory://test",
name="Test Resource",
description="A test resource",
)
]
return server
@pytest.mark.anyio
async def test_memory_server_and_client_connection(mcp_server: Server):
"""Shows how a client and server can communicate over memory streams."""
async with Client(mcp_server) as client:
response = await client.send_ping()
assert isinstance(response, EmptyResult)