Skip to main content
Glama
yangyu2729

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: NetPilot-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

ParametersJSON Schema
NameRequiredDescriptionDefault
portYes串口路径,如 COM3 (Windows) 或 /dev/ttyUSB0 (Linux/macOS)
parityNo校验位,网络设备通常为 nonenone
baudRateNo波特率,华为/H3C 交换机默认 9600。常用值: 9600, 19200, 38400, 57600, 115200
dataBitsNo数据位,网络设备通常为 8
stopBitsNo停止位,网络设备通常为 1

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions common baud rates and port examples, which adds operational context, but it does not explain what happens on connection failure, whether the connection is persistent, or how to handle a busy port. These gaps are notable for a connection-establishing tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured: it opens with the tool's purpose, then provides relevant practical details (baud rates and port examples) in a list-like format. No sentence is wasted, and the information is front-loaded for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has five parameters and no output schema, the description provides a reasonable level of completeness by explaining the connection action and giving examples for common parameters. It does not mention return values or session management, but those may be implied by the sibling tools. The lack of annotations is partially compensated by the practical guidance included.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already covers parameter descriptions fully, but the description adds value by providing OS-specific port examples (Windows, Linux, macOS) and noting that some devices use 115200 baud. This goes beyond the schema, which only gives a generic example, and helps the agent select appropriate parameter values in different environments.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific action (connecting via Console port) and the target resource (network devices such as Huawei/H3C/Cisco switches). It distinguishes itself from sibling tools by focusing solely on establishing the connection, unlike send_command or send_config which operate after a connection exists.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by mentioning that after connecting, commands can be sent, which implies this tool is a prerequisite for send_command/send_config. It also offers practical OS-specific port examples and common baud rates. However, it does not explicitly state when not to use this tool or mention alternatives like list_ports for discovering available ports.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

disconnectA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action but does not disclose any side effects, preconditions (e.g., must be connected), or error behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that is front-loaded and contains no fluff or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters and no output schema, the description adequately conveys the tool's function. However, it leaves out any mention of return values or preconditions, which could be useful for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are zero parameters, and the description provides no parameter information. Per baseline, 0 parameters warrant a score of 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly specifies the action (断开, disconnect) and the resource (交换机的Console口, switch's console port). It is distinguishable from the sibling tool 'connect'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the tool name and description (disconnect from a switch's console port), but there is no explicit guidance on when to use it or how it relates to alternatives like 'connect'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_statusA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It lists the output fields (connected, port, baud rate, device type), which is useful, but it does not explicitly state that the tool is read-only, what happens when not connected, or whether it may block or throw errors. The verb '获取' implies a read operation, but the description could be more transparent about side effects and edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that immediately conveys the purpose and key output details. It contains no fluff or repetition, making it highly concise and well-structured for quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema, no annotations), the description is fairly complete: it states the purpose and enumerates the expected return fields. It falls short of describing error behavior or the exact response format, but for a status-checking tool, it covers the core information well.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the schema coverage is trivially 100%. According to the rubric, the baseline is 4. The description adds no parameter information because there are none to describe; this is appropriate and does not detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb '获取' (get) and the specific resource '当前连接状态' (current connection status), and enumerates the included details (connected, port, baud rate, device type). This is a specific, non-tautological purpose that effectively distinguishes the tool from siblings like connect, disconnect, and list_ports.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly state when to use this tool over alternatives or provide exclusion criteria. However, the unique purpose of checking connection status is implied, which gives some guidance. There is no mention of 'use this when you need to verify connection' or 'use list_ports to enumerate available ports instead.'

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_portsA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It implies a read-only operation by stating it lists available ports, but it does not disclose the output format, whether it modifies anything, or any system prerequisites. For a simple listing tool, this is adequate but not rich. There is no contradiction with annotations since none exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long, front-loaded with the primary action ('列出所有可用的串口'), followed by a concise usage note. Every sentence earns its place, with no superfluous content. It is compact and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema, no annotations), the description is adequately complete. It states what the tool does and when to use it, which is sufficient for an agent to select and invoke the tool. It could mention the return format or that it is read-only explicitly, but those are minor omissions for a trivial list operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters in the input schema, and the schema description coverage is 100%. The description adds no parameter-specific information because there are no parameters to document. Per the rubric, 0 parameters corresponds to a baseline score of 4, and the description does not need to compensate for any parameter documentation gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: '列出计算机上所有可用的串口(COM口)' (List all available serial ports on the computer). It uses a specific verb ('列出' / list) and resource ('串口' / serial ports), and further clarifies its purpose for finding the port of a console-connected switch. This distinguishes it from the sibling tools like connect, send_command, etc., which handle other aspects of serial communication.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage context: it is used to find the port number where a switch is connected via Console cable ('用于查找通过Console线连接的交换机所在的端口号'). Although it does not explicitly mention when not to use this tool or name alternative tools, the context is sufficient for an agent to know it is a preliminary discovery step before connect or send_config. The absence of exclusions is a minor gap.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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],此时可执行配置命令。

ParametersJSON Schema
NameRequiredDescriptionDefault
commandYes要发送给交换机的命令(不需要带回车,会自动添加)
timeoutNo等待响应的超时时间(毫秒),默认 5000ms。对于 show running-config 等长输出建议设大一些

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It goes beyond the schema by explaining that newlines are auto-added, that timeout should be increased for long outputs, and that the prompt changes when entering system-view. These are useful behavioral details. However, it does not disclose the exact return format or potential error behaviors, leaving some gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with a clear purpose statement, followed by a well-organized list of common commands and a note about system-view. While it is longer than a typical description due to the examples, every line contributes useful information and there is no fluff or repetition. It is structured effectively for quick scanning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has only 2 parameters and no output schema or annotations, the description is fairly comprehensive. It explains the core action, provides usage examples, and gives practical tips like timeout adjustment and prompt change behavior. It does not specify the return format or error handling, but for a simple command-sending tool, the level of detail is sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already describes both parameters (command and timeout) fully, so the baseline is 3. The description adds value by providing example command syntax and clarifying that newlines are automatically added, plus a recommendation to increase timeout for long outputs. This enhances the semantic understanding beyond the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: sending a command to the connected switch and retrieving the result (向已连接的交换机发送一条命令,并获取返回结果). It includes numerous command examples, making the purpose concrete. However, it does not explicitly distinguish itself from the sibling tool send_config, which likely also sends commands, so it lacks sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides many example commands (display version, ping, system-view) that illustrate typical usage, and notes about auto-added newline and timeout for long outputs. However, it does not explicitly state when to use this tool versus alternatives like send_config or get_status, nor does it mention any exclusions. The usage context is implied through examples rather than explicit guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

send_configA

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

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

  • sysname Switch01

  • vlan 100

  • interface GigabitEthernet0/0/1

  • port link-type access

  • port default vlan 100

  • quit

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

ParametersJSON Schema
NameRequiredDescriptionDefault
commandsYes要批量执行的配置命令列表,每行一条

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It discloses that commands are executed sequentially: '自动逐条执行' (automatically executes one by one) and '按顺序执行' (executed in order), and notes the system-view prerequisite. However, it does not mention error handling behavior, whether execution stops on failure, or any side effects beyond configuration changes, which are gaps given the absence of annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the main purpose, followed by a prerequisite and useful example commands. It is reasonably concise, though the example list is somewhat long. Each part serves a purpose: examples clarify command format and context. No unnecessary fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter) and no output schema or annotations, the description provides the essential usage context: batch execution, order, and prerequisite. However, it omits important operational details such as whether an active connection is required and what happens when a command fails. Since annotations and output schema are absent, the description should have covered these to be fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a clear description for the 'commands' parameter (list of commands, one per line). The tool description adds value beyond the schema by providing example commands, clarifying the order of execution, and emphasizing the need for system-view context. This enriches the understanding of what valid input looks like.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: '批量发送配置命令给交换机' (batch send configuration commands to switch), with '自动逐条执行' (automatically executes one by one). It also emphasizes '适合批量配置场景' (suitable for batch configuration scenarios), which distinguishes it from sibling tools like send_command that target single commands.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: '适合批量配置场景' (suitable for batch configuration scenarios). It also specifies a prerequisite: '使用前请确保已进入 system-view(系统视图)' (before use, ensure you have entered system-view). However, it does not explicitly mention alternatives or when not to use it, so it falls short of a perfect score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.2/5.0
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

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    B
    maintenance
    A comprehensive MCP server for network device management via SSH/Telnet. Supports multiple vendors such as Cisco IOS and BDCOM, enabling AI assistants to execute commands and manage routers, switches, and firewalls.
    4
    MIT
  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables large language models to manage network devices (Cisco, Huawei, H3C, Ruijie) via Telnet/SSH, supporting command execution, configuration, and diagnostics.
    12
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables agents to access network device management interfaces via SSH, keeping credentials on the server side. Supports both interactive terminal sessions and command execution on devices like Huawei VRP, MikroTik, and OpenWrt.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yangyu2729/console-switch-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server