mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-21 21:45:20 +02:00
refactor(copilot): align tool names with MCP convention
Rename five copilot tools to the MCP <object>_<verb> naming so both agent surfaces expose the same names: - create_gns3_node -> node_create - create_gns3_link -> link_create - create_gns3_text_drawing -> drawing_create_text - create_gns3_rectangle_drawing -> drawing_create_rectangle - create_gns3_ellipse_drawing -> drawing_create_ellipse Also close two capability gaps found during the comparison: - node_create: accept optional per-node compute_id (passed through to the shared handler; before, every node landed on local) - link_create: accept optional per-link link_type (ethernet default, serial supported; before, serial links were impossible) All tools keep calling the same shared handlers in gns3_client/api_handlers.py, so the rename has no effect on execution semantics. Old names appeared nowhere else (prompts, tests, mode tool lists are clean); docs updated accordingly.
This commit is contained in:
4 files changed
+69
-43
No files matched your search
@@ -95,7 +95,7 @@ class GNS3CreateTextDrawingTool(_GNS3CreateDrawingToolBase):
|
||||
computed width/height/line_height, or an "error" key on failure.
|
||||
"""
|
||||
|
||||
name: str = "create_gns3_text_drawing"
|
||||
name: str = "drawing_create_text"
|
||||
description: str = """
|
||||
Adds a text label to the GNS3 project canvas.
|
||||
Input: JSON with project_id, x, y (top-left corner), text and optional
|
||||
@@ -123,7 +123,7 @@ class GNS3CreateRectangleDrawingTool(_GNS3CreateDrawingToolBase):
|
||||
A dictionary with the created drawing, or an "error" key on failure.
|
||||
"""
|
||||
|
||||
name: str = "create_gns3_rectangle_drawing"
|
||||
name: str = "drawing_create_rectangle"
|
||||
description: str = """
|
||||
Adds a rectangle to the GNS3 project canvas.
|
||||
Input: JSON with project_id, x, y, width, height and optional fill,
|
||||
@@ -150,7 +150,7 @@ class GNS3CreateEllipseDrawingTool(_GNS3CreateDrawingToolBase):
|
||||
A dictionary with the created drawing, or an "error" key on failure.
|
||||
"""
|
||||
|
||||
name: str = "create_gns3_ellipse_drawing"
|
||||
name: str = "drawing_create_ellipse"
|
||||
description: str = """
|
||||
Adds an ellipse or circle to the GNS3 project canvas.
|
||||
Input: JSON with project_id, x, y, width, height (bounding box) and
|
||||
|
||||
@@ -57,7 +57,7 @@ class GNS3LinkTool(BaseTool):
|
||||
with error handling for individual link failures.
|
||||
"""
|
||||
|
||||
name: str = "create_gns3_link"
|
||||
name: str = "link_create"
|
||||
description: str = """
|
||||
Creates one or more links between nodes in a GNS3 project.
|
||||
|
||||
@@ -68,6 +68,7 @@ class GNS3LinkTool(BaseTool):
|
||||
- `port1` (str): Port name of the first node (e.g., 'Ethernet0/0').
|
||||
- `node_id2` (str): UUID of the second node.
|
||||
- `port2` (str): Port name of the second node (e.g., 'Ethernet0/0').
|
||||
- `link_type` (str, optional): Link type - "ethernet" (default) or "serial".
|
||||
Note: Port names must match those from `gns3_topology_reader` tool.
|
||||
|
||||
Example Input:
|
||||
@@ -79,6 +80,13 @@ class GNS3LinkTool(BaseTool):
|
||||
"port1": "Ethernet0/0",
|
||||
"node_id2": "uuid-of-node2",
|
||||
"port2": "Ethernet0/0"
|
||||
},
|
||||
{
|
||||
"node_id1": "uuid-of-node2",
|
||||
"port1": "Serial0/0/0",
|
||||
"node_id2": "uuid-of-node3",
|
||||
"port2": "Serial0/0/0",
|
||||
"link_type": "serial"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -160,6 +168,7 @@ class GNS3LinkTool(BaseTool):
|
||||
port1 = link_data.get("port1")
|
||||
node_id2 = link_data.get("node_id2")
|
||||
port2 = link_data.get("port2")
|
||||
link_type = link_data.get("link_type")
|
||||
|
||||
# Validate link parameters
|
||||
if not all([node_id1, port1, node_id2, port2]):
|
||||
@@ -200,28 +209,29 @@ class GNS3LinkTool(BaseTool):
|
||||
created_links.append({"error": error_msg})
|
||||
continue
|
||||
|
||||
# Create the link via the shared REST handler
|
||||
link_resp = create_link_handler(
|
||||
{
|
||||
"project_id": project_id,
|
||||
"nodes": [
|
||||
{
|
||||
"node_id": node_id1,
|
||||
"adapter_number": port1_info.get("adapter_number", 0),
|
||||
"port_number": port1_info.get("port_number", 0),
|
||||
"label": {"text": port1_info.get("short_name") or port1},
|
||||
},
|
||||
{
|
||||
"node_id": node_id2,
|
||||
"adapter_number": port2_info.get("adapter_number", 0),
|
||||
"port_number": port2_info.get("port_number", 0),
|
||||
"label": {"text": port2_info.get("short_name") or port2},
|
||||
},
|
||||
],
|
||||
"fields": ["link_id"],
|
||||
},
|
||||
gns3_ctx,
|
||||
)
|
||||
# Create the link via the shared REST handler. link_type
|
||||
# is passed only when set — the server defaults to ethernet.
|
||||
link_params: dict[str, Any] = {
|
||||
"project_id": project_id,
|
||||
"nodes": [
|
||||
{
|
||||
"node_id": node_id1,
|
||||
"adapter_number": port1_info.get("adapter_number", 0),
|
||||
"port_number": port1_info.get("port_number", 0),
|
||||
"label": {"text": port1_info.get("short_name") or port1},
|
||||
},
|
||||
{
|
||||
"node_id": node_id2,
|
||||
"adapter_number": port2_info.get("adapter_number", 0),
|
||||
"port_number": port2_info.get("port_number", 0),
|
||||
"label": {"text": port2_info.get("short_name") or port2},
|
||||
},
|
||||
],
|
||||
"fields": ["link_id"],
|
||||
}
|
||||
if link_type:
|
||||
link_params["link_type"] = link_type
|
||||
link_resp = create_link_handler(link_params, gns3_ctx)
|
||||
if isinstance(link_resp, list):
|
||||
raise RuntimeError("Unexpected batch response when creating a single link")
|
||||
if "error" in link_resp:
|
||||
|
||||
@@ -99,11 +99,12 @@ class GNS3CreateNodeTool(BaseTool):
|
||||
If error occurs during validation, returns dict with error message.
|
||||
"""
|
||||
|
||||
name: str = "create_gns3_node"
|
||||
name: str = "node_create"
|
||||
description: str = """
|
||||
Creates multiple nodes in a GNS3 project using templates and coordinates.
|
||||
Input is a JSON object with project_id and array of nodes.
|
||||
Each node requires: template_id, x, y. Optional: name (to set node name directly).
|
||||
Each node requires: template_id, x, y. Optional: name (to set node name directly),
|
||||
compute_id (compute to place the node on, default "local").
|
||||
Example input:
|
||||
{
|
||||
"project_id": "uuid-of-project",
|
||||
@@ -118,7 +119,8 @@ class GNS3CreateNodeTool(BaseTool):
|
||||
"template_id": "uuid-of-template2",
|
||||
"x": -200,
|
||||
"y": 300,
|
||||
"name": "R2"
|
||||
"name": "R2",
|
||||
"compute_id": "uuid-of-remote-compute"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -176,6 +178,7 @@ class GNS3CreateNodeTool(BaseTool):
|
||||
x = node_data.get("x")
|
||||
y = node_data.get("y")
|
||||
name = node_data.get("name")
|
||||
compute_id = node_data.get("compute_id")
|
||||
|
||||
if not all(
|
||||
[
|
||||
@@ -208,6 +211,7 @@ class GNS3CreateNodeTool(BaseTool):
|
||||
x = node_data.get("x")
|
||||
y = node_data.get("y")
|
||||
name = node_data.get("name")
|
||||
compute_id = node_data.get("compute_id")
|
||||
|
||||
logger.info(
|
||||
"Creating node %d/%d with template %s at (%s, %s), name=%s...",
|
||||
@@ -219,17 +223,19 @@ class GNS3CreateNodeTool(BaseTool):
|
||||
name,
|
||||
)
|
||||
|
||||
# Create node via the shared REST handler
|
||||
created = create_node_handler(
|
||||
{
|
||||
"project_id": project_id,
|
||||
"template_id": template_id,
|
||||
"x": x,
|
||||
"y": y,
|
||||
"name": name,
|
||||
},
|
||||
gns3_ctx,
|
||||
)
|
||||
# Create node via the shared REST handler. compute_id is
|
||||
# passed only when set — the handler defaults to "local".
|
||||
node_params: dict[str, Any] = {
|
||||
"project_id": project_id,
|
||||
"template_id": template_id,
|
||||
"x": x,
|
||||
"y": y,
|
||||
}
|
||||
if name:
|
||||
node_params["name"] = name
|
||||
if compute_id:
|
||||
node_params["compute_id"] = compute_id
|
||||
created = create_node_handler(node_params, gns3_ctx)
|
||||
if isinstance(created, list):
|
||||
raise RuntimeError("Unexpected batch response when creating a single node")
|
||||
if "error" in created:
|
||||
|
||||
Reference in new issue
Block a user