mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 12:30:13 +03:00
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.
This commit is contained in:
parent
571853599f
commit
66975f54f7
@ -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,
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user