serial-bridge-mcp
Allows interacting with a Linux serial console target: executing commands and capturing output, sending text or raw payloads, and reading recent session logs.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Serial Bridge
Serial Bridge is a Hub that shares the serial consoles of one or more DUTs
between a local Operator and MCP Agents. Each DUT owns one or two Targets and
its own Bridge or CRT Mode. It is not OS-specific: install the Python packages in
requirements.txt and run it on any host with Python 3.10+. The Hub lives in
the serial_bridge/ package; start it with python -m serial_bridge or the
root app.py shim.
Install and start
Python 3.10 or newer is recommended.
python -m pip install -r requirements.txt
python -m serial_bridgeShell snippets below use PowerShell ($env:NAME = "..."). On bash or zsh, set the
same names with export NAME=....
The Hub opens your browser to the console at http://127.0.0.1:8765/ once it
is listening. The root app.py shim is equivalent. To start without opening a
browser tab:
$env:SERIAL_BRIDGE_OPEN_UI = "off"
python -m serial_bridgeOr pass --no-open-ui. Use --open-ui to force open when the environment
disables it. Unset SERIAL_BRIDGE_OPEN_UI means open by default; only
0, false, no, and off (case-insensitive) disable it.
On first boot the Hub auto-generates an Access Token into serial_bridge.token
beside the Port Binding config file (override the path with
SERIAL_BRIDGE_TOKEN_FILE). Do not commit the secrets file.
Open Setup (http://127.0.0.1:8765/setup) on the Hub host to copy the Hub
URL, view the Access Token, rotate it, and paste a Cursor mcpServers snippet.
Setup secrets (token plaintext, Rotate, and the secret-bearing snippet) are
visible only on loopback (127.0.0.1 / ::1).
Alternatively, set SERIAL_BRIDGE_TOKEN before starting the Hub and give the
same secret to the MCP client. The env var overrides the secrets file for that
process lifetime; Rotate still rewrites the file but warns until env is unset or
the Hub is restarted without it.
MCP authentication is required even from loopback. Do not put the token in source control, static frontend files, URLs, or logs.
The Hub listens on 0.0.0.0:8765, so it is reachable from the local network.
Use an appropriate host firewall and a strong token. Remote Agents cannot
change Port Bindings, and can switch a DUT's mode only through serial_set_mode
once the Operator granted Mode Switch Permission.
Related MCP server: coserial
MCP
Use Setup (/setup) on the Hub host for a copy-paste Cursor config and a
short Cursor rule ("Agent guide") that teaches the Agent the token-saving Exec
options below. Manual wiring:
Configure the Agent's Streamable HTTP MCP connection with:
URL: http://<hub-host>:8765/mcp
Authorization: Bearer <SERIAL_BRIDGE_TOKEN>Use /mcp exactly; the Web UI is at /. The MCP Server exposes:
serial_status: takes nodutand returns every DUT grouped:{duts: [{name, title, mode, mode_switch, ports}], config_warning?}.nameis the DUT Name,modeis that DUT'scrtorbridge, andportsholds that DUT's Targets keyed by Target Name (unique only within its DUT). Each Target reports its Port Binding, open state, busy hint, and current Session Log (logis the filesystem path on the Hub host;log_urlis a relative Bearer GET of that file from the same origin as/mcp). Emptylog/log_urlmeans none assigned. Last N lines areserial_tail, not Exec output. Do not pull the Session Log intoserial_execoutput. Each Target also reportsport_state(closed,open,lost),open_errorwhen the last open failed, andshell(readyorunknown) withshell_observed_at.shellis judged from that DUT's Operator-set Target Prompt (a regular expression, also shown read-only astarget_prompt) and isunknownwithout fresh evidence; the Hub never sends a probe.mode_switchis per DUT:{allowed, busy, busy_targets, next_action}, whereallowedreflects the Hub's single Mode Switch Permission andbusy/busy_targetscover only that DUT's Targets.serial_set_mode(dut, mode): switch one named DUT tocrtorbridge; other DUTs keep their mode and ports.dutis required and an unknown DUT is rejected with the list of DUT Names. Refused unless the Operator granted Mode Switch Permission in the Web UI (one permission per Hub, off by default, kept in memory only, so it is off again after every Hub restart), and refused while any Target of that DUT is busy (the result listsbusy_targetsand nothing is queued); an Exec on another DUT does not block the switch. Abridgeresult is{ok, mode, all_open, ports}; a failed port open is reported per port and never rolls back to CRT Mode. Port discovery and Port Binding editing stay with the Operator; there is no MCP tool for them. The tools below address a console bydut(DUT Name) andtarget(Target Name). Both are always required, even when the Hub has a single DUT, and a Target Name is unique only within its DUT, solinuxin two DUTs are different consoles. Successful results echo the Target Name anddut.serial_exec(dut, target, cmd, ...): send one text command and capture output until an idle gap, an optional prompt match, or the 60-second timeout. The device's Echo of the command and the matched prompt text are removed fromoutput; the Session Log keeps both. Options:prompt/prompt_is_regex: end early when the prompt appears.prompt_settle_ms(0–999, default 0) is a Settle Window: after the prompt matches, keep capturing until the device is quiet for that long, for consoles that print the prompt before the command's output.exit_code: true: Exit Code Probe for POSIX shell Targets. The Hub wraps the command so the shell prints$?behind a one-time token, removes that trailer, and reportsexit_code(an integer, ornullwhen the trailer never arrived and the Exec ended by idle). Cannot be combined withprompt; works withgrep.grep/grep_is_regex/grep_context: keep only matching lines (plus neighbors).grep_invert: truekeeps the non-matching lines instead;match_countis always the number of matching lines.grep_invertandgrep_contextare mutually exclusive.max_lines: keep only the last N lines after Grep;lines_droppedreports how many were cut.raw: true: Raw Capture. Addsraw_base64(the first 32 KiB of the unmodified capture window) andraw_truncated, independent of Grep andmax_lines.Result
statusis one ofcompleted(prompt or exit-code token arrived; a nonzeroexit_codeis stillcompleted),quiet,timeout,disconnected,aborted,error.quietandtimeoutonly end observation; they do not prove the command finished.
serial_send(dut, target, cmd, raw_hex): send a text line or Raw Payload without waiting for output.serial_tail(dut, target, n, with_timestamps): read one Target's lastnlines of the current Session Log (default 40, max 200); result{ok, dut, target, tail, n}. Each line is reduced to direction (<<<rx,>>>tx,---system) and text; passwith_timestamps: trueto prefixHH:MM:SS.mmm. The whole file remainslog_url.
To exercise status and Exec:
Open the Web UI locally and switch to Bridge Mode.
Connect the MCP client to the URL above with the Bearer header.
Call
serial_statuswith no arguments and confirm the intended DUT indutshasmodebridgeand its Target is open.Call
serial_execwith{"dut":"dut","target":"linux","cmd":"uname -a"}or{"dut":"dut","target":"rtos","cmd":"help"}. Use the DUT Name and Target Name fromserial_status(the Hub's initial DUT is nameddut).If the device has a stable prompt, optionally pass
prompt; setprompt_is_regextotrueonly when the prompt value is a regular expression.
Exec accepts a DUT Name and one of its Target Names (defaults linux and
rtos), not serial device names. The result is {ok, dut, target, output}; truncated, timed_out, and aborted appear only
when true, and error only on failure. ok means the capture finished
(prompt or idle), not that the remote command succeeded — use exit_code for
that on shell Targets. truncated is only the trailing 32KiB cap, not an
early prompt match. On Target linux, do not use a short shell prompt such as
# as prompt: a literal # matches comments and ends Exec early.
Exec output and the live/*.log transcripts are plain text with ANSI escapes
removed. The Web UI instead interprets the escapes and shows device colors.
The Agent Trace in the Web UI is kept per DUT: it lists that DUT's Exec,
Send, and Tail with the bytes each returned to the Agent, and its footer shows
that DUT's running total for this Hub session. The screen shows the focused
DUT's list. serial_status names no DUT and is not traced. Compare that total across the same device task
before and after changing how the Agent calls the tools.
Port Binding
A Port Binding assigns a Target to a serial device path and baud rate. A COM
port belongs to at most one Target on the Hub.
Built-in defaults describe the first DUT, named dut, and are Windows-style
(linux on COM3, rtos on COM6, both 115200); on Linux or macOS set paths such as /dev/ttyUSB0 instead.
Override defaults before startup with environment variables:
$env:SERIAL_BRIDGE_LINUX_PORT = "COM8"
$env:SERIAL_BRIDGE_LINUX_BAUD = "57600"
$env:SERIAL_BRIDGE_RTOS_PORT = "COM9"
$env:SERIAL_BRIDGE_RTOS_BAUD = "115200"
python -m serial_bridgeEquivalent CLI flags are --linux-port, --linux-baud, --rtos-port, and
--rtos-baud. These environment/CLI values overlay only the first DUT in the
persisted file's order. SERIAL_BRIDGE_CONFIG or --config selects the persisted JSON
file. The load order is built-in defaults, then environment/CLI values, then
the persisted file; saved Web UI values win.
The persisted config file holds an ordered duts array. Each entry has a
name (DUT Name), title, an ordered slots array, and that DUT's
target_prompts map (Target Name to regular expression), so Target Prompts are
saved nested under their DUT. A DUT's slots array of length 1 is valid and is
its Target count. Mode is not saved: every DUT starts in CRT Mode when the Hub
starts. A file that still has top-level slots or ports and no duts loads
as one DUT named dut, and a legacy top-level target_prompts map loads onto
the first DUT; the file is rewritten in the duts shape on the next save. In
CRT Mode the Operator may add a second Target to a DUT or remove one Target.
SERIAL_BRIDGE_RTOS_PORT, SERIAL_BRIDGE_RTOS_BAUD, --rtos-port, --rtos-baud,
SERIAL_BRIDGE_SLOT1_PORT, and SERIAL_BRIDGE_SLOT1_BAUD refer to Target Slot 1 of
the first DUT. When that DUT defines only one Slot, those env/CLI overrides fail startup; the
error states that the override refers to Target Slot 1 but only one Slot is configured.
Only the Operator can edit Port Bindings, and only while that DUT is in CRT Mode and the Hub has released its ports; other DUTs are unaffected.
The Web UI shows a tab strip with one tab per DUT; the focused DUT's Target panes and Agent Trace are on screen, and each browser page remembers its own focus. + Add DUT creates a DUT with a title and one or two Target bindings (only free COM ports are listed); a new DUT starts in CRT Mode, and its DUT Name is derived from its title. Remove DUT is available only while that DUT is in CRT Mode, and the last DUT cannot be removed. Removing a DUT drops its saved Target Prompts. The Web UI lists the detected serial ports in a dropdown per Target; use Scan to re-enumerate after plugging in an adapter. Changes made in the Web UI persist for restart.
Live Directory
The Live Directory is where the Hub writes per-Target Bridge session logs (one
Hub-wide directory shared by every DUT) and
bridge_status.json. The default is <app-dir>/live/ beside the project root
(same directory as serial_bridge.json and the root app.py shim).
Override before startup with:
$env:SERIAL_BRIDGE_LIVE_DIR = "D:\logs\serial-bridge"
python -m serial_bridgeOr pass --live-dir. Load order matches Port Binding: built-in default, then
environment/CLI, then the persisted config file; Web UI saves win.
Each time a DUT enters Bridge Mode, the Hub creates fresh log files for its
Targets named <DutName>-<TargetName>-YYYY-MM-DD-HHMMSS.log (local time,
24-hour clock). A second Bridge session creates new files; older logs are left in place and are not
migrated when you change the Live Directory or rename a DUT or Target.
Edit the Live Directory in the Web UI Bindings panel (same loopback-only write
path as Port Binding); it may change while a DUT is in Bridge Mode, each DUT
uses the new directory on its next entry into Bridge Mode, and a DUT already in
Bridge Mode keeps writing its current Session Log. The footer shows the configured
directory and current session log filenames when assigned. Click a current
Session Log filename to reveal it in the host file manager (Hub host /
loopback). Download the current file with
GET /api/session-log?dut=<DutName>&target=<TargetName> (loopback or
Authorization: Bearer, advertised as log_url on each Target in
serial_status). Click does not download.
Bridge Mode and CRT Mode
Mode belongs to each DUT, so one board can sit in SecureCRT while another stays in Bridge Mode.
Bridge Mode: the Hub owns that DUT's configured serial ports. The Operator and Agents can send commands and observe the same live transcripts.
CRT Mode: the Hub releases that DUT's ports for SecureCRT or another exclusive serial client. MCP Exec and Send for that DUT fail until it returns to Bridge Mode.
Disconnect SecureCRT before putting that DUT in Bridge Mode. Switching a DUT to
CRT Mode aborts its in-flight Exec and may return partial output; other DUTs are
not affected. An Agent can switch a named DUT with serial_set_mode only when
the Operator granted the Hub's Mode Switch Permission.
Raw Send warning
serial_send with raw_hex writes arbitrary bytes without text-line framing
or an automatic line ending. This is full console power: control bytes can
interrupt boot, terminate processes, alter device state, or make a session
unresponsive. Prefer serial_exec for commands, and use Raw Payloads only
when the exact byte sequence and device impact are understood.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Secure and manage MCP servers through the Speakeasy AI Control Plane from your agent.
Run and manage H Company's Computer-Use Agents from any MCP client.
MCP gateway and cloud hosting for MCP servers, agents and apps like RAG, managed from your agent.
Use a person's computer after they approve it there: files, Terminal, browser, local MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to control serial port devices (modems, instruments, embedded boards) via MCP tools for listing ports, connecting, and sending/receiving commands.31MIT
- AlicenseNot gradedqualityDmaintenanceEnables humans and AI agents to collaboratively control serial ports via MCP tools or Web UI, with real-time data sharing across all participants.MIT
- FlicenseNot gradedqualityBmaintenanceEnables secure remote management of the platform through nine MCP tools over STDIO and HTTP, including terminal execution, service controls, and live status monitoring.-
- AlicenseAqualityCmaintenanceEnables local UART and serial-port debugging through MCP, providing persistent capture, log search, regex/event monitoring, HEX send/query, protocol parsing, and shell-like command sequences.15MIT