Skip to main content
Glama
davidalo

serial-mcp

by davidalo
README.md
# ๐Ÿ”Œ serial-mcp

MCP server for serial port communication. Provides tools to open, read, write, and manage serial ports through the Model Context Protocol.

*๐Ÿค– Written by and for AI.*

## โœจ Features

- ๐Ÿ“‹ List available serial ports on the system
- โš™๏ธ Open ports with configurable baud rate, parity, stop bits, and flow control
- ๐Ÿ“– Read data by byte count, terminator character, or duration
- โœ๏ธ Write string or hex data
- ๐Ÿ’ฅ Send BREAK signals
- ๐Ÿ“Š Monitor port status and control line states

## ๐Ÿ“ฆ Prerequisites

- Python 3.10+
- [uv](https://docs.astral.sh/uv/getting-started/installation/) package manager

## ๐Ÿš€ Installation

### Via PyPI

```bash
uvx serial-mcp@latest
```

### Local Clone

```bash
git clone https://github.com/davidalo/serial-mcp.git
cd serial-mcp
uvx --from "$(pwd)" serial-mcp
```

## ๐Ÿ”— Integration

### Via PyPI

```bash
# Claude Code
claude mcp add serial -- uvx serial-mcp@latest

# Codex CLI
codex mcp add serial -- uvx serial-mcp@latest
```

### Local Clone

```bash
git clone https://github.com/davidalo/serial-mcp.git
cd serial-mcp

# Claude Code
claude mcp add serial -- uvx --from "$(pwd)" serial-mcp

# Codex CLI
codex mcp add serial -- uvx --from "$(pwd)" serial-mcp
```

## ๐Ÿ› ๏ธ Tools

| Tool | Description |
|------|-------------|
| `list_ports` | List available system serial ports |
| `open_port` | Open a serial port with configuration (baud rate, parity, stop bits, etc.) |
| `close_port` | Close an open port |
| `write_data` | Write string or hex data to a port |
| `read_bytes` | Read N bytes with timeout |
| `read_until` | Read until a terminator character |
| `read_for_duration` | Read continuously for N seconds |
| `send_break` | Send a BREAK signal |
| `get_port_status` | Get port status and control line states |
| `list_open_ports` | List all currently managed ports |

## ๐Ÿงช Testing with Virtual Ports

Use `socat` to create virtual serial port pairs for testing:

```bash
# Create virtual port pair
socat -d -d pty,raw,echo=0,link=/tmp/ttyV0 pty,raw,echo=0,link=/tmp/ttyV1
```

Then open `/tmp/ttyV0` with the MCP server and `/tmp/ttyV1` with another terminal program to test communication.

## ๐Ÿ“„ License

MIT

TDQS

A3.7/5.0

Scored across 10 tools

Disambiguation5/5

Each tool has a clearly distinct purpose. The three read functions (read_bytes, read_for_duration, read_until) are differentiated by reading mode, and all other tools serve unique roles in port management. No overlap.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case (e.g., close_port, list_open_ports, send_break). The naming is predictable and easy to interpret.

Tool Count5/5

10 tools is well-scoped for a serial port management server. The set covers opening, closing, reading (three variants), writing, status, port listing, and special signals without being excessive.

Completeness4/5

The tool set covers core serial operations (open/close, read/write, status, break signal). Minor gaps exist, such as buffer flushing or control line manipulation, but these are not critical for typical use.

Maintenance

ActivityInactive
ResponsivenessNo issues