File transfer protocols: - XMODEM: 128/1024-byte blocks with checksum or CRC-16 - YMODEM: Batch transfers with file metadata in block 0 - ZMODEM: Streaming protocol with auto-resume capability Security and robustness fixes: - Atomic file creation (O_CREAT|O_EXCL) prevents TOCTOU races - Transfer size limits (100MB default) prevent memory exhaustion - Byte range validation (0-255) with clear error messages - 4GB overflow handling for ZMODEM position encoding - CRC-32 table initialized at module load for thread safety - Timeout enforcement prevents indefinite hangs Server enhancements: - file_transfer_send/receive/send_batch tools - atexit cleanup for open connections - Thread-safety documentation for _connections registry
MCP Serial Server
FastMCP server for serial port access via Model Context Protocol.
Features
- Tools for serial port control (open, close, write, configure)
- Dynamic Resources for reading data (
serial://{port}/data) - Full pyserial support (baudrate, parity, stop bits, etc.)
- Multiple concurrent port connections
- Raw byte and text modes
Installation
# With uvx (recommended)
uvx mcserial
# Or install directly
uv pip install mcserial
Usage with Claude Code
# Add to Claude Code
claude mcp add mcserial "uvx mcserial"
Tools
| Tool | Description |
|---|---|
list_serial_ports |
Discover available serial ports |
open_serial_port |
Open a connection with config |
close_serial_port |
Close a connection |
write_serial |
Send text data |
write_serial_bytes |
Send raw bytes |
read_serial |
Read available data |
read_serial_line |
Read until newline |
configure_serial |
Change port settings |
flush_serial |
Clear buffers |
get_connection_status |
List open connections |
Resources
| URI | Description |
|---|---|
serial://ports |
List available ports |
serial://{port}/data |
Read data from open port |
serial://{port}/status |
Port configuration info |
serial://{port}/raw |
Read as hex dump |
Environment Variables
| Variable | Default | Description |
|---|---|---|
MCSERIAL_DEFAULT_BAUDRATE |
9600 | Default baud rate |
MCSERIAL_DEFAULT_TIMEOUT |
1.0 | Read timeout (seconds) |
MCSERIAL_MAX_CONNECTIONS |
10 | Max concurrent ports |
Example Workflow
1. list_serial_ports → find /dev/ttyUSB0
2. open_serial_port(port="/dev/ttyUSB0", baudrate=115200)
3. write_serial(port="/dev/ttyUSB0", data="AT\r\n")
4. Read resource: serial:///dev/ttyUSB0/data
5. close_serial_port(port="/dev/ttyUSB0")
License
MIT
Description
Languages
Python
100%