Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Mats2208/MCP-Packet-Tracer/llms.txt
Use this file to discover all available pages before exploring further.
pt_generate_script turns a validated TopologyPlan (the JSON output of pt_plan_topology) into a ready-to-run JavaScript file for Cisco Packet Tracer’s PTBuilder Script Engine. The script places every device on the logical canvas, installs expansion modules, draws cables between interfaces, and — when include_configs is true — embeds the full IOS CLI configuration as /* */ block comments so you can review everything in one file before running it.
Parameters
The
TopologyPlan JSON produced by pt_plan_topology or pt_full_build. Must contain a non-empty devices array.When
true, calls generate_full_script internally: the returned script appends all IOS CLI config blocks as /* --- DeviceName --- ... */ block comments after the structural calls. When false, calls generate_ptbuilder_script and returns only the lwAddDevice / addModule / lwAddLink lines with no configuration content.Return value
A JavaScript string ready to paste into Packet Tracer via Extensions → Scripting, or to send directly to a running Packet Tracer instance via
pt_live_deploy. Each PTBuilder function call occupies its own line.Script structure
The generator follows a strict three-phase ordering that PTBuilder’s Script Engine requires: devices must exist before modules can be installed, and modules must be installed before any link can reference the ports they add.The script uses
lwAddDevice and lwAddLink — logical-workspace helpers injected by the runtime patches — rather than the raw addDevice / addLink globals. The helpers write directly to the logical canvas so devices and cables appear immediately without requiring a save-and-reload cycle in Packet Tracer. Cable types are passed as numeric PT IPC enum values (e.g. 8100 for straight-through, 8107 for auto-detect) rather than string names.Example script excerpt
The following excerpt shows what a two-device topology looks like after generation. Wheninclude_configs=true, CLI content appears as block comments at the end. When pt_live_deploy runs, it uses generate_executable_script internally, which replaces those comments with live configureIosDevice and configurePcIp calls.
Execution order requirement
PTBuilder’s Script Engine is sequential and stateful. CallinglwAddLink before both endpoint devices exist raises a runtime error. The generator enforces the required order automatically:
lwAddDevice— creates the device on the logical canvasaddModule— installs expansion modules (e.g.HWIC-2Tfor serial ports); must run after the device is placed and before any link references module-added portslwAddLink— connects two interface ports with the specified cable type
Relationship to pt_live_deploy
pt_generate_script only produces the script string — it does not send anything to Packet Tracer. When you call pt_live_deploy, the server internally calls generate_executable_script (which combines structural calls with live configureIosDevice / configurePcIp calls instead of comments) and streams each line to the HTTP bridge on port 54321, where PTBuilder picks it up every 500 ms and executes it in the Script Engine.
Use pt_generate_script when you want to inspect or manually paste the script. Use pt_live_deploy when you want fully automated, real-time deployment into a running Packet Tracer instance.