agentleFS
Mats2208Mats2208/MCP-Packet-Tracer/AGENTS.md

MCP-Packet-Tracer

AGENTS.md385 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. Write everything in the repo in English: code, comments, docstrings, tool descriptions, user-facing messages, tests, docs and commit messages. This…

  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,337 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.

The file

We split this AGENTS.md into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write everything in the repo in English: code, comments, docstrings, tool descriptions, user-facing messages, tests, docs and commit …

    line 15
  2. Very specific:

    Start at CODEMAP.md: which file owns what, and which file holds each tool.

    line 43
  3. Very specific:

    Never build JavaScript with raw f-strings: Use json.dumps for each field.

    line 57
  4. Very specific:

    Never build a path by concatenation: Use safe_name_component() then resolve_within() from shared/utils.py.

    line 60
  5. Distinctive:

    A bug fix needs a test that fails without it: Write the failing test first.

    line 68
  6. Very specific:

    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 …

    line 70

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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.

Language

Write everything in the repo in English: code, comments, docstrings, tool descriptions, user-facing messages, tests, docs and commit messages. This keeps the project usable by anyone, whatever their language. Talk to your user in their preferred language — only what you write into the repo is English.

Build and test

pip install -e ".[test]"
python -m pytest          # from the repo root, no PT required

There is no linter or formatter configured. Match the surrounding style: type hints on public functions, from __future__ import annotations at the top, comments in English (see Language above).

Layout

PathWhat 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/tools/<topic>.py — 94 of the 111 tools, one register(mcp, ctx) each, run by tool_registry.py; bridge_context.py — the shared BridgeContext; device_panel_tools.py + desktop_service_tools.py — the 17 device-panel tools; prompt_registry.py / resource_registry.py — prompts and resources (pt://guide)
src/packet_tracer_mcp/infrastructure/ui/UI mode: Win32 + UI Automation presenter that opens/captures device windows (Windows only, [ui] extra); wizard.py + macax.py drive the Activity Wizard on Windows and macOS
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)

Start at CODEMAP.md: which file owns what, and which file holds each tool. It is generated — rerun python -m src.packet_tracer_mcp.devtools.codemap after adding a module or tool (a test fails when it is stale).

Tools are closures inside each module's register(), so helpers defined there cannot be imported by tests: put a helper worth testing at module level or in shared/utils.py. Tool replies go through reply_json() (compact, drops JS once sent). Tests cap SERVER_INSTRUCTIONS at 2,000 chars (Claude Code cuts at 2,048) and tool descriptions at 1,500; longer notes go in settings.GUIDE, served as pt://guide. tests/fixtures/tool_api.json snapshots the tool API — regenerate with UPDATE_TOOL_API=1 only on purpose.

Rules that are not negotiable

  1. Never build JavaScript with raw f-strings. Use json.dumps for each field. PT runs it through new Function(), so an unescaped device name is arbitrary code execution. ptbuilder_generator.py shows the correct pattern.
  2. Never build a path by concatenation. Use safe_name_component() then resolve_within() from shared/utils.py.
  3. Never add an unauthenticated bridge endpoint. Everything except /ping requires the token; see bridge_token.py for 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.)
  4. Don't validate in the models. Validation belongs in domain/rules/ and returns ValidationResult, so the use case decides whether to proceed.
  5. 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.
  6. 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 .pts files — main.js etc. — are not pasted and can be normal multi-line JS.)
  • An uncaught error inside runCode opens a modal that freezes the webview and kills the polling loop. That is why fire-and-forget commands are wrapped in try{...}catch{}.
  • %LOCALAPPDATA%, not %APPDATA%, for machine-local secrets — the latter roams.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.