SuperAPIAI Directory

serial-mcp-server

github.com · AI developer platforms

📟 - Serial port communication.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

Purpose

serial-mcp-server provides serial port access capabilities for AI workflows, and is suitable for scenarios that require automated interaction with UART devices through a serial port, such as boot/configuration flows, protocol handshakes, regression smoke tests, and AI-assisted debugging. It is provided in two forms at the same time: an MCP stdio server for clients that support MCP tools, and a scriptable CLI that can be used directly without MCP configuration (for CI and agent skills).

Main capabilities

  • Two forms: an MCP stdio server (suitable for clients that support MCP tools, a long-running stdio service) and a directly usable CLI.
  • JSON macro automation (DSL): record serial steps as JSON so that humans, CLI scripts, or AI agents can validate, inspect plans, simulate without hardware, and run them. The v0.3 DSL supports send (send UTF-8, hex, or base64 bytes), delay (fixed millisecond wait), expect (read until the response contains or equals the expected bytes), and assembly (combine named macros into longer workflows).
  • Macro-related CLI commands: macro validate, macro list, macro plan, macro run; MCP macro tools support loading/listing/unloading packs in runtime memory, planning, and running.
  • Hardware-free simulation: provides explicit hardware-free simulation for macro validation, planning, and executor smoke tests.
  • Capture window reads: timeout-ms preserves single-read semantics; --duration-ms provides a bounded collection window and returns a merged response containing completion_reason, waited_ms, elapsed_ms, and per-chunk metadata. Capture options include --start-trigger first-byte / immediate, --initial-timeout-ms, --idle-timeout-ms, --max-bytes. write --read accepts the same capture options.
  • Configuration commands and output rules: stdout is reserved for command data and JSON, stderr is used for diagnostics, --json output can be parsed by tools such as jq, and a non-zero exit code indicates failure; supports utf8, hex, base64 data formats (use hex or b for binaryase64).
  • Agent skills: the repository includes skills compatible with Claude Code and Codex (skills/serial-debug), with CLI preferred and MCP described as an optional configuration path, for agents to list ports, run serial smoke tests, run macro automation, control RTS/DTR, or troubleshoot UART/USB serial devices.

Usage

For the MCP server, the recommended command is the startup method with the serve subcommand; starting without a subcommand is retained as a compatibility path, and new configurations should use serve. Configuration examples are provided for Claude Desktop (macOS/Linux and Windows). The MCP macro registry is runtime-only; restarting the server clears loaded packs, and it does not write to a persistent macro library. MCP read accepts an optional capture field in addition to connection id, timeout_ms, max_bytes, and encoding; when duration_ms is not provided, it keeps the single-read behavior, and when provided, it returns structured JSON text.

Regarding the CLI: build from source (Rust 1.74+), see the repository for the binary build path; the CLI can be installed to PATH from the checkout directory. When there is no MCP client, the CLI can be used directly for serial operations. A macro pack is a JSON file with schema_version 0.3; v0.3 supports send, delay, and expect steps within a macro, as well as assembly that calls macros by name, and expect supports contains and equals. The macro DSL is intentionally limited and does not run shell commands, JavaScript, Python, file operations, loops, variables, if/else branches, Quick commands, or RTS/DTR macro steps. Macro CLI help can be viewed via serial-mcp-server macro --help.

Applicable scenarios

  • Startup or configuration flows that require ordered commands and delays.
  • Protocol handshakes that must wait for OK, READY, PONG, a prompt, or another expected response.
  • Regression smoke tests that need to repeatedly run the same serial procedure.
  • AI-assisted debugging: review the complete send/delay/expect plan before touching hardware.

Limitations and safety

  • Running hardware operations requires a serial device or USB-to-serial adapter, as well as the device driver and operating system permissions for the selected serialport.
  • The macro DSL has explicit limitations (see above) and does not support shell, scripting languages, file operations, loops, variables, branches, Quick commands, or RTS/DTR macro steps.
  • The macro registry exists only at runtime, is cleared on restart, and is not persisted.
  • Hardware safety: serial commands affect real hardware, so first confirm the port via serial-mcp-server list-ports --json, confirm voltage levels before connecting the adapter, confirm baud rate, data bits, parity, stop bits, and flow control before writing, handle RTS and DTR carefully (many boards use them for reset or boot mode), and base verification conclusions on the command output of the connected device.
  • Claude Code --bare mode failed to resolve /serial-debug in local testing; skill-triggered smoke tests should use normal Claude Code print or interactive mode.

Other information

  • Current release target: 0.3.0.
  • Language versions: English and Chinese.
  • An STM32 demo example is provided (under examples/STM32_demo/), including firmware with an interactive serial command interface; see the README in that directory for wiring, firmware commands, MCP usage, and CLI smoke commands.
  • Release work uses the checked-in Cargo.lock and related gates.
  • License: MIT, see LICENSE.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools