pt_run_js
Run JavaScript inside Packet Tracer's script engine to query network, window, or simulation state and return JSON results. Use it as an escape hatch for tasks the standard tools don't cover.
Instructions
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();
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "pt_run_js"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout | No |