工业MCP协议实现

开源工业MCP协议实现,为工业设备与AI模型提供标准化接口,支持多协议通信和边缘计算。

  • by xiao98
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 xiao98/industrial-mcp

使用说明

🏭 EDGEAI MCP

The Open-Source Bridge Between AI and Industrial Equipment

Features • Quick Start • Protocols • Docs • Contributing


🌟 什么是工业MCP?

工业MCP 是一个开源项目,实现 模型上下文协议(MCP) 对于工业环境。它允许任何AI模型(Claude、GPT、Mistral、Llama等) 从以下位置读取数据 和 控制 通过标准化接口连接工业设备。

将其视为工业AI的USB-C --一个通用连接器,适用于所有机器。

我们解决的问题

❌ Traditional Approach:
   AI Model ←→ Custom API 1 ←→ Machine 1 (Modbus)
   AI Model ←→ Custom API 2 ←→ Machine 2 (OPC UA)  
   AI Model ←→ Custom API 3 ←→ Machine 3 (MQTT)
   = N×M integration nightmare 😱

✅ With Industrial MCP:
   AI Model ←→ MCP Protocol ←→ Industrial MCP Server ←→ Any Machine
   = One standard interface for everything 🎉

✨ 特性

特性 描述
🔌 多协议支持 Modbus TCP/RTU、OPC UA、MQTT、S7(西门子)
🤖 AI就绪 与克劳德、ChatGPT、米斯特拉尔、当地法学硕士合作
📍 边缘优先 可在Raspberry Pi、Jetson、任何Linux设备上运行
🔒 数据主权 所有处理都在本地进行,不需要云
🇪🇺 符合GDPR 数据永远不会离开你的工厂
💬 自然语言 用通俗易懂的语言与你的机器交谈
📊 内置监控 实时仪表板和警报
🔧 可扩展 使用简单的Python插件添加自定义协议

🚀 快速开始

安装

# Clone the repository
git clone https://github.com/YOUR_USERNAME/industrial-mcp.git
cd industrial-mcp

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .

基本用法

from industrial_mcp import MCPServer, ModbusAdapter

# Create MCP server
server = MCPServer(name="my-factory")

# Connect to a Modbus device (e.g., a pump)
pump = ModbusAdapter(
    host="192.168.1.100",
    port=502,
    device_name="pump-01"
)

# Register the device
server.register_device(pump)

# Define tools that AI can use
@server.tool("get_pump_status")
async def get_pump_status():
    """Get the current status of the main pump"""
    temp = await pump.read_register(address=100)
    vibration = await pump.read_register(address=101)
    return {
        "temperature": temp,
        "vibration": vibration,
        "status": "normal" if vibration < 50 else "warning"
    }

# Start the MCP server
server.run(host="0.0.0.0", port=8080)

与克劳德桌面连接

添加到您的Claude桌面配置(claude_desktop_config.json):

{
  "mcpServers": {
    "industrial": {
      "command": "python",
      "args": ["-m", "industrial_mcp", "--config", "config.yaml"]
    }
  }
}

现在你可以问克劳德:

“01号泵的温度是多少?”
“振动水平正常吗?”
“显示所有连接设备的状态。”


📡 支持的协议

协议 状态 用例
MODBUS TCP协议 ✅ 稳定 PLC、传感器、仪表
Modbus RTU ✅ 稳定 串行设备,RS-485
OPC 统一架构 ✅ 稳定 现代工业体系
消息队列遥测传输 ✅ 稳定 物联网传感器、轻量级设备
西门子S7 🔄 Beta 西门子可编程逻辑控制器(S7-300/400/1200/1500)
BACnet 📋 计划 楼宇自动化
以太网/工业协议 📋 计划中 艾伦·布拉德利,罗克韦尔

🏗️ 建筑

┌─────────────────────────────────────────────────────────────┐
│                     YOUR FACTORY                            │
│                                                             │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐     │
│  │ Machine 1│  │ Machine 2│  │ Machine 3│  │ Sensor N │     │
│  │ (Modbus) │  │ (OPC UA) │  │  (MQTT)  │  │ (Modbus) │     │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └────┬─────┘     │
│       │             │             │             │           │
│       └─────────────┴──────┬──────┴─────────────┘           │
│                            │                                │
│                   ┌────────▼────────┐                       │
│                   │  INDUSTRIAL MCP │                       │
│                   │     SERVER      │  ← Runs on Edge       │
│                   │  ┌────────────┐ │                       │
│                   │  │  Adapters  │ │                       │
│                   │  │  ┌──────┐  │ │                       │
│                   │  │  │Modbus│  │ │                       │
│                   │  │  │OPC UA│  │ │                       │
│                   │  │  │ MQTT │  │ │                       │
│                   │  │  └──────┘  │ │                       │
│                   │  └────────────┘ │                       │
│                   │  ┌────────────┐ │                       │
│                   │  │ MCP Server │ │                       │
│                   │  └────────────┘ │                       │
│                   └────────┬────────┘                       │
│                            │                                │
└────────────────────────────┼────────────────────────────────┘
                             │ MCP Protocol (JSON-RPC)
                             ▼
                   ┌─────────────────┐
                   │    AI CLIENT    │
                   │  Claude / GPT   │
                   │  Local LLM      │
                   └─────────────────┘

💡 用例

🔧 预测性维护

@server.tool("analyze_vibration_pattern")
async def analyze_vibration():
    """Compare current vibration with historical failure patterns"""
    current = await pump.read_vibration()
    historical = await db.get_failure_patterns()
    similarity = calculate_similarity(current, historical)
    return {
        "similarity_to_failure": f"{similarity}%",
        "recommendation": "Schedule inspection" if similarity > 80 else "Normal"
    }

📊 实时监控

@server.tool("get_production_status")
async def get_production():
    """Get real-time production line status"""
    return {
        "units_produced": await plc.read("production_count"),
        "efficiency": await calculate_oee(),
        "downtime_minutes": await get_downtime()
    }

🚨 异常检测

@server.tool("check_anomalies")
async def check_anomalies():
    """Detect anomalies across all connected devices"""
    anomalies = []
    for device in server.devices:
        if await device.is_anomalous():
            anomalies.append(device.name)
    return {"anomalies": anomalies, "count": len(anomalies)}

🖥️ 边缘部署

树莓派4/5

# Install on Raspberry Pi
curl -sSL https://get.industrial-mcp.io | bash

# Or manually
pip install industrial-mcp[raspberry]

英伟达杰森

# Optimized for Jetson with local LLM support
pip install industrial-mcp[jetson]

码头工人

docker run -d \
  --name industrial-mcp \
  -p 8080:8080 \
  -v ./config.yaml:/app/config.yaml \
  industrialmcp/server:latest

📖 文档

文档 描述
入门指南 工业MCP的第一步
配置 YAML配置参考
适配器指南 如何使用协议适配器
自定义适配器 编写自己的适配器
安全 身份验证和加密
API 参考 完整的API文件

🤝 贡献

我们欢迎捐款!看 贡献.md 作为指导方针。

开发设置

# Clone and install dev dependencies
git clone https://github.com/YOUR_USERNAME/industrial-mcp.git
cd industrial-mcp
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
ruff check .

路线图

  • [x] Modbus TCP/RTU适配器
  • [x] OPC UA适配器
  • [x] MQTT适配器
  • [x] 基本MCP服务器
  • []西门子S7适配器(进行中)
  • []Web仪表板
  • []本地LLM整合(Ollama)
  • []异常检测ML模型
  • []ATEX认证支持

🌍 社区


📜 许可证

该项目根据 Apache许可证2.0 -看看 许可证 文件以获取详细信息。


🏢 企业版

您的企业需要更多功能吗?

特性 开源 企业
核心MCP服务器 ✅ ✅
Modbus/OPC UA/MQTT ✅ ✅
社区支持 ✅ ✅
多站点管理 ❌ ✅
高级分析仪表板 ❌ ✅
优先级支持(SLA) ❌ ✅
CE/ATEX认证套件 ❌ ✅
自定义协议开发 ❌ ✅

📧 联系人:enterprise@industrial-mcp.io


Made with ❤️ in France 🇫🇷

Part of the La French Tech ecosystem