Skip to content

Commit 1606c96

Browse files
committed
Test case showing failure at main
1 parent d3133ae commit 1606c96

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import httpx
2+
import pytest
3+
4+
from mcp.client.session import ClientSession
5+
from mcp.client.streamable_http import streamable_http_client
6+
from mcp.server import MCPServer
7+
8+
9+
@pytest.fixture
10+
def server() -> MCPServer:
11+
mcp = MCPServer("test_server")
12+
13+
@mcp.tool()
14+
async def my_tool() -> str:
15+
return "test"
16+
17+
return mcp
18+
19+
20+
HOST = "testserver"
21+
22+
23+
@pytest.mark.anyio
24+
async def test_streamable_http_server_cleanup(server: MCPServer):
25+
mcp_app = server.streamable_http_app(host=HOST)
26+
async with (
27+
mcp_app.router.lifespan_context(mcp_app),
28+
httpx.ASGITransport(mcp_app) as transport,
29+
httpx.AsyncClient(transport=transport) as client,
30+
streamable_http_client(f"http://{HOST}/mcp", http_client=client) as (read_stream, write_stream),
31+
ClientSession(read_stream, write_stream) as session,
32+
):
33+
await session.initialize()
34+
await session.call_tool("my_tool", arguments={})

0 commit comments

Comments
 (0)