Skip to main content
Glama
console-switch-mcp

console-switch-mcp

by yangyu2729

Console Switch MCP

通过串口 Console 口(RS-232/USB-to-Serial)控制网络交换机的 MCP Server。支持华为、H3C、思科等主流品牌交换机。

功能

Tool

说明

list_ports

列出计算机所有可用串口(COM口)

connect

通过 Console 口连接交换机

send_command

发送单条命令并获取返回结果

send_config

批量发送配置命令

disconnect

断开 Console 连接

get_status

查看当前连接状态

Related MCP server: rs232-mcp

支持的设备

  • 华为 (Huawei) — 自动识别 <Huawei> / [Huawei] 提示符

  • H3C — 自动识别 <H3C> / [H3C] 提示符

  • 思科 (Cisco) — 自动识别 Router> / Router# 提示符

  • 其他支持标准串口 Console 的网络设备

前置条件

  1. 硬件:Console 线(USB 转 RJ45/RS-232),常见芯片:FTDI、CH340、PL2303

  2. 驱动:安装对应 USB 转串口芯片的驱动程序

  3. Node.js:>= 18.0.0

安装

1. 克隆项目

git clone https://github.com/yangyu2729/console-switch-mcp.git
cd console-switch-mcp

2. 安装依赖并构建

npm install
npm run build

3. 配置 MCP

WorkBuddy

编辑 ~/.workbuddy/mcp.json,添加:

{
  "mcpServers": {
    "console-switch-mcp": {
      "command": "node",
      "args": ["/你的路径/console-switch-mcp/build/index.js"],
      "disabled": false
    }
  }
}

Windows 路径示例:C:/Users/你的用户名/console-switch-mcp/build/index.js macOS/Linux 路径示例:/home/你的用户名/console-switch-mcp/build/index.js

Claude Desktop

编辑配置文件:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "console-switch-mcp": {
      "command": "node",
      "args": ["/绝对路径/console-switch-mcp/build/index.js"]
    }
  }
}

配置完成后重启 WorkBuddy / Claude Desktop 即可生效。

使用

在 AI 对话中直接使用自然语言操作:

  • "列出电脑上可用的串口"

  • "用 COM3 连接华为交换机,波特率 9600"

  • "查看交换机版本信息"

  • "查看 VLAN 配置"

  • "进入系统视图,配置端口"

  • "断开连接"

常用华为交换机命令

display version              查看设备版本
display current-configuration 查看当前配置
display vlan                 查看 VLAN 信息
display interface brief      查看接口概要
display arp                  查看 ARP 表
display mac-address          查看 MAC 地址表
display ip routing-table     查看路由表
display cpu-usage            查看 CPU 使用率
display logbuffer            查看日志缓冲
system-view                  进入系统视图
ping 192.168.1.1             测试网络连通性

串口参数

参数

默认值

说明

baudRate

9600

华为/H3C 默认 9600,部分设备用 115200

dataBits

8

数据位

stopBits

1

停止位

parity

none

校验位

项目结构

console-switch-mcp/
├── src/
│   ├── index.ts           # MCP Server 入口
│   └── serial-console.ts  # 串口通信核心模块
├── build/                 # 编译输出
├── package.json
└── tsconfig.json

License

MIT

Available Tools

6 tools
connectA

通过Console口连接到网络设备(如华为/H3C/思科交换机)。连接后可以发送命令进行配置和调试。

常用波特率:华为/H3C 默认 9600,部分设备 115200。 Windows 端口示例: COM1, COM3 Linux 端口示例: /dev/ttyUSB0, /dev/ttyS0 macOS 端口示例: /dev/cu.usbserial-xxxx

Inputs: port (required), parity, baudRate, dataBits, +1 more.

disconnectA

断开与交换机的Console口连接。

Inputs: no named parameters.

get_statusA

获取当前连接状态,包括是否已连接、端口、波特率、检测到的设备类型等信息。

Inputs: no named parameters.

list_portsA

列出计算机上所有可用的串口(COM口)。用于查找通过Console线连接的交换机所在的端口号。

Inputs: no named parameters.

send_commandA

向已连接的交换机发送一条命令,并获取返回结果。

华为交换机常用命令示例:

  • display version 查看设备版本

  • display current-configuration 查看当前配置

  • display interface brief 查看接口概要

  • display vlan 查看VLAN信息

  • display mac-address 查看MAC地址表

  • display arp 查看ARP表

  • display ip routing-table 查看路由表

  • display device 查看设备状态

  • display logbuffer 查看日志缓冲

  • ping 192.168.1.1 测试网络连通性

  • system-view 进入系统视图

  • display cpu-usage 查看CPU使用率

  • display memory-usage 查看内存使用率

注意:进入 system-view 后提示符会从 变为 [Huawei],此时可执行配置命令。

Inputs: command (required), timeout.

send_configA

批量发送配置命令给交换机。自动逐条执行,适合批量配置场景。

使用前请确保已进入 system-view(系统视图)。 示例命令:

  • sysname Switch01

  • vlan 100

  • interface GigabitEthernet0/0/1

  • port link-type access

  • port default vlan 100

  • quit

每行一条命令,按顺序执行。

Inputs: commands (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: listing ports, connecting/disconnecting, checking status, and sending commands (single vs. batch). The overlap between send_command and send_config is clarified by their descriptions, making misselection unlikely.

    Naming Consistency4/5

    Most tools follow a verb_noun pattern (list_ports, get_status, send_command, send_config), while connect and disconnect are standalone verbs. This is a minor deviation but remains predictable and readable.

    Tool Count5/5

    With 6 tools, the set is well-scoped for a console management server, covering the essential operations without redundancy or bloat.

    Completeness5/5

    The server covers the full lifecycle: discovering ports, connecting, checking status, sending individual commands, and batch configuration. No obvious gaps for typical console-based switch management.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables large language models to manage network devices (Cisco, Huawei, H3C, Ruijie) via Telnet/SSH, supporting command execution, configuration, and diagnostics.
      16
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to manage Cisco, Huawei, and H3C network switches over Telnet, SSH, or Console serial connections, with automatic vendor detection, paging and prompt handling, and cleaned command output. A local SSE web console streams every command and device response in real time so operators can watch what the AI is doing.
      2
      MIT