Skip to main content
Glama
mcp-uart

mcp-uart

by SamyiHu
README.md
# mcp-uart

Serial console and MCP server for AI agents — talk to UART devices, and watch
every byte while the agent does it.

[中文说明](README.zh-CN.md)

## What it is

- **MCP server** — three grouped tools for any MCP client (Claude Code, Cline, Cursor, …)
- **DSH plugin** — a serial panel, floating orb and status strip inside DeepSeek Harness
- **HTTP hub** — the same session over HTTP/SSE, so the panel and the agent share one port

The runtime is a native Rust daemon (`uartd`); the Node sources stay for the
HTTP API and as a fallback.

## Install

```bash
npm install -g mcp-uart
```

The daemon ships as one small package per platform (`optionalDependencies`), so
nothing is compiled on install.

| Platform | Package |
|---|---|
| Windows x64 | `mcp-uart-uartd-win32-x64` |
| Linux x64 / arm64 (static) | `mcp-uart-uartd-linux-*` |
| macOS Intel / Apple silicon | `mcp-uart-uartd-darwin-*` |

From source: `npm install && npm run build && npm run build:rust`.

Linux needs serial permission: `sudo usermod -aG dialout $USER`, then log in again.

## Use it from an MCP client

```json
{
  "mcpServers": {
    "uart": { "command": "mcp-uart", "args": [] }
  }
}
```

Web console without an MCP client:

```bash
mcp-uart-hub --port 8787     # open http://127.0.0.1:8787
```

## Tools

Three tools, each taking an `action`:

| Tool | Actions | Covers |
|---|---|---|
| `uart_serial` | 18 | ports, open/close, write/read, **capture**, **timeline**, wait, extract, monitors, signals, encodings, protocols |
| `uart_orchestrator` | 7 | profile-driven testing: list, connect, run, `sequence`, smoke, status |
| `uart_view` | 6 | panel status, frames, history, ports, HTML reports |

### Capture: one call, timed result

Reads stop on a condition instead of polling:

```json
{
  "action": "capture",
  "send": { "data": "READ?\r\n" },
  "filter": { "direction": "rx" },
  "stop": { "untilHex": "0D0A", "timeoutMs": 2000 },
  "startHex": "AA"
}
```

Stop conditions: `bytes`, `frames`, `untilHex`, `untilText`, `silenceMs`,
`timeoutMs`. Every frame comes back with `tMs` relative to the send.

### Timeline: the agent declares a plan

Agent round trips are seconds; serial timing is milliseconds. A timeline runs on
the daemon's clock instead:

```json
{
  "action": "timeline",
  "steps": [
    { "atMs": 0,   "send": { "data": "AT+RST\r\n" } },
    { "atMs": 200, "mark": "boot" },
    { "atMs": 250, "send": { "hex": "AA55" } },
    { "atMs": 300, "wait": { "untilText": "OK", "timeoutMs": 500 } }
  ],
  "tailMs": 200
}
```

Returns per-step `plannedMs` → `actualMs` with `jitterMs`, plus the frames and
which step each followed.

## DSH plugin

One bundle, two rows on the plugin page: the panel and the agent tools. The
panel has three placements — sidebar, floating orb, or a strip under the
composer — and is switchable from the plugin settings.

While an MCP bridge row is active the tool row steps aside, so the model never
sees two copies of the same tools.

## HTTP API

`/api/health`, `/api/ports`, `/api/status`, `/api/frames`, `/api/history`,
`/api/connect`, `/api/write`, `/api/config`, `/api/signals`, `/api/capture`,
`/api/timeline`, `/api/monitor/*`, `/api/visualize`, `/api/orchestrator/*`.

## Development

```bash
npm run build      # TypeScript + assets + DSH client bundle
npm run build:rust # native daemon
npm test           # desensitisation guard, Node suite, UI suite, parity checks
cargo test --manifest-path rust/Cargo.toml
npm run pack:platform     # build this platform's npm package
```

Chip-specific test profiles stay on your machine: only `frame-demo.json` and
`text-console.json` are tracked, everything else under
`src/orchestrator/profiles/` is ignored. `npm run hooks:install` adds a
pre-commit check that refuses commits containing a chip model, a personal path
or a credential; `npm run check:desensitized` runs the same check by hand.

## License

MIT