mcp-rs232
暴露RS232串行端口连接的MCP服务器
  
mcp名称:io.github.daedalus/mcp-rs232
安装
pip install mcp-rs232用法
from mcp_rs232 import list_ports, open_port, close_port, read_port, write_port
# List available ports
ports = list_ports()
print(ports)
# Open a port
open_port("COM1", baud_rate=9600)
# Write data (hex encoded)
write_port("COM1", "48656c6c6f") # "Hello"
# Read data (returns hex encoded)
data = read_port("COM1")
# Close the port
close_port("COM1")命令行界面
mcp-rs232 --helpAPI
资源
serial://ports-列出所有可用串行端口及其详细信息serial://port/{port_name}-获取特定端口的详细信息
工具
list_ports_tool()-返回可用串行端口列表open_port(port, baud_rate, ...)-打开串行连接close_port(port)-关闭串行连接read_port(port, size, timeout)-从端口读取数据(十六进制编码)write_port(port, data)-将十六进制编码的数据写入端口get_port_config(port)-返回当前端口配置
发展
git clone https://github.com/daedalus/mcp-rs232.git
cd mcp-rs232
pip install -e ".[test]"
# run tests
pytest
# format
ruff format src/ tests/
# lint
ruff check src/ tests/
# type check
mypy src/