Skip to content

Commit 1226aa3

Browse files
committed
use two tools
1 parent 994fd80 commit 1226aa3

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import anyio
22
import pytest
3-
from pydantic import AnyUrl
43

54
from mcp.server.fastmcp import FastMCP
65
from mcp.shared.memory import create_connected_server_and_client_session as create_session
76

8-
_resource_name = "slow://slow_resource"
9-
107

118
@pytest.mark.anyio
129
async def test_messages_are_executed_concurrently():
@@ -23,25 +20,27 @@ async def sleep_tool():
2320
call_order.append("tool_end")
2421
return "done"
2522

26-
@server.resource(_resource_name)
27-
async def slow_resource():
23+
@server.tool("trigger")
24+
async def trigger():
2825
# Wait for tool to start before setting the event
2926
await tool_started.wait()
27+
call_order.append("trigger_started")
3028
event.set()
31-
call_order.append("resource_end")
29+
call_order.append("trigger_end")
3230
return "slow"
3331

3432
async with create_session(server._mcp_server) as client_session:
3533
# First tool will wait on event, second will set it
3634
async with anyio.create_task_group() as tg:
3735
# Start the tool first (it will wait on event)
3836
tg.start_soon(client_session.call_tool, "sleep")
39-
# Then the resource (it will set the event)
40-
tg.start_soon(client_session.read_resource, AnyUrl(_resource_name))
37+
# Then the trigger tool will set the event to allow the first tool to continue
38+
await client_session.call_tool("trigger")
4139

4240
# Verify that both ran concurrently
4341
assert call_order == [
4442
"waiting_for_event",
45-
"resource_end",
43+
"trigger_started",
44+
"trigger_end",
4645
"tool_end",
4746
], f"Expected concurrent execution, but got: {call_order}"

0 commit comments

Comments
 (0)