mcp-serial
mcp-serial lets you interact with microcontrollers over a serial connection — list ports, open sessions, send commands, read/filter output, and flash STM32/ESP32 firmware with safety guards.
List serial ports with description, hardware ID, VID/PID, and open-session status (
list_ports).Open a port (or pyserial URL like
loop://) and capture lines in the background (open_port).Close a port and stop capturing (
close_port).Send a command/line to the firmware's CLI (
write_line).Page through captured output with sequence numbers, regex grep, and optional wait for fresh data (
read_lines).Clear/strop the capture buffer (
clear_buffer).Flash a
.binto an STM32 via ST-Link and reset it, requiringconfirm=true(flash_stm32).Flash a
.binto an ESP32-family chip with esptool, closing any open session first, requiringconfirm=true(flash_esp32).Reset the connected STM32 target via ST-Link (
reset_stm32).Probe the connected ST-Link target (chip ID, flash and SRAM size) (
probe_stlink).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-serial list serial ports, open the Nucleo at 115200, and show boot errors"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-serial
An MCP server that lets Claude, Cursor, or any MCP client work with your microcontroller the way you do at a serial console: list ports, open a session, send commands, read and filter the output, and flash firmware to STM32 or ESP32 boards. Flashing is gated behind an explicit confirm=true and an allow-listed firmware directory, so the assistant can't overwrite a board by accident.
you: "Flash build/app.bin to the Nucleo, then tell me if the sensor init logs any errors."
claude: flash_stm32(firmware_path="build/app.bin", confirm=true) -> flashed, reset
open_port("/dev/cu.usbmodem1103", 115200)
read_lines(port=..., grep="error|fail", wait_seconds=5) -> 0 matches
"Flashed and reset. 1,214 lines in 5 s, no errors; IMU and BMP280 both report OK."Install
uv tool install mcp-serial # or: pipx install mcp-serialClaude Code:
claude mcp add mcp-serial -e MCP_SERIAL_ALLOWED_DIR=$PWD -- mcp-serialClaude Desktop / other clients (claude_desktop_config.json):
{
"mcpServers": {
"mcp-serial": {
"command": "mcp-serial",
"env": { "MCP_SERIAL_ALLOWED_DIR": "/path/to/your/firmware/project" }
}
}
}Flashing uses whatever you already have installed: st-flash/st-info (stlink) for STM32, esptool for ESP32.
Related MCP server: serial-mcp
Tools
Tool | What it does |
| Serial ports with description, hwid, VID/PID, and whether a session is open |
| Open a port (or a pyserial URL like |
| Stop capturing and release the port |
| Send a command to the firmware's CLI |
| Page through captured output with sequence numbers, a regex filter, and an optional short wait for new data |
| Drop the capture buffer |
|
|
|
|
|
|
|
|
Example session

examples/session.py drives the server as a real MCP client over stdio, using pyserial's loop:// so it runs without hardware:
tools: list_ports, open_port, close_port, write_line, read_lines, clear_buffer, flash_stm32, flash_esp32, reset_stm32, probe_stlink
> open_port {"port": "loop://", "baud": 115200, "already_open": false}
> write_line {"port": "loop://", "bytes_written": 7} # "status"
> write_line {"port": "loop://", "bytes_written": 22} # "ERR: imu init timeout"
> read_lines (grep=ERR)
{"port": "loop://", "last_seq": 2, "count": 1,
"lines": [{"seq": 2, "t": 1792127056.6, "text": "ERR: imu init timeout"}]}
> flash_stm32 without confirm
{"flashed": false, "reason": "set confirm=true to flash; this overwrites the firmware on the board"}
> close_port {"port": "loop://", "closed": true, "lines_captured": 2}Safety model
Flash tools refuse unless
confirm=trueis passed, so the client has to state the intent explicitly.Firmware paths must resolve inside
MCP_SERIAL_ALLOWED_DIR(default: the server's working directory).External tools run with argument lists, never through a shell; addresses and chip names are validated.
Output is captured in a bounded ring buffer (
MCP_SERIAL_MAX_LINES, default 10,000) so a chatty board can't exhaust memory.
Environment
Variable | Default | Meaning |
| cwd | Directory firmware files must live under |
|
| Default baud for |
|
| Capture buffer size per port |
Development
uv venv && uv pip install -e ".[dev]" && pytest -qThe tests use pyserial's loop:// loopback, so they run without hardware.
License
MIT © Fady Youssef
Available Tools
10 toolsclear_bufferB
Drop all captured lines for a port; sequence numbers keep increasing.
Inputs: port (required). Returns: object
close_portA
Close a port opened with open_port and stop capturing.
Inputs: port (required). Returns: object
flash_esp32A
Flash a .bin to an ESP32-family chip with esptool; closes any open session on the port first. Requires confirm=true.
Inputs: port (required), firmware_path (required), baud, chip, +2 more. Returns: object
flash_stm32A
Flash a .bin to an STM32 over ST-Link with st-flash, then reset the target. Requires confirm=true.
Inputs: firmware_path (required), address, confirm. Returns: object
list_portsA
List serial ports with description, hardware id, VID/PID, and whether this server has them open.
Inputs: no named parameters. Returns: result
open_portB
Open a serial port (or a pyserial URL such as loop://) and start capturing lines in the background.
Inputs: port (required), baud. Returns: object
probe_stlinkA
Show the connected ST-Link target: chip id, flash and SRAM size (st-info --probe).
Inputs: no named parameters. Returns: object
read_linesB
Return captured lines (oldest first, newest last) with sequence numbers.
Use after_seq to fetch only output newer than your last read, grep for a regex filter (e.g. "error|warn"), and wait_seconds to block briefly for fresh output after a command.
Inputs: port (required), grep, after_seq, max_lines, +1 more. Returns: object
reset_stm32B
Reset the connected STM32 target through ST-Link (st-flash reset).
Inputs: no named parameters. Returns: object
write_lineB
Send text plus a newline to an open port, e.g. a command for the firmware's CLI.
Inputs: port (required), text (required), newline. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool maps to a distinct resource+action: port discovery (list_ports), ST-Link probing (probe_stlink), session control (open/close_port), I/O (write_line/read_lines/clear_buffer), and flashing/reset. The only minor overlap is reset_stm32 versus flash_stm32, which also resets the target, but descriptions keep them separable.
All names are snake_case with a leading verb (list_ports, open_port, read_lines, flash_esp32, reset_stm32), a consistent verb_noun pattern. The nouns shift between resources (port, buffer) and platform targets (stlink, stm32, esp32), which is a slight deviation but still predictable.
Ten tools is well within the ideal 3-15 range and each earns its place: discovery, session lifecycle, textual I/O, buffer management, and per-platform flashing/reset. No redundant or filler tools.
The surface covers the full serial workflow (list, open, read, write, clear, close) plus ST-Link/STM32/ESP32 flashing and STM32 probing/reset. Minor asymmetry: there is a flash_esp32 and reset_stm32 but no reset_esp32, and no way to send bytes without a newline.
Maintenance
Related MCP Connectors
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceMCP server for serial ports — non-blocking reads, DTR/RTS, streaming subscriptions, port allowlist.21MIT
- FlicenseAqualityDmaintenanceMCP server for serial port communication. Provides tools to open, read, write, and manage serial ports through the Model Context Protocol.10-
- 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