CS

cjznb/serialhub

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

3 stars 0 forks 质量 84 趋势 19MIT

常驻串口中枢:持久多口 + 每口环形缓冲(毫秒时间戳/全局序号) + Web UI(xterm/ANSI/中英) + TCP 桥 + MCP,面向 AI agent。持久串行枢纽守护进程,具备 Web UI、TCP 桥和 MCP 服务器。

概览

将一个或多个串口转换为服务,以下内容: - 保持端口开放,并将每条线路附加到每个端口(全局单调序列 + 历数 ts_ms)。- (xterm.js)实时监控多个端口,允许你过滤、搜索、导出和发送。- 暴露全部功能集;和 共享同一个瘦客户端。- 通过 TCP 中继端口(服务器监听/客户端拨号)。- 让代理用 wait_for 屏蔽哨兵,并用since_seq光标恢复。 设计合同(数据模型/枢纽/REST/CLI/MCP,全部冻结)在docs/ARCHITECTURE.md中。MCP专用指南在docs/MCP.md(中文:docs/MCP.zh-CN.md)中。 Python -m serialhub serve --config config.example.yaml 启动守护进程,然后在浏览器中打开 http://127.0.0.1:8765/;命令行的 Python -m serialhub 列表和 MCP wait_for立即工作。 安装后,有两个等效的入口点: 在浏览器中打开http://127.0.0.1:8765/查看网页界面。 配置是 (.yaml/.

概述(AI 翻译)

英语 ·简体中文

串口枢纽 ·持久串口枢纽

将一个或多个串口转变为持久、可审查、可逐步读取且非常友好代理的服务:

  • 守护进程保持端口开放,并将每行附加到每个端口的环缓冲区(全局单调seq + 历米 ts_ms)。
  • Web UI(xterm.js)实时监控多个端口,允许你筛选、搜索、导出和发送。
  • REST + WebSocket 暴露全部功能集;CLI 和 MCP 服务器共享同一个瘦客户端。
  • TCP桥通过TCP中继端口(服务器监听/客户端拨号)。
  • MCP 工具 允许代理用 wait_for 屏蔽哨兵,并用 since_seq 光标继续,无需重新消耗。

设计合同(数据模型/枢纽/REST / CLI / MCP,全部冻结)在docs/ARCHITECTURE.md中。 MCP专属指南为docs/MCP.md(中文:docs/MCP.zh-CN.md)。 DSH(DeepSeek Harness)集成攻略格式为 docs/DSH.md(中文:docs/DSH.zh-CN.md)。


0.一句话

python -m serialhub serve --config config.example.yaml 启动守护进程,然后打开 http://127.0.0.1:8765/

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

English · 简体中文

serialhub · Persistent Serial Hub

Turn one or more serial ports into a persistent, reviewable, incrementally readable service that’s very agent-friendly:

  • The daemon holds ports open and appends every line into a per-port ring buffer (global monotonic seq + epoch-ms ts_ms).
  • Web UI (xterm.js) watches several ports live and lets you filter, search, export, and send.
  • REST + WebSocket expose the whole feature set; the CLI and the MCP server share the same thin client.
  • The TCP bridge relays a port over TCP (server listen / client dial-out).
  • MCP tools let an agent block on a sentinel with wait_for and resume with a since_seq cursor, without re-consuming.

The design contract (data model / Hub / REST / CLI / MCP, all frozen) is in docs/ARCHITECTURE.md. The MCP-specific guide is in docs/MCP.md (Chinese: docs/MCP.zh-CN.md). The DSH (DeepSeek Harness) integration walkthrough is in docs/DSH.md (Chinese: docs/DSH.zh-CN.md).


0. In one line

python -m serialhub serve --config config.example.yaml starts the daemon, then open http://127.0.0.1:8765/ in a browser; both python -m serialhub list on the command line and MCP wait_for work right away. You can run the entire pipeline without hardware by using loop://.


1. Features at a glance

Capability Description
Persistent multi-port One reader thread per port; held open and reconnected with exponential backoff on disconnect (old buffer is kept)
Auto-discovery A port may use a match spec instead of a fixed device; resolved at open and re-resolved on every reconnect, so a replugged adapter on a new COM is still found
Ring buffer Per port, evicts the oldest lines on a dual threshold of line count + bytes; default 20000 lines / 8 MiB
Global sequence seq is monotonic across all ports and thread-safe; ts_ms is the epoch-ms receive time
Line kind kind ∈ {rx, tx, mark}: received / sent by this process (echo) / marker
No double consumption read supports since_seq / since_ts cursors and returns next_seq for resuming
Blocking sentinel wait_for blocks until a line matches a regex; a timeout is not an error (matched:false, still ok:true)
Search search runs a regex over the whole buffer, optionally with a context window
Export raw / noansi / json (JSONL) to disk
REST + WS Every CLI action has a matching REST endpoint; /ws pushes live line events
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "serialhub": { "command": "python", "args": ["<path-to-serialhub>/serialhub/mcp_server.py"], "env": { "SERIALHUB_URL": "http://127.0.0.1:8765" } } } }