Skip to main content
Glama

ptlab

Headless Cisco Packet Tracer labs from Python (or MCP). Write .pkt / graded .pka without Packet Tracer running. Target: PT 9.x, CCNA switching + routing.

tests

This is not a live PT driver. Mats2208/MCP-Packet-Tracer talks to a running instance over a Lua .pts bridge. ptlab is the opposite: codec first, files on disk, live deploy later (docs/PHASE2.md).

What works today

Layer

Status

Container (Twofish-EAX + XOR + zlib)

GUI-valid on PT 9.0.0 — docs/FORMAT.md

Donor mutation (clone, check)

Opens in PT; structural refs are unit-tested

From-scratch skinny XML

Silent drop — blank untitled workspace

Title-bar load gate (gui-gate)

Fast; false-positive on broken cables

Structural gate (check)

Catches stale / dangling / colliding DEV_ADDR

Simulation ping (ping-gate)

Needs a one-time IPC ExApp registration

Activity Wizard .pka scoring in PT

Not verified yet

Phase 2 live bridge

Not built

GUI-openable files are template-backed: harvest a real device tree from local saves/, mint new MAC/DEV_ADDR, rewrite cables. Do not trust a file that only round-trips through this library.

CCNA wedge (not full PT coverage): PC-PT, Server-PT, 1841, 2960-24TT, plus 2950-24. Hold 2911 until a second independent export is diffed.

Related MCP server: packet-tracer-mcp

Install

Python 3.11+:

pip install -e ".[dev]"
python -m pytest

Packet Tracer is optional for codec tests. The load / ping gates need Windows + PT 9.

Two ways to write a file

Donor-backed (opens in PT). Clone from a harvested tree, then gate it:

ptlab harvest --limit 25
ptlab clone donor.xml lab.pkt \
  --from-device PC0 --name LabPC2 \
  --peer Switch0 --peer-port FastEthernet0/4 \
  --keep PC0,Switch0 \
  --ip 192.168.1.50 --subnet 255.255.255.0 --gateway 192.168.1.1
ptlab check lab.pkt
ptlab gui-gate lab.pkt

Object graph (library / MCP). Good for configs, inspect, and Activity Wizard XML. The .pkt it emits is a valid container, not a GUI-valid hardware dump:

from ptlab import create_topology, generate_graded_activity, write_pkt

topo = create_topology(
    devices=[
        {"id": "R1", "kind": "router"},
        {"id": "R2", "kind": "router"},
    ],
    links=[{"a": "R1", "a_port": "GigabitEthernet0/0", "b": "R2", "b_port": "GigabitEthernet0/0"}],
)
topo.set_config("R1", """
hostname R1
interface GigabitEthernet0/0
 ip address 10.0.0.1 255.255.255.252
 no shutdown
router ospf 1
 network 10.0.0.0 0.0.0.3 area 0
""")
topo.set_config("R2", """
hostname R2
interface GigabitEthernet0/0
 ip address 10.0.0.2 255.255.255.252
 no shutdown
router ospf 1
 network 10.0.0.0 0.0.0.3 area 0
""")
write_pkt(topo, "lab.pkt")
generate_graded_activity(topo, output_path="lab.pka")

examples/two_router_ospf.py is this path end-to-end.

Correctness gates

PT 9 does not error on bad XML. It opens a blank untitled workspace. A file that loads can still have a cable attached to the wrong device — or to nothing.

Tier

Command

Proves

Cost

1 load

ptlab gui-gate lab.pkt

Title bar is Cisco Packet Tracer - <path>

~11s

1b structure

ptlab check lab.pkt

Unique DEV_ADDR; cable mem-addrs match FROM/TO

instant

2 ping

ptlab ping-gate lab.pkt --from-device LabPC2 --to-device PC0

ICMP through the clone (LabPC2 → PC0, not the switch)

PT + IPC

Register extras/ptlab_exapp.xml once: Extensions → IPC → Configure Apps → Add. Until then ping-gate reports load_ok: true, ipc_ok: false.

Do not mint multi-device labs for students until tier 2 is green.

CLI

ptlab decode lab.pkt lab.xml
ptlab encode lab.xml lab.pkt
ptlab inspect lab.pka
ptlab harvest --limit 25
ptlab clone donor.xml lab.pkt --from-device PC0 --name LabPC2 --peer Switch0 --peer-port FastEthernet0/4
ptlab check lab.pkt
ptlab gui-gate lab.pkt
ptlab ping-gate lab.pkt --from-device LabPC2 --to-device PC0

MCP

{
  "mcpServers": {
    "ptlab": {
      "command": "python",
      "args": ["-m", "ptlab_mcp"]
    }
  }
}

Tool

Purpose

create_topology

In-memory devices + links

set_device_config

IOS-style config on a device

generate_pkt

Twofish-encrypted .pkt

generate_graded_activity

.pka with COMPARISONS scoring

inspect_pkt

Parse an existing file to a summary

validate_current_topology

Duplicate IPs, OSPF area clashes, DHCP overlap

These tools write the object-graph serializer. GUI-openable topologies go through ptlab clone, not generate_pkt.

Docs

Note

Contents

docs/FORMAT.md

Container pipeline, GUI experiments, gates, .pka layout

docs/SCHEMA.md

Python topology model

docs/PHASE2.md

Live deploy — blocked until Phase 1 ping + templates

License

MIT. Packet Tracer is a Cisco product; this repo is an independent interoperability tool, not affiliated with Cisco. Container format: Mirco De Zorzi (pka2xml) and jeamxn/cisco-pka-to-xml.

Available Tools

6 tools
create_topologyB

Build an in-memory Packet Tracer topology from devices and links.

Each device needs id (or name), kind (router|switch|pc|server|laptop), and optionally model, interfaces, coordinates, and config. Each link needs a_device, a_port, b_device, b_port, optional cable.

ParametersJSON Schema
NameRequiredDescriptionDefault
nameNoUntitled
linksNo
devicesYes
instructionsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It discloses that the topology is built 'in-memory,' but does not mention side effects, whether existing topologies are replaced, validation behavior, or what the tool returns. This is a meaningful gap for a creation tool with no annotation safety hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded: the main purpose appears in the first sentence, followed by concise structured field guidance for devices and links. Every sentence contributes necessary information with no fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description adequately covers the main input structure and even provides an enum for device kinds, which is helpful given the sparse schema. However, it omits usage guidance, behavior details, and semantics of 'name' and 'instructions'. The output schema reduces the need to explain return values, but the missing pieces still leave the description only partially complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds valuable structure for the two core parameters: devices require id/name and kind with an enum, and links require endpoint fields. However, the 'name' and 'instructions' parameters are left completely unexplained, leaving part of the input surface undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Build') and resource ('in-memory Packet Tracer topology from devices and links'), making the core purpose obvious. It does not explicitly name or distinguish itself from sibling tools, though 'in-memory' hints at a contrast with generate_pkt. This falls just short of full sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given about when to use this tool instead of alternatives such as validate_current_topology, generate_pkt, or set_device_config. The description implies its use case but provides no exclusions, prerequisites, or comparative context. An agent gets no help choosing between this and related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_graded_activityC

Serialize a .pka activity with scored IP addressing and routing criteria.

ParametersJSON Schema
NameRequiredDescriptionDefault
objectivesNo
output_pathYes
topology_idNo
instructionsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

C2.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It implies file output via 'Serialize' but does not state whether output_path is overwritten, whether a topology must already exist, what happens with optional parameters, or what is returned. This is a meaningful gap for a generation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no filler words. It is concise, though the brevity contributes to under-specification elsewhere.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with four parameters, one required, and no annotations, the description is too thin. It provides a high-level output statement but omits parameter roles, prerequisites, error behavior, and relationship to the sibling topology tools, leaving the agent under-equipped to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description does not compensate by defining output_path, objectives, topology_id, or instructions. None of the four parameters receive any added meaning beyond their titles, so the agent cannot reliably construct arguments.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb (Serialize) and names the resource (.pka activity) plus the distinguishing content (scored IP addressing and routing criteria), so an agent can tell it apart from siblings like generate_pkt or set_device_config. It stops short of 5 because it does not clarify what 'scored' means or mention the output path, but the core purpose is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to call this tool instead of validate_current_topology, create_topology, generate_pkt, or inspect_pkt. No alternatives, prerequisites, or exclusions are mentioned, so the agent must infer usage from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_pktB

Serialize the in-memory topology to a Twofish-encrypted .pkt file.

ParametersJSON Schema
NameRequiredDescriptionDefault
output_pathYes
topology_idNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It does reveal that output is Twofish-encrypted and that serialization targets a .pkt file, which is useful. However, it does not mention whether an existing file is overwritten, whether a topology must already be loaded, or any other side effects or requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no filler. Every word contributes meaning, and it is appropriately sized for the limited content it conveys.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is too thin for a tool with two parameters, no annotations, and no parameter descriptions. The optional topology_id is particularly unexplained: the description says 'the in-memory topology,' which may conflict with the existence of a topology_id parameter. The output schema covers return values, but the tool's invocation context and parameter semantics remain unclear.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description makes no mention of output_path or topology_id. The schema only provides names and types, so the agent cannot determine what output_path should be or what topology_id controls. The description adds no parameter-level meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action ('Serialize'), a specific resource ('the in-memory topology'), and a specific output format ('.pkt file'). It clearly differentiates from siblings like inspect_pkt (which inspects .pkt files) and create_topology (which builds the topology rather than serializing it).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given about when to use this tool versus alternatives such as validate_current_topology or inspect_pkt. There are no exclusions, prerequisites, or contextual conditions stated. The agent is left to infer that this is for saving the current topology.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

inspect_pktA

Parse an existing .pkt or .pka file into a readable summary (offline).

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must carry the transparency burden. It usefully conveys that the operation is offline and expects an existing file, implying read-only inspection. However, it does not explicitly state that the file is not modified, what the summary contains, or how failures are handled.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, tightly written sentence with no filler. The core action, input, and result are all front-loaded and clearly stated.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a one-parameter inspection tool with an output schema available, the description is nearly complete: it identifies the input type, the operation, the offline nature, and the kind of output. It lacks explicit usage guidance and a non-mutation guarantee, but the simple scope keeps the gap small.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema's only parameter, 'path', has 0% description coverage, so the description must compensate. It does so by specifying that the path must point to an existing .pkt or .pka file, adding meaningful constraints beyond the bare parameter name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Parse') and names the exact resource ('existing .pkt or .pka file') and the result ('readable summary'). The 'offline' qualifier helps distinguish it from generation-oriented siblings like generate_pkt.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given about when to use inspect_pkt versus sibling tools such as generate_pkt or validate_current_topology. It states the tool's capability but not the conditions that should lead an agent to select it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

set_device_configB

Push an IOS-style config onto a device in the in-memory topology.

ParametersJSON Schema
NameRequiredDescriptionDefault
configYes
device_idYes
topology_idNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the full behavioral burden. It states the action but does not disclose whether the config replaces or merges existing config, whether the device must already exist, what happens on invalid config, or whether changes are ephemeral beyond the 'in-memory' hint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no filler. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Even with an output schema present, an agent still lacks critical information about parameter semantics, side effects, and preconditions for this mutation tool. The description is too thin to support confident invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, but it does not. 'Device' and 'IOS-style config' loosely map to device_id and config, but topology_id is completely unexplained, and the required vs optional nature of parameters is not addressed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Push') and clearly identifies the resource (a device in the in-memory topology) and the payload (IOS-style config). This distinguishes it well from sibling tools such as validate_current_topology or create_topology.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. There are no stated prerequisites, no when-not-to-use conditions, and no mention of alternatives. The only contextual hint is 'in-memory topology.'

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

validate_current_topologyA

Run offline validation: duplicate IPs, OSPF area mismatches, DHCP overlap.

ParametersJSON Schema
NameRequiredDescriptionDefault
topology_idNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The word 'offline' adds a behavioral trait, and listing the checks tells the agent what validation is performed. With no annotations provided, the description carries the full burden, but it does not explicitly confirm that the tool is read-only or describe behavior when topology_id is null.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single efficient sentence that front-loads the action and gives concrete validation categories without filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple and has an output schema, so return-value documentation is not required from the description. However, the description omits the role of topology_id and any prerequisites, leaving minor but real gaps for an agent deciding how to invoke it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% and the description never mentions the only parameter, topology_id. The parameter name is somewhat self-explanatory and optional, but the description does not clarify whether it selects a topology or what the null default means.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Run offline validation') and names concrete validation categories (duplicate IPs, OSPF area mismatches, DHCP overlap). This clearly distinguishes it from sibling tools like create_topology, set_device_config, or inspect_pkt.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The intended use is implied by the description: call this tool to validate a topology offline. However, it does not explicitly state when to prefer it over alternatives such as inspect_pkt, nor does it mention prerequisites like having a topology already created.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 6 tool updatesv0.1.0
    • First observedcreate_topology
    • First observedgenerate_graded_activity
    • First observedgenerate_pkt
    • First observedinspect_pkt
    • First observedset_device_config
    • First observedvalidate_current_topology

TDQS

A3.5/5.0

Scored across 6 tools

Disambiguation5/5

Each tool targets a distinct operation: validation, activity generation, topology creation, configuration, serialization, and parsing. No overlapping purposes; even the two generate tools differ in output format (.pka vs .pkt).

Naming Consistency5/5

All tools follow a consistent snake_case verb_noun pattern (validate_current_topology, generate_graded_activity, create_topology, etc.). The naming is predictable and readable.

Tool Count5/5

Six tools is well-scoped for a Packet Tracer topology server, covering creation, validation, configuration, export, and inspection without redundancy or bloat.

Completeness4/5

Core workflows are covered: create, validate, configure, export, and inspect. Minor gaps like explicitly listing devices or removing devices/links exist, but agents can work around them through create and set operations.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers