Simplify the documentation structure in `README.md` by removing the `todo/` directory reference and detailed design documents for planned features. Consolidate future roadmap items into a high-level summary under "Future Enhancements". Update `node-control-tools.md` to include documentation for new topology management tools (create node, create link, get template, rename node) and reflect updated API imports for `Link` support.
23 KiB
Node and Topology Management Tools
Overview
GNS3-Copilot provides tools for managing the lifecycle of network devices and topology in GNS3 projects. These tools enable AI agents to create, connect, start, stop, suspend, and manage nodes as part of automated lab management workflows.
Available Tools
GNS3TemplateTool 🆕
Tool Name: get_gns3_templates
Description: Retrieves all available device templates from the GNS3 server, including template names, IDs, and types.
Input:
{}
Output:
{
"templates": [
{
"name": "Cisco IOSv",
"template_id": "uuid-of-template",
"template_type": "router"
},
{
"name": "Ethernet switch",
"template_id": "uuid-of-template2",
"template_type": "switch"
}
]
}
Features:
- Lists all available device templates
- No input required (connects to configured GNS3 server)
- Returns template_id needed for node creation
Use Cases:
- Discover available device types before creating nodes
- Get template_id for GNS3CreateNodeTool
- Template inventory management
GNS3CreateNodeTool 🆕
Tool Name: create_gns3_node
Description: Creates multiple nodes in a GNS3 project using specified templates and coordinates.
Input:
{
"project_id": "uuid-of-project",
"nodes": [
{
"template_id": "uuid-of-template",
"x": 100,
"y": -200
},
{
"template_id": "uuid-of-template2",
"x": -200,
"y": 300
}
]
}
Output:
{
"project_id": "uuid-of-project",
"created_nodes": [
{
"node_id": "uuid-of-node1",
"name": "NodeName1",
"status": "success"
},
{
"node_id": "uuid-of-node2",
"name": "NodeName2",
"status": "success"
}
],
"total_nodes": 2,
"successful_nodes": 2,
"failed_nodes": 0
}
Features:
- Batch create multiple nodes
- Uses templates for consistent node configuration
- X/Y coordinate positioning for topology layout
- Important: Ensure distance between any two nodes is greater than 250px for clear interface labels
Use Cases:
- Automated topology deployment
- Multi-node lab initialization
- Programmatic topology creation
Implementation Details:
- Calls
POST /projects/{project_id}/nodesfor each node - Uses template_id from GNS3TemplateTool
- Assigns default names sequentially (e.g., R1, R2, R3)
GNS3LinkTool 🆕
Tool Name: create_gns3_link
Description: Creates one or more links between nodes in a GNS3 project by connecting their network ports.
Input:
{
"project_id": "uuid-of-project",
"links": [
{
"node_id1": "uuid-of-node1",
"port1": "Ethernet0/0",
"node_id2": "uuid-of-node2",
"port2": "Ethernet0/0"
}
]
}
Output:
[
{
"link_id": "uuid-of-link",
"node_id1": "uuid-of-node1",
"port1": "Ethernet0/0",
"node_id2": "uuid-of-node2",
"port2": "Ethernet0/0"
}
]
Features:
- Batch create multiple links
- Automatic port discovery by name
- Error handling for individual link failures
- Port names must match topology data
Use Cases:
- Automated topology wiring
- Multi-link connection setup
- Network infrastructure deployment
Implementation Details:
- Calls
POST /projects/{project_id}/linksfor each link - Port names must match those from
gns3_topology_readertool - Uses adapter_number and port_number for port identification
- Supports both physical and virtual interfaces
GNS3UpdateNodeNameTool 🆕
Tool Name: update_gns3_node_name
Description: Updates the name of one or multiple nodes in a GNS3 project.
Input:
{
"project_id": "uuid-of-project",
"nodes": [
{"node_id": "uuid-of-node-1", "new_name": "Router1"},
{"node_id": "uuid-of-node-2", "new_name": "Switch1"}
]
}
Output:
{
"project_id": "...",
"total_nodes": 2,
"successful": 2,
"failed": 0,
"nodes": [
{
"node_id": "...",
"old_name": "...",
"new_name": "Router1",
"status": "success"
}
]
}
Features:
- Batch rename multiple nodes
- Verification of name change
- Comprehensive error handling
Use Cases:
- Apply naming conventions to topology
- Rename nodes for better organization
- Update node names after topology creation
Implementation Details:
- Calls
PUT /projects/{project_id}/nodes/{node_id} - Cannot rename while node is started (except special node types)
- CAN rename while node is suspended
GNS3StartNodeTool
Tool Name: start_gns3_node
Description: Starts one or multiple nodes in a GNS3 project with progress tracking and status monitoring.
Input:
{
"project_id": "uuid-of-project",
"node_ids": ["uuid-of-node-1", "uuid-of-node-2"]
}
Output:
{
"project_id": "...",
"total_nodes": 2,
"successful": 2,
"failed": 0,
"nodes": [
{"node_id": "...", "name": "...", "status": "started"},
{"node_id": "...", "name": "...", "status": "started"}
]
}
Features:
- Batch start multiple nodes
- Progress bar with visual feedback
- Automatic status verification
- Comprehensive error handling
- ~140s base wait time + 10s per additional node
Use Cases:
- Automated lab deployment
- Multi-node topology initialization
- Lab startup automation
GNS3StopNodeTool
Tool Name: stop_gns3_node
Description: Stops one or multiple nodes in a GNS3 project.
Input:
{
"project_id": "uuid-of-project",
"node_ids": ["uuid-of-node-1", "uuid-of-node-2"]
}
Output:
{
"project_id": "...",
"total_nodes": 2,
"successful": 2,
"failed": 0,
"nodes": [
{"node_id": "...", "name": "...", "status": "stopped"},
{"node_id": "...", "name": "...", "status": "stopped"}
]
}
Features:
- Batch stop multiple nodes
- Immediate API response (no waiting)
- Automatic status verification
- Comprehensive error handling
- Synchronous operation
Use Cases:
- Lab shutdown automation
- Resource management
- Energy-saving workflows
- Test cleanup procedures
Implementation Details:
- Calls
POST /projects/{project_id}/nodes/{node_id}/stop - Verifies node existence before stopping
- Retrieves updated status after stop command
- Returns detailed results for each node
GNS3SuspendNodeTool
Tool Name: suspend_gns3_node
Description: Suspends one or multiple nodes in a GNS3 project. Suspended nodes preserve their state in memory and can be quickly resumed.
Input:
{
"project_id": "uuid-of-project",
"node_ids": ["uuid-of-node-1", "uuid-of-node-2"]
}
Output:
{
"project_id": "...",
"total_nodes": 2,
"successful": 2,
"failed": 0,
"nodes": [
{"node_id": "...", "name": "...", "status": "suspended"},
{"node_id": "...", "name": "...", "status": "suspended"}
],
"note": "Suspended nodes preserve their state in memory. Use resume to continue where you left off."
}
Features:
- Batch suspend multiple nodes
- Preserves device state in memory
- Immediate API response (no waiting)
- Fast resume capability
- Automatic status verification
- Comprehensive error handling
Use Cases:
- Temporary lab pause (continue later)
- Save experimental state
- Quick context switching
- Resource optimization without losing work
Key Benefits:
- Fast Resume: Resumes in seconds vs. minutes for full restart
- State Preservation: All configurations, connections, and runtime state saved
- Resource Efficiency: Pauses devices without releasing memory
- Lab Snapshots: Save intermediate states for later analysis
Implementation Details:
- Calls
POST /projects/{project_id}/nodes/{node_id}/suspend - Verifies node existence before suspending
- Retrieves updated status after suspend command
- Returns detailed results for each node
- Node name can be changed while suspended (unlike started state)
State Comparison:
| Operation | Result | Recovery Time | State Preserved? | Resource Usage |
|---|---|---|---|---|
| Stop | Powered off | Slow (full boot) | ❌ No | Minimal |
| Suspend | Paused | Fast (seconds) | ✅ Yes | Medium (memory) |
| Start | Running | N/A | N/A | High |
When to Use Suspend vs Stop:
# ✅ Use SUSPEND when:
# - Taking a break and continuing later today
# - Need to test something else temporarily
# - Want to preserve complex configuration state
# - Quick switching between lab scenarios
# ✅ Use STOP when:
# - Done with the lab for now
# - Need to free up system resources
# - Finishing a complete test session
# - Won't need the lab for a while
Technical Implementation
Module Structure
gns3server/agent/gns3_copilot/tools_v2/
├── gns3_create_node.py # Node creation tool 🆕
├── gns3_create_link.py # Link creation tool 🆕
├── gns3_get_node_temp.py # Template retrieval tool 🆕
├── gns3_update_node_name.py # Node rename tool 🆕
├── gns3_start_node.py # Start node tool
├── gns3_stop_node.py # Stop node tool
└── gns3_suspend_node.py # Suspend node tool
API Integration
The tools use the Node and Link classes from custom_gns3fy:
from gns3server.agent.gns3_copilot.gns3_client import Node, Link, get_gns3_connector
# Get templates
templates = get_gns3_connector().get_templates()
# Create node
node = Node(project_id=project_id, template_id=template_id, x=x, y=y, connector=gns3_server)
node.create()
# Create link
link = Link(project_id=project_id, connector=gns3_server, nodes=[...])
link.create()
# Update node name
node = Node(project_id=project_id, node_id=node_id, connector=gns3_server)
node.update(name=new_name)
# Start/stop/suspend node
node = Node(project_id=project_id, node_id=node_id, connector=gns3_server)
node.start() # or node.stop() / node.suspend()
Progress Tracking
GNS3StartNodeTool includes visual progress bar:
Starting 3 node(s), please wait...
[===========> ] 35.0%
Progress Calculation:
- Base duration: 140 seconds
- Extra duration: 10 seconds per additional node
- Formula:
total_duration = 140 + max(0, node_count - 1) * 10
GNS3StopNodeTool does not include progress tracking:
- Stop operations are typically fast (< 5 seconds)
- Immediate API response provides status feedback
- No need for progress indication
GNS3SuspendNodeTool does not include progress tracking:
- Suspend operations are typically fast (< 10 seconds)
- Immediate API response provides status feedback
- No need for progress indication
Node State Transitions
┌─────────┐
│ Stopped │◀─────── stop()
└────┬────┘
│
│ start()
▼
┌──────────┐
│ Started │───suspend()───▶ Suspended
└──────────┘ │
▲ │ │
│ │ stop() │ resume()
└──────┴──────────────────────────┘
State Change Allowed Operations:
| Current State | Can Start? | Can Stop? | Can Suspend? | Can Rename? |
|---|---|---|---|---|
| Stopped | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
| Started | ❌ No | ✅ Yes | ✅ Yes | ❌ No* |
| Suspended | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes |
*Except special node types: cloud, nat, ethernet_switch, ethernet_hub, frame_relay_switch, atm_switch
Copilot Mode Integration
Teaching Assistant Mode
Tools Available:
GNS3TemplateTool- List available device templates 🆕GNS3CreateNodeTool- Create nodes in topology 🆕GNS3LinkTool- Create links between nodes 🆕GNS3UpdateNodeNameTool- Rename nodes 🆕GNS3StartNodeTool- For diagnostics requiring started nodes
Capabilities:
- READ-ONLY diagnostic tools
- Can create and manage topology (nodes, links, names)
- Cannot stop or suspend nodes (prevents disruption of active labs)
Lab Automation Assistant Mode
Tools Available:
GNS3TemplateTool- List available device templates 🆕GNS3CreateNodeTool- Create nodes in topology 🆕GNS3LinkTool- Create links between nodes 🆕GNS3UpdateNodeNameTool- Rename nodes 🆕GNS3StartNodeTool- Full lab deploymentGNS3StopNodeTool- Full lab shutdownGNS3SuspendNodeTool- Lab pause with state preservation
Capabilities:
- Full diagnostic and configuration tools
- Complete topology and lifecycle management (create, connect, start/stop/suspend)
- Automated workflows with state preservation
- Lab snapshot capabilities for later resumption
Usage Examples
Example 1: Start Nodes with Progress
from gns3server.agent.gns3_copilot.tools_v2 import GNS3StartNodeTool
tool = GNS3StartNodeTool()
result = tool._run(json.dumps({
"project_id": "abc-123-def",
"node_ids": ["node-1", "node-2", "node-3"]
}))
# Output includes progress bar and final status
Example 2: Stop Nodes
from gns3server.agent.gns3_copilot.tools_v2 import GNS3StopNodeTool
tool = GNS3StopNodeTool()
result = tool._run(json.dumps({
"project_id": "abc-123-def",
"node_ids": ["node-1", "node-2"]
}))
# Immediate return with stop status
Example 3: Automated Lab Lifecycle
# Lab deployment
start_tool = GNS3StartNodeTool()
start_result = start_tool._run(json.dumps({
"project_id": project_id,
"node_ids": all_node_ids
}))
# ... Run tests ...
# Lab shutdown
stop_tool = GNS3StopNodeTool()
stop_result = stop_tool._run(json.dumps({
"project_id": project_id,
"node_ids": all_node_ids
}))
Example 4: Lab Pause and Resume
from gns3server.agent.gns3_copilot.tools_v2 import GNS3SuspendNodeTool
# Start lab
start_tool = GNS3StartNodeTool()
start_result = start_tool._run(json.dumps({
"project_id": project_id,
"node_ids": all_node_ids
}))
# ... Configure devices ...
# ... Run some tests ...
# Suspend lab (preserves all state)
suspend_tool = GNS3SuspendNodeTool()
suspend_result = suspend_tool._run(json.dumps({
"project_id": project_id,
"node_ids": all_node_ids
}))
# Nodes suspended - state preserved in memory
# ... Take a break, work on something else ...
# Resume lab (quick recovery)
start_result = start_tool._run(json.dumps({
"project_id": project_id,
"node_ids": all_node_ids
}))
# Back to previous state in seconds!
Example 5: Suspend While Renaming Nodes
from gns3server.agent.gns3_copilot.tools_v2 import (
GNS3SuspendNodeTool,
GNS3UpdateNodeNameTool
)
# Suspend nodes first (allows renaming)
suspend_tool = GNS3SuspendNodeTool()
suspend_result = suspend_tool._run(json.dumps({
"project_id": project_id,
"node_ids": node_ids
}))
# Now rename nodes (possible while suspended!)
rename_tool = GNS3UpdateNodeNameTool()
rename_result = rename_tool._run(json.dumps({
"project_id": project_id,
"nodes": [
{"node_id": "node-1", "new_name": "Router-Primary"},
{"node_id": "node-2", "new_name": "Router-Backup"}
]
}))
# Resume when ready
# Note: Cannot rename while started, but CAN rename while suspended!
Example 6: Get Available Templates 🆕
from gns3server.agent.gns3_copilot.tools_v2 import GNS3TemplateTool
tool = GNS3TemplateTool()
result = tool._run("")
# Returns all available device templates
# {
# "templates": [
# {"name": "Cisco IOSv", "template_id": "...", "template_type": "router"},
# {"name": "Ethernet switch", "template_id": "...", "template_type": "switch"}
# ]
# }
Example 7: Create Topology Nodes 🆕
from gns3server.agent.gns3_copilot.tools_v2 import GNS3CreateNodeTool
tool = GNS3CreateNodeTool()
result = tool._run(json.dumps({
"project_id": "abc-123-def",
"nodes": [
{
"template_id": "uuid-of-router-template",
"x": 100,
"y": -200
},
{
"template_id": "uuid-of-switch-template",
"x": -200,
"y": 300
}
]
}))
# Creates two nodes with specified templates and positions
Example 8: Connect Nodes with Links 🆕
from gns3server.agent.gns3_copilot.tools_v2 import GNS3LinkTool
tool = GNS3LinkTool()
result = tool._run(json.dumps({
"project_id": "abc-123-def",
"links": [
{
"node_id1": "uuid-of-node1",
"port1": "Ethernet0/0",
"node_id2": "uuid-of-node2",
"port2": "Ethernet0/0"
},
{
"node_id1": "uuid-of-node1",
"port1": "Ethernet0/1",
"node_id2": "uuid-of-node3",
"port2": "Ethernet0/0"
}
]
}))
# Creates two links connecting the nodes
Example 9: Apply Naming Convention 🆕
from gns3server.agent.gns3_copilot.tools_v2 import GNS3UpdateNodeNameTool
tool = GNS3UpdateNodeNameTool()
result = tool._run(json.dumps({
"project_id": "abc-123-def",
"nodes": [
{"node_id": "node-1", "new_name": "R1-Core"},
{"node_id": "node-2", "new_name": "R2-Core"},
{"node_id": "node-3", "new_name": "S1-Access"},
{"node_id": "node-4", "new_name": "S2-Access"}
]
}))
# Applies consistent naming to all nodes
Example 10: Complete Topology Creation Workflow 🆕
from gns3server.agent.gns3_copilot.tools_v2 import (
GNS3TemplateTool,
GNS3CreateNodeTool,
GNS3LinkTool,
GNS3UpdateNodeNameTool,
GNS3StartNodeTool
)
# Step 1: Get available templates
template_tool = GNS3TemplateTool()
templates = template_tool._run("")
# Find router and switch template_ids...
# Step 2: Create nodes
create_tool = GNS3CreateNodeTool()
nodes = create_tool._run(json.dumps({
"project_id": project_id,
"nodes": [
{"template_id": router_template_id, "x": 0, "y": -200},
{"template_id": router_template_id, "x": 200, "y": -200},
{"template_id": switch_template_id, "x": 100, "y": 0}
]
}))
# Step 3: Connect nodes
link_tool = GNS3LinkTool()
links = link_tool._run(json.dumps({
"project_id": project_id,
"links": [
{"node_id1": nodes["created_nodes"][0]["node_id"], "port1": "Ethernet0/0",
"node_id2": nodes["created_nodes"][2]["node_id"], "port2": "Ethernet0/0"},
{"node_id1": nodes["created_nodes"][1]["node_id"], "port1": "Ethernet0/0",
"node_id2": nodes["created_nodes"][2]["node_id"], "port2": "Ethernet0/1"}
]
}))
# Step 4: Apply naming
name_tool = GNS3UpdateNodeNameTool()
names = name_tool._run(json.dumps({
"project_id": project_id,
"nodes": [
{"node_id": nodes["created_nodes"][0]["node_id"], "new_name": "R1"},
{"node_id": nodes["created_nodes"][1]["node_id"], "new_name": "R2"},
{"node_id": nodes["created_nodes"][2]["node_id"], "new_name": "SW1"}
]
}))
# Step 5: Start nodes
start_tool = GNS3StartNodeTool()
start_result = start_tool._run(json.dumps({
"project_id": project_id,
"node_ids": [n["node_id"] for n in nodes["created_nodes"]]
}))
Error Handling
All tools include comprehensive error handling:
Missing Required Fields
{
"error": "Missing required fields: project_id and node_ids."
}
Invalid Input Type
{
"error": "node_ids must be a list."
}
Node Not Found
{
"node_id": "uuid",
"name": "N/A",
"status": "error",
"error": "Node not found"
}
Connection Error
{
"error": "Failed to connect to GNS3 server. Please check your configuration."
}
Security Considerations
Access Control
- All tools respect GNS3's built-in access control
- Requires valid GNS3 server authentication
- Project-level permissions apply
Audit Logging
All operations are logged:
logger.info("Starting %d nodes in project %s...", len(node_ids), project_id)
logger.info("Creating %d nodes in project %s...", len(nodes), project_id)
logger.info("Creating %d links in project %s...", len(links), project_id)
logger.info("Updating names for %d nodes in project %s...", len(nodes), project_id)
logger.info("Stop command sent for node %s (%s)", node_id, node.name)
logger.info("Suspend command sent for node %s (%s)", node_id, node.name)
Mode-Based Restrictions
-
Teaching Assistant Mode:
- Can create topology (templates, nodes, links, names)
- Can start nodes for diagnostics
- Cannot stop, suspend (prevents disruption of active labs)
-
Lab Automation Assistant Mode:
- Can create and manage full topology
- Can start, stop, and suspend nodes (full lifecycle control)
- Complete lab management including state preservation
Performance Characteristics
| Operation | Typical Duration | Wait Time | Progress | State Preserved |
|---|---|---|---|---|
| Get Templates | < 2s | 0s | No | N/A |
| Create Node | < 1s per node | 0s | No | N/A |
| Create Link | < 1s per link | 0s | No | N/A |
| Update Name | < 1s per node | 0s | No | N/A |
| Start | 60-180s | ~140s base | Yes | N/A |
| Stop | < 5s | 0s | No | ❌ No |
| Suspend | < 10s | 0s | No | ✅ Yes |
Notes:
- Stop operations are significantly faster than start operations
- Suspend is slightly slower than stop but preserves state
- Stop/Suspend do not require progress tracking (immediate feedback)
- Start duration depends on node type (router, switch, PC, etc.)
- Suspend provides fast resume capability compared to full start
- Create node/link operations are fast and require no waiting
- Template retrieval is instant with no parameters needed
Future Enhancements
Planned Features
- Quick Start Tool: Start nodes without waiting for completion (for CI/CD)
- Delete Node Tool: Remove nodes from topology
- Delete Link Tool: Remove links from topology
- Resume Tool: Explicit resume operation for suspended nodes
- Restart Tool: Combined stop + start operation
- Bulk Status Check: Query multiple nodes without stopping
- Conditional Stop/Suspend: Operate only if node is in specific state
- Graceful Shutdown: Send halt commands before stopping
Potential Improvements
- Auto-layout calculation (optimal node positioning)
- Progress tracking for long suspend operations (rare but possible)
- Concurrent create/link operations (parallel API calls)
- Suspend node groups by name pattern
- Dependency-aware suspend (suspend in dependency order)
- Auto-suspend after idle timeout
- State snapshots (save multiple suspend states)
Related Documentation
- Chat API - Session management and SSE
- Command Security - Security framework
- LLM Model Configs - Model configuration
Implementation Date: 2026-03-12
Status: ✅ Implemented - Topology management tools available in both modes. Full lifecycle management (start/stop/suspend) available in Lab Automation Assistant Mode