MCP-Packet-Tracer
AGENTS.md234 starsChanged 4 months agoMITView on GitHub
Notes for coding agents working in this repo. Read this before changing anything under src/. An MCP server that automates Cisco Packet Tracer. It plans network topologies, validates them, generates JavaScript for PT's script engine and IOS CLI config for the devices, and can push all of it into a running copy of Packet Tracer over a local HTTP bridge. There is no linter or formatter configured. Match the surrounding style: type hints on public functions, from __future__ import annotations…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- docsSkill
- packet-tracerSkill
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 41
Never build JavaScript with raw f-strings: Use json.dumps for each field.
- Very specific: line 44
Never build a path by concatenation: Use safe_name_component() then resolve_within() from shared/utils.py.
- Distinctive: line 52
A bug fix needs a test that fails without it: Write the failing test first.
- Very specific: line 54
Never guess a PT API signature: If a method isn't already used somewhere in this repo, confirm it against Cisco's reference before writing …
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Notes for coding agents working in this repo. Read this before changing anything
under src/.
What this is
An MCP server that automates Cisco Packet Tracer. It plans network topologies, validates them, generates JavaScript for PT's script engine and IOS CLI config for the devices, and can push all of it into a running copy of Packet Tracer over a local HTTP bridge.
Build and test
pip install -e ".[test]"
python -m pytest # from the repo root, no PT requiredThere is no linter or formatter configured. Match the surrounding style: type
hints on public functions, from __future__ import annotations at the top,
comments in Spanish or English following whatever the file already uses.
Layout
| Path | What lives there |
src/packet_tracer_mcp/domain/ | Pydantic models, validation rules, planning services |
src/packet_tracer_mcp/application/ | Use cases: rules + generators, dependencies injected |
src/packet_tracer_mcp/infrastructure/ | Generators, executors, the HTTP + file bridges, device catalog |
src/packet_tracer_mcp/adapters/mcp/ | tool_registry.py — the 61 MCP tools |
EXTENSION/script-engine/ | Script-engine side of the extension. main.js is ours (tracked); the rest are PTBuilder reference copies (gitignored) |
EXTENSION/webview/ | The MCP Control Center webview (index.html + interface.js) |
tool_registry.py is ~3000 lines and every tool is a closure inside
register_tools(). That means helpers defined there cannot be imported by
tests. If you write a helper worth testing, put it in shared/utils.py.
Rules that are not negotiable
- Never build JavaScript with raw f-strings. Use
json.dumpsfor each field. PT runs it throughnew Function(), so an unescaped device name is arbitrary code execution.ptbuilder_generator.pyshows the correct pattern. - Never build a path by concatenation. Use
safe_name_component()thenresolve_within()fromshared/utils.py. - Never add an unauthenticated bridge endpoint. Everything except
/pingrequires the token; seebridge_token.pyfor why loopback alone is not a control. (The file-bridge channel needs no token — the mailbox lives under a user-ACL'd%LOCALAPPDATA%dir a browser page can't reach.) - Don't validate in the models. Validation belongs in
domain/rules/and returnsValidationResult, so the use case decides whether to proceed. - A bug fix needs a test that fails without it. Write the failing test first; if it passes before your change, it isn't testing the bug.
- Never guess a PT API signature. If a method isn't already used somewhere
in this repo, confirm it against Cisco's reference before writing code on top
of it — PT answers a wrong call with a bare
Invalid arguments for IPC call "X", so a guess fails without telling you why.
Working with the bridge
The bridge only really works with Packet Tracer open, so most verification is
offline. tests/test_bridge_security.py drives a real PTCommandBridge on an
ephemeral port — follow that pattern rather than mocking HTTP.
Set PT_MCP_BRIDGE_TOKEN to avoid touching the user's real token file.
Anything involving PT's webview (CORS behaviour, the this-sm: origin, whether
the script engine can reach an API) cannot be verified from tests. Say so
explicitly instead of assuming; don't claim a change is verified when only the
offline half was.
Gotchas
- PT's
executeCode()strips newlines from source that is pasted into the Builder Code Editor, so any such snippet must be a single line without//comments. (The compiled.ptsfiles —main.jsetc. — are not pasted and can be normal multi-line JS.) - An uncaught error inside
runCodeopens a modal that freezes the webview and kills the polling loop. That is why fire-and-forget commands are wrapped intry{...}catch{}. %LOCALAPPDATA%, not%APPDATA%, for machine-local secrets — the latter roams.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

