Serial MCP Server
串口 MCP 服务器
一个用于串口通信的模型上下文协议 (MCP) 服务器,使 LLM 能够通过串口连接与硬件设备进行交互。
功能特性
列出可用串口
打开/关闭串口连接
向串口读写数据
控制串口信号 (DTR, RTS, CTS, DSR, DCD)
支持自定义波特率、数据位、停止位和校验位
支持 JSON 和 Markdown 输出格式
Related MCP server: UART MCP Server
安装
# Install from PyPI (when published)
pip install serial-mcp-new使用方法
运行服务器
# Run with stdio transport (default, for local use)
serial-mcp在 Claude Code 中配置
"mcpServers": {
"ssh-mcp": {
"command": "C:\\Users\\DELL\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\Scripts\\serial-mcp.exe",
"args": [],
"env": {}
}
},可用工具
工具 | 描述 |
| 列出所有可用串口 |
| 打开串口连接 |
| 关闭串口连接 |
| 向串口写入数据 |
| 从串口读取数据 |
| 设置控制信号状态 |
| 读取当前信号状态 |
| 列出所有活动连接 |
示例工作流
列出可用端口:
serial_list_ports()打开连接:
serial_open(port="COM3", baud_rate=115200)写入数据:
serial_write(connection_id="conn_1", data="Hello, device!")读取响应:
serial_read(connection_id="conn_1", timeout=2.0)完成后关闭:
serial_close(connection_id="conn_1")
依赖项
Python 3.10+
mcp >= 1.6.1
pyserial >= 3.5
pydantic >= 2.0.0
许可证
MIT
Available Tools
8 toolsserial_closeAIdempotent
Close a serial port connection.
Closes the specified serial port connection and releases resources. The connection ID becomes invalid after closing.
Args: params (ClosePortInput): Validated input parameters containing: - connection_id (str): Connection ID returned by serial_open
Returns: str: Success message or error message.
Success response: "Connection closed: conn_1" Error response: "Error: Connection 'conn_1' not found"
Inputs: params (required). Returns: result
serial_get_signalsARead-onlyIdempotent
Read the current state of serial port signals.
Returns the current state of all control signals including input signals (CTS, DSR, DCD) and output signals (DTR, RTS).
Args: params (GetSignalsInput): Validated input parameters containing: - connection_id (str): Connection ID returned by serial_open - response_format (ResponseFormat): Output format (default: 'markdown')
Returns: str: Formatted signal states or error message.
Success format for JSON: { "connection_id": "conn_1", "dtr": true, "rts": false, "cts": true, "dsr": true, "dcd": false }
Error response: "Error: Connection 'conn_1' not found or not open"
Inputs: params (required). Returns: result
serial_list_connectionsARead-onlyIdempotent
List all active serial port connections.
Returns information about all currently open serial port connections.
Args: params (ListConnectionsInput): Validated input parameters containing: - response_format (ResponseFormat): Output format (default: 'markdown')
Returns: str: Formatted list of connections or empty message.
Success format for JSON: [ { "id": "conn_1", "port": "COM3", "baud_rate": 9600, "path": "COM3", "is_open": true, "created_at": "2024-01-15T10:30:00Z" } ]
Error response: "No active connections"
Inputs: params (required). Returns: result
serial_list_portsARead-onlyIdempotent
List all available serial ports on the system.
This tool scans the system for available serial ports and returns detailed information about each port including device path, manufacturer, and serial number.
Args: params (ListPortsInput): Validated input parameters containing: - response_format (ResponseFormat): Output format (default: 'markdown')
Returns: str: Formatted list of serial ports.
Success response format: For JSON: Array of port objects with path, manufacturer, serialNumber, etc. For Markdown: Formatted list with port details
Error response: "Error: "
Inputs: params (required). Returns: result
serial_openADestructive
Open a serial port connection.
Opens a new serial port connection with specified parameters. Returns a connection ID that must be used for subsequent operations on this port.
Args: params (OpenPortInput): Validated input parameters containing: - port (str): Serial port path (e.g., 'COM3', '/dev/ttyUSB0') - baud_rate (int): Baud rate (default: 9600) - data_bits (int): Data bits, 5-8 (default: 8) - stop_bits (float): Stop bits, 1.0-2.0 (default: 1.0) - parity (str): Parity: 'N', 'E', or 'O' (default: 'N')
Returns: str: Connection ID or error message.
Success response: "Connection opened: conn_1" Error response: "Error: "
Inputs: params (required). Returns: result
serial_readARead-only
Read data from a serial port connection.
Reads available data from the serial port up to the specified maximum bytes. Times out after the specified timeout period if no data is available.
Args: params (ReadDataInput): Validated input parameters containing: - connection_id (str): Connection ID returned by serial_open - max_bytes (int): Maximum bytes to read (default: 1024, max: 65536) - timeout (float): Read timeout in seconds (default: 1.0) - encoding (str): Text encoding (default: 'utf-8') - response_format (ResponseFormat): Output format (default: 'markdown')
Returns: str: Formatted data or error message.
Success format for JSON: { "connection_id": "conn_1", "bytes_read": 42, "hex": "48656c6c6f", "data": "Hello", "timestamp": "2024-01-15T10:30:00Z" }
Error response: "Error: Connection 'conn_1' not found or not open"
Inputs: params (required). Returns: result
serial_set_signalsADestructive
Set control signal states on a serial port connection.
Sets the DTR (Data Terminal Ready) and/or RTS (Request To Send) control signals.
Args: params (SetSignalsInput): Validated input parameters containing: - connection_id (str): Connection ID returned by serial_open - dtr (Optional[bool]): DTR signal state (True=HIGH, False=LOW, None=unchanged) - rts (Optional[bool]): RTS signal state (True=HIGH, False=LOW, None=unchanged)
Returns: str: Success message or error message.
Success response: "Signals set on conn_1: DTR=HIGH, RTS=LOW" Error response: "Error: Connection 'conn_1' not found or not open"
Inputs: params (required). Returns: result
serial_writeADestructive
Write data to a serial port connection.
Writes the specified data string to the serial port using the specified encoding.
Args: params (WriteDataInput): Validated input parameters containing: - connection_id (str): Connection ID returned by serial_open - data (str): Data to write as a string - encoding (str): Text encoding (default: 'utf-8') - timeout (float): Write timeout in seconds (default: 5.0)
Returns: str: Success message with bytes written or error message.
Success response: "Wrote 12 bytes to conn_1" Error response: "Error: Connection 'conn_1' not found or not open"
Inputs: params (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct operation on serial ports: opening, closing, listing ports/connections, reading, writing, and getting/setting signals. There is no ambiguity between them.
All tools follow a consistent 'serial_verb' pattern (e.g., serial_open, serial_read, serial_write, serial_close, etc.), making it easy to predict tool names.
With 8 tools covering connection management, data I/O, and signal control, the count is well-scoped for a serial port server. No tool feels unnecessary or missing.
The toolset covers the core operations: open, close, list ports, list connections, read, write, get/set signals. A potential gap is flushing buffers or handling break conditions, but these are advanced and not essential.
Maintenance
Related MCP Connectors
PDF, image, video, OCR, screenshot, SQL, QR and text tools for agents. No API key, no signup.
Connect your AI to your own devices, 3D printers, factory tools and a shared agent task pool.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Access Pollinations models and API capabilities through agent tools.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to interact with physical serial port devices across platforms (Windows COM/Linux tty) with support for asynchronous communication, URC pattern recognition, and structured logging.1-
- AlicenseAqualityDmaintenanceEnables AI assistants to communicate with serial port devices, supporting port management, data transmission in text/binary modes, interactive terminal sessions, and automatic reconnection.1412MIT
- AlicenseAqualityCmaintenanceAllows AI agents to interact with serial devices via RS232/UART, enabling port listing, connection, read/write, control line manipulation, and protocol specification for automated debugging and testing.27118 PyPI27MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to communicate with UART/serial devices, offering tools for port management, data read/write, and protocol handling.1MIT