Switchcraft
Provides tools for managing OpenWrt switches over SSH, including VLAN and port configuration through UCI and DSA bridge-VLAN settings.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Switchcraft - MCP Network Switch Server
A Model Context Protocol (MCP) server for stable L2/L3 network switch configuration management with git-versioned desired state and hardware-in-the-loop testing.
Why This Exists
Managing a heterogeneous network with Brocade (telnet), Zyxel (HTTPS/SSH), and OpenWrt (SSH) switches is painful:
Unreliable communication - Brocade telnet is notoriously flaky
Inconsistent configs - Each vendor speaks a different language
No version control - Changes are made ad-hoc without history
Risky testing - No safe way to validate changes on real hardware
Switchcraft provides:
Stable connections with automatic retries and exponential backoff
Normalized configuration across all switch types
Git-versioned desired state with drift detection
HIL testing with server-enforced safety constraints
Unified API for Claude Code to manage your entire network
Related MCP server: network-device-assistant
Supported Devices
Device | Type | Protocol | Features |
Brocade FCX |
| Telnet | VLAN, port config, batch commands, retry logic |
Zyxel GS1900 |
| HTTPS | Web API, VLAN, port config |
Zyxel GS1900 |
| SSH | CLI interface (like Brocade), legacy SSH support |
OpenWrt |
| SSH | UCI config, DSA bridge-vlan |
Quick Start
# Clone and setup
cd /home/emesix/git/switchcraft
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
# Configure credentials
cp .env.example .env
# Edit .env with your NETWORK_PASSWORD
# Run tests
make test
# Start MCP server
make serverConfiguration
1. Environment Variables
# Required
export NETWORK_PASSWORD="your_switch_password"
# Optional
export SWITCHCRAFT_LOG_LEVEL=INFO
export SWITCHCRAFT_LOG_FILE=~/.switchcraft/switchcraft.log2. Device Inventory
Edit configs/devices.yaml:
devices:
brocade-core:
type: brocade
host: 192.168.254.2
protocol: telnet
port: 23
username: admin
enable_password_required: true
zyxel-frontend:
type: zyxel-cli
host: 192.168.254.3
protocol: ssh
port: 22
username: admin3. Claude Code Integration
Add to ~/.config/claude-code/settings.json:
{
"mcpServers": {
"switchcraft": {
"command": "/path/to/switchcraft/.venv/bin/python",
"args": ["-m", "mcp_network_switch.server"],
"cwd": "/path/to/switchcraft",
"env": {
"NETWORK_PASSWORD": "your_password"
}
}
}
}Available Tools
Device Management
Tool | Description |
| List all configured network devices |
| Get health/status of a device |
Configuration Reading
Tool | Description |
| Get normalized config (VLANs, ports) |
| Get VLAN configurations |
| Get port configurations |
Configuration Writing
Tool | Description |
| Create/update a VLAN (supports dry_run) |
| Remove a VLAN (supports dry_run) |
| Configure a port |
| Save running config to startup |
Batch Operations
Tool | Description |
| Run raw command on device |
| Fast batch show commands (Brocade) |
| Fast batch config commands (Brocade) |
| Run command on multiple devices |
Configuration Management
Tool | Description |
| Save desired state to git-versioned store |
| Check drift between desired and actual |
| Apply desired state to device (with rollback) |
| Create named snapshot |
| Restore from snapshot |
| View git commit history |
| Rollback to previous version |
| Diff between revisions |
Fleet Management
Tool | Description |
| List device groups defined in inventory |
| List available configuration profiles |
| Create a reusable configuration profile |
| Apply profile to all devices in a group |
Audit
Tool | Description |
| View recent configuration changes |
Make Targets
make help # Show all targets
make test # Run unit tests (160 tests)
make lint # Run ruff linter
make server # Start MCP server
# HIL Testing (Hardware-in-the-Loop)
make hil # Run on ALL devices (192.168.254.2-4)
make hil-brocade # Test only Brocade
make hil-zyxel # Test only Zyxel
make hil-openwrt # Test only OpenWrt
make hil-report # View last HIL reportHIL Testing
HIL (Hardware-in-the-Loop) testing validates changes against real hardware with server-enforced safety:
Only VLAN 999 - Any other VLAN operation is rejected
Only designated ports - 23/24 on Brocade/Zyxel, lan7/8 on OpenWrt
Full lifecycle - Snapshot → Apply → Verify → Cleanup → Validate
Audit artifacts - Every run produces JSON evidence
# Run HIL tests (requires NETWORK_PASSWORD)
source .env
make hilSee docs/HIL-TESTING.md for full documentation.
Configuration Management
Switchcraft maintains git-versioned desired state for each device:
~/.switchcraft/configs/
├── .git/ # Git repository
├── desired/
│ ├── brocade-core.yaml # Desired state
│ ├── zyxel-frontend.yaml
│ └── onti-backend.yaml
├── last_known/ # Last observed state
└── snapshots/ # Named snapshotsDrift Detection
"Check if brocade-core matches desired state"
-> Uses config_status tool
-> Returns: IN_SYNC or DRIFT with differencesVersion History
"Show config history for brocade-core"
-> Uses config_history tool
-> Returns: Git commits with messages, timestamps, authorsArchitecture
switchcraft/
├── configs/
│ ├── devices.yaml # Production device inventory
│ └── devices.lab.yaml # HIL lab devices
├── src/mcp_network_switch/
│ ├── server.py # MCP server entry point
│ ├── devices/
│ │ ├── base.py # Abstract device class
│ │ ├── brocade.py # Brocade telnet handler
│ │ ├── openwrt.py # OpenWrt SSH handler
│ │ ├── zyxel.py # Zyxel HTTPS handler
│ │ └── zyxel_cli.py # Zyxel SSH CLI handler
│ ├── config_store/
│ │ ├── store.py # Git-versioned config store
│ │ └── git_manager.py # Git operations
│ ├── hil/
│ │ ├── mode.py # HIL mode enforcement
│ │ ├── constraints.py # Safety constraints
│ │ └── runner.py # Lifecycle test runner
│ └── utils/
│ ├── connection.py # Retry logic
│ └── logging_config.py
├── tests/
│ ├── hil_spec.yaml # HIL test specification
│ └── *.py # 133 unit tests
├── docs/
│ ├── HIL-TESTING.md # HIL documentation
│ └── *.md # Other docs
└── Makefile # Build targetsStability Features
Brocade (Telnet)
5 retry attempts with exponential backoff (2s → 15s)
Batch command execution (3-5x faster)
Proper
--More--pagination handlingAutomatic reconnection on failure
Zyxel (SSH CLI)
Legacy SSH algorithm support (OpenSSH 6.2)
Interactive shell with pagination handling
Smart error detection (ignores statistics)
OpenWrt (SSH)
UCI command interface
DSA bridge-vlan support
Port status from sysfs
Documentation
Document | Description |
Instructions for Claude Code | |
HIL testing guide | |
Command reference | |
Common issues | |
Version history |
Troubleshooting
"Connection refused" on Brocade
Ensure telnet is enabled on the switch
Check if another session is active (Brocade limits concurrent sessions)
The server will retry automatically
"HIL CONSTRAINT VIOLATION"
HIL mode only permits VLAN 999 operations
Check that you're using the correct device and ports
Device unreachable
Verify network connectivity:
ping 192.168.254.XCheck credentials in
.env
Development
# Run tests
make test
# Run with verbose output
pytest -v
# Lint
make lint
# Fix lint errors
make lint-fixLicense
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
AI network lab: build and validate real multi-vendor router and switch labs from a prompt.
Routed, editable network diagrams from CDP/LLDP output, CSV or Graphviz DOT, as draw.io files
Protocol-native energy infrastructure orchestration for AI data centers. Provides 46 MCP tools across 8 grid protocols (IEC-61850, DNP3, Modbus, OCPP, OpenADR, IEEE 2030.5, IEC 60870-5-104, ICCP) with 5 core API primitives: connect, dispatch, settle, comply, and intel. Enables AI agents to programmatically interact with substations, grid interfaces, and energy assets for real-time workload-grid coordination.
Hosted Notion MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables conversational automation of HPE Aruba Central network operations through Claude Code. Provides 88 tools across monitoring, configuration, and operations domains for device migration, SSID management, switch provisioning, and GreenLake Platform integration.162MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude Code to interact with network devices over serial and SSH with command safety classification and a persistent knowledge base.MIT
- FlicenseNot gradedqualityDmaintenanceEnables managing Nokia SR OS devices via NETCONF from Claude Desktop, supporting MD-CLI commands, configuration retrieval and editing, candidate workflow with commit/rollback, and multi-device sessions.1-
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to drive switches, servers, and consoles over SSH or serial Console through 28 MCP tools, auto-detecting vendors, paging through long output, and cleaning raw byte streams into readable text. Provides structured diagnostics (interfaces, ARP/MAC/routing tables, ping, logs, health checks) plus a three-tier safety model with audit logging, credential redaction, and dry-run config changes.MIT