Skip to main content
Glama

MCP Serial Port Tool

by niusulong

MCP串口工具 (MCP Serial Port Tool)

基于MCP(Model Context Protocol)协议的串口工具,为AI助手提供与物理串口设备交互的能力。

功能特性

  • 🔄 基于MCP协议的标准化接口

  • 🔌 跨平台串口支持(Windows COM / Linux tty)

  • ⚡ 异步事件驱动架构

  • 🔒 写入互斥锁保证数据完整性

  • 🎯 配置化URC识别与过滤

  • 📊 结构化日志与健康检查

  • 🧪 完整的测试覆盖

快速开始

安装依赖

npm install

开发模式

npm run dev

构建项目

npm run build

运行测试

npm test

项目结构

mcp2serial/ ├── src/ # 源代码 │ ├── core/ # 核心引擎层 │ ├── adapters/ # 硬件适配层 │ ├── services/ # 业务服务层 │ ├── mcp/ # MCP协议层 │ ├── utils/ # 工具模块 │ └── types/ # 类型定义 ├── config/ # 配置文件 ├── tests/ # 测试代码 ├── docs/ # 文档 └── examples/ # 示例配置

API接口

串口操作

  • serial.open - 打开串口

  • serial.close - 关闭串口

  • serial.write - 写入数据并读取响应

  • serial.list - 获取可用串口列表

  • serial.status - 查询串口状态

通知

  • serial.report - 异步事件通知(URC、错误、状态变化)

健康检查

  • health.status - 获取系统健康状态

  • health.metrics - 获取性能指标

日志

  • trace.get_log - 获取日志记录

配置说明

主要配置文件位于 config/ 目录:

  • default.yaml - 默认配置

  • urc-patterns.yaml - URC模式配置

详细配置说明请参考 配置文档

开发指南

代码规范

项目使用ESLint和TypeScript严格模式,请确保代码符合规范:

npm run lint npm run lint:fix

测试

# 运行所有测试 npm test # 监视模式 npm run test:watch # 覆盖率报告 npm run test:coverage

许可证

MIT License

贡献

欢迎提交Issue和Pull Request!

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/niusulong/mcp2serial'

If you have feedback or need assistance with the MCP directory API, please join our Discord server