From 66975f54f7d7d20cc182dc83e65a395a95d0c847 Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Thu, 11 Jun 2026 00:14:00 +0800 Subject: [PATCH] fix: Map MCP device_command_run parameter to tool's expected field name MCP sent 'device_commands' but the internal display_tools_nornir expects 'device_configs'. Renamed parameter for consistency. --- gns3server/api/routes/mcp/__init__.py | 6 +++--- gns3server/api/routes/mcp/device_config.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gns3server/api/routes/mcp/__init__.py b/gns3server/api/routes/mcp/__init__.py index 9a770924b..70f430894 100644 --- a/gns3server/api/routes/mcp/__init__.py +++ b/gns3server/api/routes/mcp/__init__.py @@ -1187,8 +1187,8 @@ async def device_config_send( @mcp.tool() async def device_command_run( project_id: Annotated[str, Field(description="UUID of the project")], - device_commands: Annotated[list, Field( - description="List of device show commands. Each entry: {\"device_name\": \"R1\", \"show_commands\": [\"show ip int brief\", \"show running-config\"]}" + device_configs: Annotated[list, Field( + description="List of device commands. Each entry: {\"device_name\": \"R1\", \"show_commands\": [\"show ip int brief\", \"show running-config\"]}" )], ) -> list[dict[str, Any]]: """Run read-only diagnostic (show) commands on network devices via console. @@ -1197,7 +1197,7 @@ async def device_command_run( Devices must be started first. """ return await asyncio.to_thread(_run_handler_sync, device_command_run_handler, { - "project_id": project_id, "device_commands": device_commands, + "project_id": project_id, "device_configs": device_configs, }) diff --git a/gns3server/api/routes/mcp/device_config.py b/gns3server/api/routes/mcp/device_config.py index 790d4b89f..6d886a81c 100644 --- a/gns3server/api/routes/mcp/device_config.py +++ b/gns3server/api/routes/mcp/device_config.py @@ -62,16 +62,16 @@ def device_config_send_handler(params: dict[str, Any], gns3_ctx: dict[str, Any]) def device_command_run_handler(params: dict[str, Any], gns3_ctx: dict[str, Any]) -> list[dict[str, Any]]: """Run read-only diagnostic (show) commands on network devices.""" project_id = params.get("project_id") - device_commands = params.get("device_commands") - if not project_id or not device_commands: - return [{"error": "project_id and device_commands are required"}] + device_configs = params.get("device_configs") + if not project_id or not device_configs: + return [{"error": "project_id and device_configs (list of {device_name, show_commands}) are required"}] from gns3server.agent.gns3_copilot.tools_v2.display_tools_nornir import ExecuteMultipleDeviceCommands tool = ExecuteMultipleDeviceCommands() input_data = json.dumps({ "project_id": project_id, - "device_commands": device_commands, + "device_configs": device_configs, }) return tool._run( input_data,