Skip to main content
Glama
README.md
# switch-console-mcp

A small local [MCP](https://modelcontextprotocol.io) server that lets Claude (desktop app)
send CLI commands to a network switch over its **serial console** (USB/RS-232, e.g. `COM5`).

Tested with a **Hirschmann GRS105 (HiOS-2A-10.3.03)** on 9600-8-N-1, no flow control.
It should work with most switches that use a plain text CLI over a console port.

## Tools

| Tool | What it does |
|---|---|
| `console_status` | Presses Enter on the console and returns what the switch shows (prompt / login banner). |
| `run_commands` | Logs in if the switch asks (credentials from env vars), sends a list of CLI commands in order, and returns the full console output. Handles `--More--` paging. |

All console output is also appended to `switch_console_log.txt` next to the script.

## Requirements

- Windows / Linux / macOS with Python 3.10+
- A console cable to the switch
- Claude desktop app

```
pip install -r requirements.txt
```

Works with both `mcp` 1.x (`FastMCP`) and 2.x (`MCPServer`).

## Setup

1. Copy `switch_console_mcp.py` somewhere on the machine that has the console cable.
2. Add the server to your Claude desktop config
   (Windows: `%APPDATA%\Claude\claude_desktop_config.json`).
   See `claude_desktop_config.example.json` — add the `"mcpServers"` section as a
   **top-level key** next to any existing settings.
3. Set the environment variables:

   | Variable | Default | Meaning |
   |---|---|---|
   | `SWITCH_PORT` | `COM5` | Serial port (`COM5`, `/dev/ttyUSB0`, …) |
   | `SWITCH_BAUD` | `9600` | Baud rate |
   | `SWITCH_USER` | *(empty)* | Login username |
   | `SWITCH_PASS` | *(empty)* | Login password |
   | `SWITCH_LOG` | `switch_console_log.txt` | Output log path |

4. Fully restart the Claude desktop app.
5. Close PuTTY / plink — only one program can hold the COM port at a time.

## Example

Ask Claude: *"Set the description SPARE on ports 1/1 to 1/7 and save."*
Claude calls `run_commands` with:

```
enable
configure
interface 1/1
name SPARE
exit
...
exit
copy config running-config nvm
show port all
```

## Security notes

- The password sits in **plain text** in the Claude desktop config. Use this on lab / test
  equipment, or use a dedicated low-privilege account.
- Claude never sees the password — the server sends it to the switch itself.
- This server gives Claude **full CLI access** to whatever is on the other end of the cable.
  Do not leave it connected to production equipment unattended.
- Never commit your real `claude_desktop_config.json` (it is in `.gitignore`).

## License

MIT