Skip to content

Commit b9955e0

Browse files
Migrate test files from create_connected_server_and_client_session
Migrate the following files to use the new Client API: - tests/server/fastmcp/test_server.py: Use Client.from_server(mcp) instead of client_session(mcp._mcp_server) - tests/shared/test_session.py: Use InMemoryTransport + ClientSession for low-level session tests - tests/shared/test_progress_notifications.py: Use InMemoryTransport for progress callback exception test - examples/fastmcp/weather_structured.py: Use Client.from_server(mcp) for the example The high-level Client API is used for tests that just need to call tools, resources, and prompts. The low-level InMemoryTransport + ClientSession pattern is used for tests that need direct session access (e.g., _in_flight, send_notification, send_request).
1 parent 64abe69 commit b9955e0

File tree

4 files changed

+116
-114
lines changed

4 files changed

+116
-114
lines changed

examples/fastmcp/weather_structured.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
from pydantic import BaseModel, Field
1616

17+
from mcp.client import Client
1718
from mcp.server.fastmcp import FastMCP
18-
from mcp.shared.memory import create_connected_server_and_client_session as client_session
1919

2020
# Create server
2121
mcp = FastMCP("Weather Service")
@@ -157,7 +157,7 @@ async def test() -> None:
157157
print("Testing Weather Service Tools (via MCP protocol)\n")
158158
print("=" * 80)
159159

160-
async with client_session(mcp._mcp_server) as client:
160+
async with Client.from_server(mcp) as client:
161161
# Test get_weather
162162
result = await client.call_tool("get_weather", {"city": "London"})
163163
print("\nWeather in London:")

0 commit comments

Comments
 (0)