Uh oh!
There was an error while loading. Please reload this page.
Add ergonomic Client class for testing MCP servers - #1870
Conversation
e3c2972 to
0b610a8Comparefelixweinberger
commented
Jan 16, 2026
Key files to review:
Remainder is tests being updated to use the new interface. NOTE: This only implements test support. Refactoring Client to support different transports for the end-user API (streamable HTTP, stdio, SSE, etc.) is coming, marked as TODO in the Client docstring. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Follow-up tasks
|
bf03f32 to
a7659d1Comparea7659d1 to
27f896dCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Add a high-level Client class that wraps ClientSession with transport
management, making it easier to test MCP servers.
Key changes:
- Add Client class with async context manager support
- Add InMemoryTransport for in-memory server connections
- Migrate test files to use new Client(server) API
- Update testing documentation with Client usage examples
Usage:
async with Client(server) as client:
result = await client.call_tool('my_tool', {'arg': 'value'})6e60a85 to
621081eCompareUh oh!
There was an error while loading. Please reload this page.
Summary
Adds a high-level
Clientclass that provides an ergonomic API for testing MCP servers with in-memory transport.Motivation and Context
Testing MCP servers currently requires using the verbose
create_connected_server_and_client_sessionfunction. This PR introduces a simpler API:Related issues:
How Has This Been Tested?
ClientandInMemoryTransportcreate_connected_server_and_client_sessionto new APIBreaking Changes
create_connected_server_and_client_sessionfrommcp.shared.memory(v2 breaking change)Types of changes
Checklist
Additional context
New API
High-level (recommended):
Low-level (for advanced use cases):