serial-hub-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| SERIAL_HUB_MCP_HTTP | No | Set to 1 to enable HTTP mode, equivalent to --http. | |
| SERIAL_HUB_MCP_LOG_MEM | No | Number of in-memory log entries per process. Defaults to 1000. | |
| SERIAL_HUB_MCP_LOGS_DIR | No | Directory for log partitions. Defaults to $XDG_CACHE_HOME/serial-hub-mcp/logs. | |
| SERIAL_HUB_MCP_DUMPS_DIR | No | Output directory for dump_to_file. Defaults to $XDG_CACHE_HOME/serial-hub-mcp/dumps. | |
| SERIAL_HUB_MCP_HTTP_HOST | No | HTTP bind host. | 127.0.0.1 |
| SERIAL_HUB_MCP_HTTP_PATH | No | MCP endpoint path. | /mcp |
| SERIAL_HUB_MCP_HTTP_PORT | No | HTTP bind port. | 8787 |
| SERIAL_HUB_MCP_HTTP_TOKEN | No | Optional Bearer token for the /mcp endpoint. | |
| SERIAL_HUB_MCP_PROFILES_DIR | No | Directory for reusable connection profiles. Defaults to $XDG_CONFIG_HOME/serial-hub-mcp. | |
| SERIAL_HUB_MCP_HTTP_INFO_PATH | No | Unauthenticated service info endpoint path. | /info |
| SERIAL_HUB_MCP_LOG_PART_BYTES | No | Log partition roll size in bytes. Defaults to 8388608 (8 MiB). | |
| SERIAL_HUB_MCP_HTTP_HEALTH_PATH | No | Unauthenticated health endpoint path. | /health |
| SERIAL_HUB_MCP_LOG_RETAIN_BYTES | No | Disk retention in bytes per connection. Defaults to 67108864 (64 MiB/conn); <=0 disables eviction. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_portsA | 枚举系统检测到的串口。返回每个端口的路径、厂商、序列号、USB VID/PID 等。打开前先调用此工具确认存在的端口。 |
| openA | 打开一个串口连接。定位端口三选一: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 用它。 |
| closeB | 关闭一个之前打开的串口连接。 |
| writeA | 向串口发送数据(只发不收)。data 为字符串,encoding 决定解码方式:utf8(默认,直接按文本)、hex(如 "AF 01")、base64。成功后返回写入字节数。如需"发完等回包"请用 transact。newline 未写时用 open 时的默认。发一行命令建议 newline=crlf,避免把字面换行当命令。 |
| readA | 读取串口已到达的数据。默认立即返回所有未读字节(cat 语义)。wait_ms>0 时等待新数据;min_bytes 指定等待的最少字节数。match + match_encoding 指定匹配串:一旦缓冲里出现匹配即返回(含匹配部分)。返回 text/hex/bytes 及 matched/timed_out。 |
| transactA | 写入数据后等待回包,在一步内完成,是 AT/Modbus/GRBL 等请求响应式交互的推荐入口。写后只关心"写之后到达"的字节(忽略此前已缓冲的噪声)。timeout_ms 限时等待;match + match_encoding 指定响应结束标志。返回 text/hex/bytes 及 matched/timed_out。交互终端推荐 newline=crlf + match=提示符,避免把字面换行当命令。 |
| get_statusA | 查看指定连接(或多个连接)的打开状态、波特率、收发字节数、剩余未读字节。connection_id 省略则列出全部连接。 |
| set_dtr_rtsA | 设置串口 DTR/RTS 调制解调控制线电平。未传的线保持不动。pulse_ms>0 时先设为给定值、保持该时长后自动反转(一次完成"拉低→放高"之类的复位时序,如 Arduino 自动复位)。需要多拍精确时序(如 ESP32 进下载模式)时,可分多次调用本工具逐拍设置。返回最终 dtr/rts 电平。 |
| send_breakA | 向串口发送 BREAK 信号并释放(保持 duration_ms 后释放)。常用于唤醒/复位只认 BREAK 的设备。duration_ms 默认 300。 |
| receiveA | 持续消费全部到达流量,直到命中 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})。 |
| dump_to_fileA | 把 Rx(可选先清缓冲)边收边写入文件,返回文件路径与结尾预览——大流量/长日志不经过 MCP 搬运。 结束条件优先级:match(字节) 出现 > 达到 max_bytes > 静默 idle_timeout_ms > budget_ms 耗尽。默认文件按天归档到 ~/.cache/serial-hub-mcp/dumps/。 |
| log_queryA | 检索串口日志条目。日志按行切分(\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 之后的历史才完整,淘汰过的更早部分不可回溯)。 |
| log_statsA | 查看日志存储统计:各连接的日志总条数、内存/磁盘分布、分区/淘汰信息、时间范围、目录路径;省略 connection_id 则给出全局汇总。 |
| log_clearA | 清空指定连接(或全部)的日志:内存 + 已落盘文件。清空后不可恢复,谨慎使用。 |
| profile_listA | 列出已保存的串口连接 profile(port/波特率/换行/prompt 等参数),open({profile:name}) 一条复用。 |
| profile_saveB | 把常见连接参数存为命名 profile,供 open({profile}) 一条复用。字段与 open 一致:transport/endpoint/port/baud_rate/data_bits/stop_bits/parity/flow_control/rx_buffer_size/newline/prompt/regex/note。 |
| profile_deleteC | 删除指定命名 profile。 |
| service_infoA | 返回服务信息:服务名/版本/端点/(可选)变更摘要(changelog),用于确认部署版本与接入方式。 |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
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.