
Serial Mcp Server
io.github.es617由 GitHub 账号 es617 发布v0.1.3更新于 Oct 24, 2026
Let AI agents interact with serial devices — list ports, connect, send, and read.
概览
一个本地 MCP 服务器,让 AI 助手列出、打开、读写并控制本机上的真实串口设备。
- 可以做什么
- 列出串口,按可配置的波特率、校验位、停止位和编码打开或关闭连接,并查看连接状态或已打开的连接列表。以文本、十六进制或 base64 读写数据,支持 readline 和读到指定分隔符,并可清空输入输出缓冲区。设置或脉冲 DTR、RTS 控制线,用于硬件复位和进入引导模式。注册、附加、搜索和读取描述设备命令与报文格式的 Markdown 协议规范。加载和重载设备插件以增加高层快捷工具,并查看工具调用追踪。可将会话镜像到 PTY,让 screen、minicom 或脚本同时接入。
- 适用场景
- 适合嵌入式工程师、创客、测试与现场工程师,让助手与单片机等串口硬件对话:调试启动信息和提示符、迭代固件、执行可重复的复位加命令测试流程,或探索未知设备的协议。
- 运行要求
- 以 PyPI 包 serial-mcp-server 通过 stdio 在本地运行(用 pip 安装后注册 serial_mcp 命令)。需要 Python 和本机串口访问权限,支持 macOS、Windows 和 Linux。可选环境变量用于配置连接上限、插件策略、PTY 镜像、追踪和工具名分隔符。
安装
在 SourceWeft 中
- 打开 控制台中的 Serial Mcp Server,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Serial MCP Server
[MCP] [License: MIT] [Python] [Serial]
A stateful serial port Model Context Protocol (MCP) server for developer tooling and AI agents. Works out of the box with Claude Code, VS Code with Copilot, and any MCP-compatible runtime. Communicates over stdio and uses pyserial for cross-platform serial on macOS, Windows, and Linux.
Example: Let Claude Code list available serial ports, connect to your microcontroller, reset it via DTR, and read the boot banner from your hardware.
Demo
Video walkthrough — connecting to a serial device, sending commands, reading responses, and creating plugins.
Why this exists
If you’ve ever copy-pasted commands into screen or minicom, guessed baud rates, toggled DTR to kick a bootloader, and re-run the same test sequence 20 times — this is for you.
You have a serial device. You want an AI agent to talk to it — open a port, send commands, read responses, debug protocols. This server makes that possible.
It gives any MCP-compatible agent a full set of serial tools: listing ports, opening connections, reading, writing, line-oriented I/O, control line manipulation — plus protocol specs and device plugins, so the agent can reason about higher-level device behavior instead of just raw bytes.
The agent calls these tools, gets structured JSON back, and reasons about what to do next — without you manually typing commands into a terminal for every step.
What agents can do with it:
- Develop and debug — connect to your device, send commands, read responses, and diagnose issues conversationally (boot banners, prompts, error codes).
- Iterate on new firmware — attach a protocol spec so the agent understands your command set, boot modes, and output format as they evolve.
- Automate test flows — reset device via DTR, wait for prompt, run a command sequence, validate output.
- Explore unknown devices — probe command sets, discover prompts, infer message formats.
- Build serial automation — long-running test rigs, manufacturing bring-up, CI hardware smoke tests.
Who is this for?
- Embedded engineers — faster iteration on serial protocols, conversational debugging, automated test sequences
- Hobbyists and makers — interact with serial devices without writing boilerplate; let the agent help reverse-engineer simple protocols
- QA and test engineers — build repeatable serial test suites with plugin tools
- Support and field engineers — diagnose serial device issues interactively without specialized tooling
- Researchers — automate data collection from serial devices, explore device capabilities systematically
Quickstart (Claude Code)
Then in Claude Code, try:
"List available serial ports and connect to the one on /dev/ttyUSB0 at 115200 baud."
What the agent can do
Once connected, the agent has full serial capabilities:
- List ports to find available serial devices
- Open and close connections with configurable baud rate, parity, stop bits, and encoding
- Read and write data in text, hex, or base64 format
- Line-oriented I/O — readline and read-until-delimiter for text protocols
- Control lines — set or pulse DTR and RTS for hardware reset and boot mode entry
- Flush input and output buffers
- Attach protocol specs to understand device-specific commands and data formats
- Use plugins for high-level device operations instead of raw reads/writes
- Create specs and plugins for new devices so future sessions start "knowing" your protocol
- PTY mirroring — attach screen, minicom, or custom scripts to the same serial session the agent is using
The agent can coordinate multi-step flows automatically — e.g., toggle reset, wait for prompt, send init sequence, stream output.
At a high level:
Raw Serial → Protocol Spec → Plugin
You can start with raw serial tools, then move up the stack as your device protocol becomes understood and repeatable.
Install (development)
MCP is a protocol — this server works with any MCP-compatible client. Below are setup instructions for the most common ones.
Add to Claude Code
Add to VS Code / Copilot
Add to your project's .vscode/mcp.json (or create it):
Adjust env to match your needs — set SERIAL_MCP_PLUGINS to specific plugin names, or add SERIAL_MCP_MIRROR for PTY mirroring.
Add to Cursor
Add to your project's .cursor/mcp.json (or create it). Cursor does not support dots in tool names, so SERIAL_MCP_TOOL_SEPARATOR must be set to _:
Environment variables
Tools
Protocol Specs
Specs are markdown files that describe a serial device's protocol — connection settings, message format, commands, and multi-step flows. They live in .serial_mcp/specs/ and teach the agent what the byte stream means.
Without a spec, the agent can still open a port and exchange data. With a spec, it knows what commands to send, what responses to expect, and what the data means.
You can create specs by telling the agent about your device — paste a datasheet, describe the protocol, or just let it explore and document what it finds. The agent generates the spec file, registers it, and references it in future sessions. You can also write specs by hand.
Plugins
Plugins add device-specific shortcut tools to the server. Instead of the agent composing raw read/write sequences, a plugin provides high-level operations like mydevice.read_temp or ota.upload_firmware.
The agent can also generate Python plugins (with your approval). It explores a device, writes a plugin based on what it learns, and future sessions get shortcut tools — no manual coding required.
To enable plugins:
Editing an already-loaded plugin only requires serial.plugin.reload — no restart needed.
Tracing
Every tool call is traced to .serial_mcp/traces/trace.jsonl and an in-memory ring buffer (last 2000 events). Tracing is on by default — set SERIAL_MCP_TRACE=0 to disable.
Event format
Two events per tool call:
connection_idis extracted from args when present- Write
datais stripped from traced args by default (enable withSERIAL_MCP_TRACE_PAYLOADS=1)
Inspecting the trace
Use serial.trace.status to check config and event count, and serial.trace.tail to retrieve recent events — no need to read the file directly.
PTY Mirror
When the MCP server owns a serial port, most OSes prevent any other process from opening it. PTY mirroring creates a virtual clone port that external tools (screen, minicom, logic analyzers, custom scripts) can connect to simultaneously.
Platform: macOS and Linux only. On Windows, setting SERIAL_MCP_MIRROR to ro/rw logs a warning and is silently ignored.
Try without an agent
You can test the server interactively using the MCP Inspector — no Claude or other agent needed:
Open the URL with the auth token from the terminal output. The Inspector gives you a web UI to call any tool and see responses in real time.
Known limitations
- Single-client only. The server handles one MCP session at a time (stdio transport). Multi-client transports (HTTP/SSE) may be added later.
- Exclusive access. Without PTY mirroring, the MCP server must own the serial port exclusively.
Safety
This server connects an AI agent to real hardware. That's the point — and it means the stakes are higher than pure-software tools.
Plugins execute arbitrary code. When plugins are enabled, the agent can create and run Python code on your machine with full server privileges. Review agent-generated plugins before loading them. Use SERIAL_MCP_PLUGINS=name1,name2 to allow only specific plugins rather than all.
Writes affect real devices. A bad command sent to a serial device can trigger unintended behavior, disrupt other connected systems, or cause hardware damage (e.g., wiping flash, entering bootloader mode, triggering actuators). Consider what the agent can reach.
Use tool approval deliberately. When your MCP client prompts you to approve a tool call, consider whether you want to allow it once or always. "Always allow" is convenient but means the agent can repeat that action without further confirmation.
This software is provided as-is under the MIT License. You are responsible for what the agent does with your hardware.
License
This project is licensed under the MIT License — see LICENSE for details.
Acknowledgements
This project is built on top of the excellent pyserial library for cross-platform serial communication in Python.
来源:README.md,提交 b940b84
工具
0版本历史
1- v0.1.3最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分