serial-hub-mcp
serial-hub-mcp is an MCP serial hub for discovering, opening, and interacting with serial ports using byte-accurate I/O and durable logs.
Enumerate available serial ports and open/close local or configured remote serial connections.
Send/read raw bytes and perform request-response transactions with timeouts and match patterns.
Capture receive windows, dump RX streams directly to files, and inspect connection status/counters.
Control DTR/RTS lines, pulse reset sequences, and send BREAK signals.
Query, inspect, and clear host-side serial logs by sequence, time, direction, substring, or regex.
Save, list, and delete reusable connection profiles.
Return service/version/endpoint metadata via
service_info.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@serial-hub-mcp list serial ports and open /dev/ttyUSB0 at 115200 baud"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
serial-hub-mcp
One MCP server for local and remote serial ports — byte-transparent I/O, durable logs, and a browser terminal.
中文说明:README.zh.md
Contents: Quick start · Tools · Configuration · Deployment · Documentation · Security
serial-hub-mcp is an MCP server that is also a serial hub. One process can hold multiple
local UARTs plus remote serial endpoints — an ESP32-S3 wireless bridge or an x86/Linux
serial-hub-server that exposes all of its local ports.
The byte plane is intentionally boring: bytes in, bytes out, no framing, no prompt/regex interpretation. Content judgement is left to the agent. The host splits lines for retrieval, assigns log sequence numbers, and keeps the raw hex as the source of truth.

Why
One interface for local and remote: the same
read/write/transact/receivetools work whether the port is on the host, an ESP32, or another Linux box.Byte-transparent: no hidden framing or prompt parsing; agents see what the device sent.
Durable host-side logs: query by sequence, time, direction, or content; the device only keeps bytes that have not been ACKed.
Operable: profiles, open history, DTR/RTS/BREAK, dump/download, and a Web terminal.
Related MCP server: UART MCP Server
Features
stdio + Streamable HTTP transports; optional Bearer auth and unauthenticated
/health//info.Local serial via
serialport: path, profile,sn/vid/pid, baud, parity, flow control.Byte-accurate I/O:
read(cat),transact(write + wait, ignores pre-write noise),receive(windowed capture),dump_to_file(export a cached slice).Control lines: DTR/RTS with pulse for reset sequences, plus BREAK.
Durable logs: v2 binary segments + SQLite(WAL) block indexes by default; JSONL legacy mode is still available.
Profiles and remotes: save connection parameters, register remotes once, and let
list_portsaggregate local and remote ports in parallel.Remote link v1: binary BATCH frames, ACK flow control, capture resume, single writer.
Web UI: one tab per connection (close it from the tab, filterable picker when there are many), xterm terminal, live RX/TX log, history and download in
--httpmode.
Quick start
Requirements
Node.js >= 22 (CI covers 22 and 24; the Docker image uses Node 22).
Linux: add your user to
dialoutfor/dev/ttyUSB*//dev/ttyACM*.Optional: Docker for the x86
serial-hub-server.
Install from source
The package is not published on npm yet.
git clone https://github.com/yhuan416/serial-hub-mcp.git
cd serial-hub-mcp
npm ci
node src/server.js # stdio
node src/server.js --http # HTTP + Web UI on 127.0.0.1:8787Optional: npm link puts serial-hub-mcp and serial-hub-server on your PATH.
MCP client configuration
stdio:
{
"mcpServers": {
"serial": {
"command": "node",
"args": ["/absolute/path/to/serial-hub-mcp/src/server.js"]
}
}
}After npm link, "command": "serial-hub-mcp" is enough.
Streamable HTTP:
SERIAL_HUB_MCP_HTTP_TOKEN=change-me node src/server.js --http --host 0.0.0.0 --port 8787{
"mcpServers": {
"serial-hub": {
"type": "http",
"url": "http://127.0.0.1:8787/mcp",
"headers": { "Authorization": "Bearer change-me" }
}
}
}Non-loopback HTTP binds require a token; see Security.
First calls
list_ports()
open({ port: "/dev/ttyUSB0", baud_rate: 115200 })
receive({ connection_id: "...", start: "flush", budget_ms: 5000 })
transact({ connection_id: "...", data: "AT", newline: "crlf", match: "OK" })
close({ connection_id: "..." })Remote:
open({ remote: "lab-x86", port_id: "ttyACM0", baud_rate: 921600 })
open({ transport: "remote", endpoint: "tcp://192.168.4.67:7000", token: "...", port_id: "uart1" })Tools
Tool | What it does |
| Local ports plus every configured remote |
| Open or close a connection |
| Ports opened before, deduped by endpoint/port/baud |
| State, counters, control-line levels |
| Read bytes since the cursor |
| Send bytes |
| Write then wait for a response |
| Capture a window until match / idle / budget / max bytes |
| Export a cached slice by seq, time, or offset |
| Control lines and BREAK |
| Reusable connection profiles |
| Query, inspect, clear host logs |
| Service name, version, endpoints/storage/limits, changelog |
Full parameters, examples, and read-only/destructive hints: docs/tools.md.
Configuration
Common variables; the full table is in docs/configuration.md.
Variable | Default | Purpose |
| unset |
|
|
| HTTP bind host |
|
| HTTP bind port |
| unset | Secret. Bearer token; required for non-loopback binds |
| unset | Secret file. Read token from file; env wins |
| unset | Access URL shown on |
|
|
|
|
|
|
|
| Delete logs/dumps/captures older than this; |
|
| Close connections idle for N minutes; |
|
| Remote registry |
|
| Directory containing |
Paths use $XDG_CACHE_HOME (default ~/.cache) and $XDG_CONFIG_HOME (default ~/.config).
Secrets also support <NAME>_FILE for Docker/Kubernetes secret files; a direct environment
variable wins over the file. See docs/configuration.md.
Deployment
stdio: run
node src/server.jsfrom your MCP client.Streamable HTTP:
--httpexposes/mcp,/health,/info,/dumps/<file_id>, and the Web UI at/./infois a self-describing page: JSON for scripts,?format=html(or any browser) for humans — deployment, storage, limits, endpoints, and copy-paste client setup. It is unauthenticated and never contains the token. The same data is returned by theservice_infotool; conventions live in docs/info-page.md.Docker MCP: docker/serial-hub-mcp.Dockerfile and the compose files in docker/.
x86 serial hub: docs/x86-hub-server.md.
Remote registry: docs/remotes.md.
The self-describing /info page
Browsers get a readable page; scripts get JSON from the same URL:
It answers the questions that come right after a deploy: which version is running, where the
data lives, what the limits are, which endpoints need a token, and how to point a client at it
(the top section is shown here; storage, limits, endpoints and client setup follow).
The page is unauthenticated, never contains the token, and returns the same data as the
service_info tool (JSON keys stay English; page labels are Chinese today).
serial-hub-server serves the same page on its binary port
(http://<hub>:7000/info). Contract and template: docs/info-page.md.
Operational details (reverse proxy, Docker mounts, systemd, Harbor, rollback): docs/deployment.md.
Architecture
flowchart LR
A[MCP client] -->|stdio / HTTP| B[serial-hub-mcp]
B --> C[local UARTs]
B -->|TCP v1 SH frames| D[ESP32-S3 bridge]
B -->|TCP v1 SH frames| E[x86 serial-hub-server]
E --> F["/dev/ttyUSB*, ttyACM*"]The host owns line splitting, seq, logs, and read cursors. The remote only keeps bytes that
have not been ACKed. Wire format: docs/remote-link-protocol-v1.md.
Documentation
Doc | What |
Install, client config, first calls | |
Full tool reference and examples | |
Every environment variable and path | |
stdio, HTTP, Docker, systemd, Harbor | |
| |
| |
Multi-port Linux service | |
Binary wire contract | |
Log model, v2 store, retention, dumps | |
Common errors and diagnostics | |
Tests, lint, CI, release steps |
Development
npm ci
npm test # unit tests + stdio/HTTP smoke; no hardware required
npm run lint
npm run smoke
npm run smoke:httpRemote tests start an in-process hub. CI runs Node 22 and 24 (Node 22+ is required).
Release steps (version bump, tags, Harbor image, deployment) are in docs/development.md.
Security
The remote link and HTTP transport are plaintext. Use a trusted LAN, VPN, or SSH tunnel.
Binding a non-loopback HTTP address without
SERIAL_HUB_MCP_HTTP_TOKENis refused unless--allow-anonymous/SERIAL_HUB_MCP_HTTP_ALLOW_ANONYMOUS=1is set explicitly.Loopback HTTP binds validate
HostandOriginagainst127.0.0.1/localhostby default (DNS rebinding protection) — on every route, including/healthand/info. Override withSERIAL_HUB_MCP_HTTP_ALLOWED_HOSTS/SERIAL_HUB_MCP_HTTP_ALLOWED_ORIGINSwhen using a hostname or reverse proxy.Tokens are masked in tool output and
open_list; prefertoken_envinremotes.json.Report vulnerabilities privately; see SECURITY.md.
Secrets
Secret | Purpose | Source | Handling |
| Bearer token for | env or | Constant-time compare; never logged; masked |
| HELLO auth for the x86 hub | env, |
|
Direct env wins over *_FILE. A missing or empty *_FILE aborts startup instead of silently
generating a new token. Prefer Docker/Kubernetes secrets mounted as files; see
docs/configuration.md.
License
MIT. See LICENSE.
Available Tools
18 toolsclose关闭串口B
关闭一个之前打开的串口连接。
Inputs: connection_id (required).
dump_to_fileRX 直落盘(大流量抓取)A
把 Rx(可选先清缓冲)边收边写入文件,返回文件路径与结尾预览——大流量/长日志不经过 MCP 搬运。 结束条件优先级:match(字节) 出现 > 达到 max_bytes > 静默 idle_timeout_ms > budget_ms 耗尽。默认文件按天归档到 ~/.cache/serial-hub-mcp/dumps/。
Inputs: connection_id (required), dir, path, flush, +5 more.
get_status连接状态A
查看指定连接(或多个连接)的打开状态、波特率、收发字节数、剩余未读字节。connection_id 省略则列出全部连接。
Inputs: connection_id.
list_ports列出串口A
枚举系统检测到的串口。返回每个端口的路径、厂商、序列号、USB VID/PID 等。打开前先调用此工具确认存在的端口。
Inputs: no named parameters.
log_clear清空串口日志A
清空指定连接(或全部)的日志:内存 + 已落盘文件。清空后不可恢复,谨慎使用。
Inputs: connection_id.
log_query检索串口日志A
检索串口日志条目。日志按行切分(\n / \r\n),每条含全局 seq 索引、epoch 时间戳 ts、方向 dir(rx/tx)、内容 line/hex/bytes。支持按连接、方向、索引范围(seq_from/seq_to)、时间范围(time_from/time_to)、内容子串(contains)、正则(regex)过滤。存储:内存保留最近 N 条,最旧溢出到磁盘(每连接分片 JSONL,超保留上限自动淘汰最旧分片);检索时内存+磁盘都查。返回 entries(含 count/truncated)与 earliest_seq/retention(earliest_seq 之后的历史才完整,淘汰过的更早部分不可回溯)。
Inputs: dir, limit, order, regex, +6 more.
log_stats串口日志统计A
查看日志存储统计:各连接的日志总条数、内存/磁盘分布、分区/淘汰信息、时间范围、目录路径;省略 connection_id 则给出全局汇总。
Inputs: connection_id.
open打开串口A
打开一个串口连接。定位端口三选一:port(路径)/ profile(命名参数)/ sn|vid|pid(按设备标识自动找)。transport=remote 时改用 endpoint(ESP32 无线串口桥,如 tcp://esp32s3-01:7000),不使用 port/sn/vid/pid。baud_rate 默认 115200;data_bits 默认 8;stop_bits 默认 1;parity 默认 none;flow_control 默认 none。newline 设置发送默认追加的换行(write/transact 未显式指定时的默认)。成功后返回 connection_id,后续 read/write/transact 用它。
Inputs: sn, pid, vid, port, +10 more.
profile_delete删除连接 profileC
删除指定命名 profile。
Inputs: name (required).
profile_list列出连接 profileA
列出已保存的串口连接 profile(port/波特率/换行/prompt 等参数),open({profile:name}) 一条复用。
Inputs: no named parameters.
profile_save保存连接 profileB
把常见连接参数存为命名 profile,供 open({profile}) 一条复用。字段与 open 一致:transport/endpoint/port/baud_rate/data_bits/stop_bits/parity/flow_control/rx_buffer_size/newline/prompt/regex/note。
Inputs: name (required), note, port, regex, +10 more.
read读取串口数据A
读取串口已到达的数据。默认立即返回所有未读字节(cat 语义)。wait_ms>0 时等待新数据;min_bytes 指定等待的最少字节数。match + match_encoding 指定匹配串:一旦缓冲里出现匹配即返回(含匹配部分)。返回 text/hex/bytes 及 matched/timed_out。
Inputs: connection_id (required), match, wait_ms, min_bytes, +1 more.
receive统一接收窗口(持续收流量直到结束)A
持续消费全部到达流量,直到命中 match(字节)、达到 max_bytes、静默 idle_timeout_ms、或 budget_ms 耗尽。结束时不丢弃流量——期间所有字节如实带回,由 matched/stopped_reason 说明命中情况;内容判读交给 agent。start=cursor 从当前游标起;start=flush 先清缓冲(干净窗口)再开始;可选 reset 复位(配合 start=flush 抓启动日志)。抓 boot 示例:receive({start:'flush', reset:'dtr', budget_ms:15000})。
Inputs: connection_id (required), match, reset, start, +5 more.
send_break发送 BREAK 信号A
向串口发送 BREAK 信号并释放(保持 duration_ms 后释放)。常用于唤醒/复位只认 BREAK 的设备。duration_ms 默认 300。
Inputs: connection_id (required), duration_ms.
service_infoA
返回服务信息:服务名/版本/端点/(可选)变更摘要(changelog),用于确认部署版本与接入方式。
Inputs: no named parameters.
set_dtr_rts设置 DTR/RTS 控制线A
设置串口 DTR/RTS 调制解调控制线电平。未传的线保持不动。pulse_ms>0 时先设为给定值、保持该时长后自动反转(一次完成"拉低→放高"之类的复位时序,如 Arduino 自动复位)。需要多拍精确时序(如 ESP32 进下载模式)时,可分多次调用本工具逐拍设置。返回最终 dtr/rts 电平。
Inputs: connection_id (required), dtr, rts, pulse_ms.
transact收发交互(写+读)A
写入数据后等待回包,在一步内完成,是 AT/Modbus/GRBL 等请求响应式交互的推荐入口。写后只关心"写之后到达"的字节(忽略此前已缓冲的噪声)。timeout_ms 限时等待;match + match_encoding 指定响应结束标志。返回 text/hex/bytes 及 matched/timed_out。交互终端推荐 newline=crlf + match=提示符,避免把字面换行当命令。
Inputs: data (required), connection_id (required), match, newline, +3 more.
write发送串口数据A
向串口发送数据(只发不收)。data 为字符串,encoding 决定解码方式:utf8(默认,直接按文本)、hex(如 "AF 01")、base64。成功后返回写入字节数。如需"发完等回包"请用 transact。newline 未写时用 open 时的默认。发一行命令建议 newline=crlf,避免把字面换行当命令。
Inputs: data (required), connection_id (required), newline, encoding.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
read, receive, dump_to_file, and transact all consume serial data with overlapping parameters (match, max_bytes, timeouts), so an agent must read carefully to choose among them—especially read vs receive. The descriptions do differentiate them (cat semantics vs consume-until-condition vs one-shot request/response vs write-to-file), which keeps it from being worse, but the read-side surface is crowded.
Almost everything is snake_case and grouped predictably (log_query/log_stats/log_clear, profile_list/profile_save/profile_delete). The main deviation is bare verbs (open, close, read, write, receive, transact) mixed with verb_noun names (list_ports, get_status, send_break), and service_info is noun-first, but the overall pattern remains readable.
18 tools is on the heavy side but each maps to a real facet of serial work: connection lifecycle, I/O, profiles, logging, modem control, and file dumping. Nothing feels gratuitously duplicated, though the read-path tools (read/receive/dump_to_file/transact) add some bulk.
Coverage is strong: port enumeration, open/close, read/write/transact, profile CRUD, log query/stats/clear, DTR/RTS with pulse, BREAK, status, and file dump—no obvious dead ends for the stated scope. Minor gaps like fetching a single profile by name or exporting logs are workarounds an agent can handle via profile_list and log_query.
Maintenance
Related MCP Connectors
Build, run, inspect, and continue AgentScript workflows on connected Super Chrome and Mac clients.
Agent interoperability design, delivered per API call as an atom service on Conduit Atoms.
Run and manage H Company's Computer-Use Agents from any MCP client.
Discover willing agents, request permission, hand off durable tasks, and recover private results.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to interact with physical serial port devices across platforms (Windows COM/Linux tty) with support for asynchronous communication, URC pattern recognition, and structured logging.1-
- AlicenseAqualityDmaintenanceEnables AI assistants to communicate with serial port devices, supporting port management, data transmission in text/binary modes, interactive terminal sessions, and automatic reconnection.1412MIT
- AlicenseAqualityCmaintenanceAllows AI agents to interact with serial devices via RS232/UART, enabling port listing, connection, read/write, control line manipulation, and protocol specification for automated debugging and testing.2790 PyPI27MIT
- AlicenseAqualityDmaintenanceEnables AI agents to communicate with serial devices such as Arduinos, ESP32s, USB-UART adapters, and RS-232 instruments by discovering ports, opening connections, sending commands, reading responses, and controlling reset lines.122MIT