From 5cc71f3dad1608e0b223efb57ce51006f32126a1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 28 Sep 2025 03:28:38 +0000 Subject: [PATCH 1/2] Initial plan From 685198c8ed9ff3a02cffb11d6594e0d87c922a5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 28 Sep 2025 03:37:58 +0000 Subject: [PATCH 2/2] Fix function integration issues in mcp_client and custom_controller Co-authored-by: Copyxyzai <168319629+Copyxyzai@users.noreply.github.com> --- src/utils/mcp_client.py | 8 ++------ tests/test_controller.py | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/utils/mcp_client.py b/src/utils/mcp_client.py index 126d49da9..7f788020d 100644 --- a/src/utils/mcp_client.py +++ b/src/utils/mcp_client.py @@ -9,20 +9,16 @@ from langchain.tools import BaseTool from langchain_mcp_adapters.client import MultiServerMCPClient from pydantic import BaseModel, Field, create_model -from pydantic.v1 import BaseModel, Field logger = logging.getLogger(__name__) async def setup_mcp_client_and_tools(mcp_server_config: Dict[str, Any]) -> Optional[MultiServerMCPClient]: """ - Initializes the MultiServerMCPClient, connects to servers, fetches tools, - filters them, and returns a flat list of usable tools and the client instance. + Initializes the MultiServerMCPClient, connects to servers, and returns the client instance. Returns: - A tuple containing: - - list[BaseTool]: The filtered list of usable LangChain tools. - - MultiServerMCPClient | None: The initialized and started client instance, or None on failure. + MultiServerMCPClient | None: The initialized and started client instance, or None on failure. """ logger.info("Initializing MultiServerMCPClient...") diff --git a/tests/test_controller.py b/tests/test_controller.py index 173bae44b..6cd94af93 100644 --- a/tests/test_controller.py +++ b/tests/test_controller.py @@ -42,9 +42,11 @@ async def test_mcp_client(): } } - mcp_tools, mcp_client = await setup_mcp_client_and_tools(test_server_config) + mcp_client = await setup_mcp_client_and_tools(test_server_config) - for tool in mcp_tools: + if mcp_client: + for server_name in mcp_client.server_name_to_tools: + for tool in mcp_client.server_name_to_tools[server_name]: tool_param_model = create_tool_param_model(tool) print(tool.name) print(tool.description)