tracerlab
v0.1.6Build and verify Cisco Packet Tracer networks from an AI agent.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
pt_status
Bridge + Packet Tracer status: connection, PT version, open file, device/link counts.
pt_setup_instructions
How to install the one-time PT-side bridge module (needed if pt_status says NOT CONNECTED).
pt_topology
Whole canvas, compact: every device (model, position, power) with its addressed/cabled interfaces, peers and link state. detail=true adds MACs, switchport modes, descriptions and unused ports.
| Parameter | Type | Description |
|---|---|---|
detail | boolean |
pt_device
One device in depth: all physical ports (IP, peer, state, switchport mode), free ports, module slots.
| Parameter | Type | Description |
|---|---|---|
name * | string |
pt_running_config
Running (or startup) config of an IOS device, read from the device model (fast, no paging). section: only blocks whose header contains this text, e.g. 'interface', 'router ospf', 'line vty'.
| Parameter | Type | Description |
|---|---|---|
device * | string | |
section | ||
startup | boolean |
pt_show
Run show/exec commands (privileged EXEC) on a router/switch and return their output. commands: one or more, e.g. ['show ip interface brief', 'show ip route']. grep: optional regex; keep only matching lines (like '| include').
| Parameter | Type | Description |
|---|---|---|
commands * | ||
device * | string | |
grep |
pt_command_log
Recent commands typed into any device CLI (PT's command log), oldest first.
| Parameter | Type | Description |
|---|---|---|
device | ||
limit | integer |
pt_screenshot
Image of the logical workspace (the topology as drawn in PT).
| Parameter | Type | Description |
|---|---|---|
fmt | string |
pt_add_devices
Add devices. devices: [{name, model, x?, y?}], model like '2911', 'ISR4331', '2960-24TT', '3560-24PS', 'PC-PT', 'Laptop-PT', 'Server-PT' (see pt_catalog). Missing x/y are laid out automatically. Routers/switches have their boot skipped so they are ready immediately.
| Parameter | Type | Description |
|---|---|---|
devices * | array |
pt_connect
Cable devices. links: [{a, b, a_port?, b_port?, cable?}]. Ports are optional: the first free port of the right media is chosen (fastest first; on switches use a_pref/b_pref='access' to keep gigabit uplinks free). cable: auto (default) | straight | cross | serial | fiber | console | coaxial | phone. For serial links the device needs a serial module (pt_add_module).
| Parameter | Type | Description |
|---|---|---|
links * | array |
pt_disconnect
Remove cables by endpoint: ['R1:GigabitEthernet0/0', 'S1:FastEthernet0/3'].
| Parameter | Type | Description |
|---|---|---|
ports * | array |
pt_delete_devices
Delete devices (and their cables).
| Parameter | Type | Description |
|---|---|---|
names * | array |
pt_clear_canvas
Delete EVERY device on the canvas. Requires confirm=true.
| Parameter | Type | Description |
|---|---|---|
confirm | boolean |
pt_update_device
Rename, move and/or power a device on/off.
| Parameter | Type | Description |
|---|---|---|
name * | string | |
new_name | ||
power | ||
x | ||
y |
pt_add_module
Insert a module (device is power-cycled automatically). Common: HWIC-2T (2 serial, 1941/2901/2911), WIC-2T (1841/2811), NIM-2T (ISR4321/4331), HWIC-4ESW, NM-1FE-TX, PT-ROUTER-NM-1S (Router-PT), AC-POWER-SUPPLY (3650). slot omitted = first slot that accepts it. Returns the device's ports afterwards.
| Parameter | Type | Description |
|---|---|---|
device * | string | |
module * | string | |
slot |
pt_device_modules
Module slot tree of a device: slot path, slot type and installed module.
| Parameter | Type | Description |
|---|---|---|
device * | string |
pt_build
Build a whole network in one call. spec = { devices: [{name, model, x?, y?, modules?: [{module, slot?}]}], links: [{a, b, a_port?, b_port?, cable?}], # ports auto-picked when omitted configs: {device: ["ios line", ...]}, # global-config lines, applied + saved hosts: {pc: {ip, mask | cidr, gateway, dns} | {dhcp: true}}, auto: {routing: 'ospf'|'eigrp'|'rip'|'static'|'none', lan_pool, p2p_pool, dhcp, lan_prefix}, # optional checks: [[src, dst], ...] # ping pairs, run when verify=true } `aut…
| Parameter | Type | Description |
|---|---|---|
spec * | object | |
verify | boolean |
pt_lab
Build a complete, pre-computed lab (devices, cabling, IPs, configs, hosts, test pairs) in one call. name='list' shows blueprints and their params: small-office, router-on-a-stick, intervlan-l3, routing (ospf|eigrp|rip|static x chain|ring|star|mesh, optional serial), nat-internet, hsrp, etherchannel-stp, ipv6-dual-stack. verify=true pings the test pairs after convergence.
| Parameter | Type | Description |
|---|---|---|
clear_first | boolean | |
name | string | |
params | ||
verify | boolean |
pt_cli
Run IOS commands on a router/switch/ASA. mode=config: lines are entered from global config (sub-modes like 'interface g0/0' work, 'end' is added); the reply lists only failing lines. mode=exec: privileged EXEC, returns output (prefer pt_show). save=true appends 'write memory'.
| Parameter | Type | Description |
|---|---|---|
commands * | ||
device * | string | |
mode | string | |
save | boolean |
pt_configure_hosts
IP settings for PCs/laptops/servers/printers. hosts: [{name, ip, mask? | ip:'10.0.0.5/24' | cidr, gateway?, dns?, dhcp?: true, port?, ipv6?: '2001:db8::5/64', gw6?}].
| Parameter | Type | Description |
|---|---|---|
hosts * | array |
pt_apply_feature
Generate IOS config for a feature (see ios_features) and apply it to a device in one step. e.g. feature='ospf', params={'networks':['10.0.0.0/30','192.168.1.0/24'],'router_id':'1.1.1.1', 'passive':['GigabitEthernet0/0']}. dry_run=true returns the lines without applying.
| Parameter | Type | Description |
|---|---|---|
device * | string | |
feature * | string | |
params * | object | |
dry_run | boolean |
pt_auto_address
Address the live topology and generate routing, computed from the actual cabling: each L3 segment (router/host ports joined through switches) gets a subnet: LANs from lan_pool (/lan_prefix, or right-sized when null), router-only links get /30s from p2p_pool. Routers take the first host addresses (gateway), hosts .10+ (or DHCP pools on the router with dhcp=true). Existing addresses are kept unless overwrite=true. apply=false only shows the plan and configs.
| Parameter | Type | Description |
|---|---|---|
apply | boolean | |
dhcp | boolean | |
dns | ||
lan_pool | string | |
lan_prefix | ||
loopbacks | boolean | |
overwrite | boolean | |
p2p_pool | string | |
routing | string |
pt_save_configs
'write memory' on the given (default: all) routers/switches.
| Parameter | Type | Description |
|---|---|---|
devices |
pt_ping
Ping from devices and report OK/PARTIAL/FAIL per pair. pairs: [[src, dst], ...] where dst is a device name or IP. Sources can be PCs/servers (Command Prompt) or routers/switches (IOS ping). Pairs from different sources run in parallel. A first-ping loss is usually ARP warm-up: count>=2 hides it.
| Parameter | Type | Description |
|---|---|---|
pairs * | array | |
count | integer |
pt_ping_matrix
All-pairs reachability between end hosts (default: every PC/laptop/server, max 10) as a matrix.
| Parameter | Type | Description |
|---|---|---|
count | integer | |
hosts |
pt_traceroute
Traceroute (tracert on hosts) from a device to a device name or IP; returns the hop list.
| Parameter | Type | Description |
|---|---|---|
dst * | string | |
src * | string |
pt_diagnose
Find misconfigurations from the live state: duplicate IPs, mixed subnets on a segment, hosts without IP / wrong or missing gateway, cabled-but-down interfaces, powered-off devices, uncabled hosts. deep=true also reads every router's routing table and lists subnets each router cannot reach.
| Parameter | Type | Description |
|---|---|---|
deep | boolean |
pt_fast_forward
Fast-forward PT's realtime clock (speeds up STP, OSPF/EIGRP convergence, DHCP).
| Parameter | Type | Description |
|---|---|---|
times | integer |
pt_simulation
Simulation mode control. action: simulation|realtime (switch mode), pdu (simple ICMP PDU src->dst), forward/back (steps events), reset, frames (last events with status), status.
| Parameter | Type | Description |
|---|---|---|
action * | string | |
dst | ||
src | ||
steps | integer |
pt_file
Packet Tracer file operations on the open workspace: new, open <path>, save, save_as <path> (.pkt).
| Parameter | Type | Description |
|---|---|---|
action * | string | |
path |
pkt_inspect
Read a .pkt/.pka file WITHOUT Packet Tracer: devices, models, IPs, links, and (configs=true) every device's running-config. Good for grading or understanding a lab file.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
configs | boolean |
pkt_convert
Convert .pkt <-> .xml without Packet Tracer (decrypt to editable XML, or re-encrypt XML into a .pkt).
| Parameter | Type | Description |
|---|---|---|
dst * | string | |
src * | string |
pkt_export_configs
Write every device's running-config from a .pkt file to <out_dir>/<device>.txt.
| Parameter | Type | Description |
|---|---|---|
out_dir * | string | |
path * | string |
net_subnet
Subnet facts for an address/prefix: network, mask, wildcard, broadcast, host range, count, class.
| Parameter | Type | Description |
|---|---|---|
cidr * | string |
net_vlsm
VLSM plan: needs = {'Sales': 50, 'Eng': 25, 'R1-R2': 2}. Largest first; returns subnet, mask, wildcard, gateway (first host), host range and broadcast per segment.
| Parameter | Type | Description |
|---|---|---|
needs * | object | |
pool * | string |
net_summarize
Route summarization: exact collapsed set and the single covering supernet (+ how much extra it covers).
| Parameter | Type | Description |
|---|---|---|
networks * | array |
net_split
Split a block into `count` equal subnets or into /new_prefix subnets (first 64 shown).
| Parameter | Type | Description |
|---|---|---|
cidr * | string | |
count | ||
new_prefix |
ios_features
List IOS config generators and their parameters (used by ios_generate / pt_apply_feature).
ios_generate
Generate IOS config lines for a feature without applying them. See ios_features for names/params. e.g. ('dhcp_pool', {'name':'LAN','network':'192.168.1.0/24','dns':'8.8.8.8','exclude_first':10}).
| Parameter | Type | Description |
|---|---|---|
feature * | string | |
params * | object |
pt_catalog
Device models PT 9 offers (exact names for pt_add_devices) with ports, slots and usage notes. category: router | switch | l3-switch | host | firewall | ap | wireless-router ... modules=true lists modules.
| Parameter | Type | Description |
|---|---|---|
category | ||
modules | boolean |
pt_api_lookup
Search Packet Tracer's IPC/scripting API (6000+ methods, 374 classes) for use with pt_run_js. query: a class name ('TerminalLine'), a method fragment ('Vlan', 'ospf'), or 'Class.method'.
| Parameter | Type | Description |
|---|---|---|
query * | string | |
limit | integer |
pt_run_js
Escape hatch: run JavaScript inside PT's script engine and return the JSON result. The code is a function body: use `return`. Globals: ipc (IPC root: ipc.network(), ipc.appWindow(), ipc.simulation()), PTM (this server's helpers: PTM.dev(name), PTM.snapshot(), PTM.cli(name, lines, mode)...). Example: return ipc.network().getDevice('R1').getPort('GigabitEthernet0/0').getMacAddress();
| Parameter | Type | Description |
|---|---|---|
code * | string | |
timeout | number |