feat: Pass through and expose additional parameters in ClientSessionGroup.call_tool and .connect_to_server (#1576)
This commit is contained in:
parent
9724ad1ce6
commit
a357380cfa
1 changed files with 101 additions and 11 deletions
|
|
@ -5,7 +5,12 @@ import pytest
|
|||
|
||||
import mcp
|
||||
from mcp import types
|
||||
from mcp.client.session_group import ClientSessionGroup, SseServerParameters, StreamableHttpParameters
|
||||
from mcp.client.session_group import (
|
||||
ClientSessionGroup,
|
||||
ClientSessionParameters,
|
||||
SseServerParameters,
|
||||
StreamableHttpParameters,
|
||||
)
|
||||
from mcp.client.stdio import StdioServerParameters
|
||||
from mcp.shared.exceptions import McpError
|
||||
|
||||
|
|
@ -62,7 +67,7 @@ class TestClientSessionGroup:
|
|||
# --- Test Execution ---
|
||||
result = await mcp_session_group.call_tool(
|
||||
name="server1-my_tool",
|
||||
args={
|
||||
arguments={
|
||||
"name": "value1",
|
||||
"args": {},
|
||||
},
|
||||
|
|
@ -73,6 +78,9 @@ class TestClientSessionGroup:
|
|||
mock_session.call_tool.assert_called_once_with(
|
||||
"my_tool",
|
||||
{"name": "value1", "args": {}},
|
||||
read_timeout_seconds=None,
|
||||
progress_callback=None,
|
||||
meta=None,
|
||||
)
|
||||
|
||||
async def test_connect_to_server(self, mock_exit_stack: contextlib.AsyncExitStack):
|
||||
|
|
@ -329,7 +337,7 @@ class TestClientSessionGroup:
|
|||
(
|
||||
returned_server_info,
|
||||
returned_session,
|
||||
) = await group._establish_session(server_params_instance)
|
||||
) = await group._establish_session(server_params_instance, ClientSessionParameters())
|
||||
|
||||
# --- Assertions ---
|
||||
# 1. Assert the correct specific client function was called
|
||||
|
|
@ -357,7 +365,17 @@ class TestClientSessionGroup:
|
|||
mock_client_cm_instance.__aenter__.assert_awaited_once()
|
||||
|
||||
# 2. Assert ClientSession was called correctly
|
||||
mock_ClientSession_class.assert_called_once_with(mock_read_stream, mock_write_stream)
|
||||
mock_ClientSession_class.assert_called_once_with(
|
||||
mock_read_stream,
|
||||
mock_write_stream,
|
||||
read_timeout_seconds=None,
|
||||
sampling_callback=None,
|
||||
elicitation_callback=None,
|
||||
list_roots_callback=None,
|
||||
logging_callback=None,
|
||||
message_handler=None,
|
||||
client_info=None,
|
||||
)
|
||||
mock_raw_session_cm.__aenter__.assert_awaited_once()
|
||||
mock_entered_session.initialize.assert_awaited_once()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue