Documentation
Everything you need to install the server, connect your MCP client, and deploy your first topology.
Required runtime. Check with python --version
Python package manager for installation
To clone the repository
Required only for live deploy — not for planning or generation
git clone https://github.com/Mats2208/MCP-Packet-Tracer.git cd MCP-Packet-Tracer
pip install -e .
This installs all dependencies defined in pyproject.toml.
python -m pytest tests/ -v
All 34 tests should pass.
$ python -m src.packet_tracer_mcp INFO Packet Tracer MCP v0.4.0 INFO Transport: streamable-http INFO Listening on http://127.0.0.1:39000/mcp
The server starts on port 39000 using streamable HTTP transport.
For legacy stdio mode, use --stdio flag.
# Alternative: stdio mode for debugging python -m src.packet_tracer_mcp --stdio
Add to .vscode/mcp.json:
{
"servers": {
"packet-tracer": {
"url": "http://127.0.0.1:39000/mcp"
}
}
} Add to claude_desktop_config.json:
{
"mcpServers": {
"packet-tracer": {
"url": "http://127.0.0.1:39000/mcp"
}
}
} http://127.0.0.1:39000/mcp using
streamable HTTP transport. The server exposes 22 tools and 5 resources that any
MCP-compatible client can discover automatically. Once connected, ask your AI agent to build a topology. You can also call tools directly:
pt_full_build( routers=2, pcs_per_lan=2, dhcp=True, routing="ospf", has_wan=True ) # Returns: plan + script + configs + explanation
# 1. Generate plan plan = pt_plan_topology(routers=2, pcs_per_lan=2, routing="static") # 2. Validate pt_validate_plan(plan) # 3. Auto-fix if needed pt_fix_plan(plan) # 4. Generate artifacts pt_generate_script(plan) # PTBuilder JavaScript pt_generate_configs(plan) # IOS CLI configs # 5. Get explanation pt_explain_plan(plan) # Natural language summary
# Save everything to a directory pt_export(plan, path="./my_lab/")
Create a new or open an existing workspace.
Open the Builder Code Editor inside Packet Tracer, paste this script, and click Run:
window.webview.evaluateJavaScriptAsync("setInterval(function(){var x=new XMLHttpRequest();x.open('GET','http://127.0.0.1:54321/next',true);x.onload=function(){if(x.status===200&&x.responseText){$se('runCode',x.responseText)}};x.onerror=function(){};x.send()},500)"); # Check bridge connection pt_bridge_status() # Deploy a plan in real-time pt_live_deploy(plan)
Devices will appear in Packet Tracer within seconds. Links and configurations are applied automatically.
Save and load topologies for later reuse.
# List saved projects
pt_list_projects()
# Load a previously saved project
pt_load_project("my_lab")
# Export creates a project automatically
pt_export(plan, path="./my_lab/") Check Python version: python --version (needs 3.11+). Ensure all dependencies installed: pip install -e .
Verify the server is running on http://127.0.0.1:39000/mcp. Check no firewall is blocking port 39000.
Ensure the bootstrap script is running in Packet Tracer. Check that port 54321 is not in use by another process. The bootstrap only needs to be pasted once per PT session.
Run pt_fix_plan(plan) to auto-correct common issues (wrong cables, model limitations, port conflicts). If errors persist, check the error codes for specific guidance.
NAT, ACL, VLAN, and STP are not yet supported. RIP and EIGRP are available via enum but are not as mature as static and OSPF routing.
The full source code, tests, and WIKI are in the repository.
View Full Repository