opcua2mcp
Converts OPC UA sensor data into MCP-compatible tools and exposes machine health via both HTTP and MCP.
README
OPCUA2MCP IIoT Bridge
This repository provides an end-to-end Industrial IoT prototype that converts OPC UA sensor data into MCP-compatible tools and exposes machine health via both HTTP and MCP.

What is opcua2mcp?
opcua2mcp is the core bridge module in src/opcua2mcp.py.
It connects to an OPC UA server, reads sensor values defined in YAML configuration, evaluates sensor health against configurable thresholds, caches readings, and publishes the results through a FastMCP server.
The design is ideal for IIoT deployments that need:
- OPC UA data ingestion from equipment simulators or real PLCs
- MCP tool exposure for model context interoperability
- machine health scoring and alert generation
- optional Redis caching for faster repeated reads
Architecture
app/app.py— start-up script that loadsapp/config.yaml, reads environment variables, and launches the converter.src/opcua2mcp.py— core converter implementation that builds the MCP server and sensor health logic.app/opcua_simulator.py— OPC UA simulator that can be configured from YAML and serves variable sensor values.docker-compose.yml— orchestrates the OPC UA simulator, two machine-specific converter containers, and Redis.
Configuration
The OPC UA simulator and sensor definitions are stored in app/config.yaml.
Example structure:
server:
endpoint: opc.tcp://0.0.0.0:4840
namespace: http://opcua.simulator
update_interval: 2
machines:
Machine-001:
vibration:
node_id: ns=2;s=Machine-001/Device/Vibration
unit: mm/s
threshold: 3.5
initial_value: 2.2
min: 0.5
max: 5.0
step: 0.25
randomize: true
temperature:
node_id: ns=2;s=Machine-001/Device/Temperature
unit: C
threshold: 80.0
initial_value: 68.0
min: 50.0
max: 92.0
step: 1.5
randomize: true
Each machine has named sensors with:
node_idor generated node identifierunitthresholdfor health evaluation- optional simulation parameters:
initial_value,min,max,step,randomize
Running the stack
Install dependencies:
pip install -r requirements.txt
Run with Docker Compose:
docker compose up --build
This brings up:
opcua-simulatorexposing OPC UA on4840opcua2mcp_001exposing MCP and HTTP on5011opcua2mcp_002exposing MCP and HTTP on5021redisfor cache storage
Environment variables
app/app.py supports the following environment variables:
MACHINE_NAME— machine name from YAML config (Machine-001,Machine-002)OPCUA_ENDPOINT— OPC UA server URLCACHE_BACKEND—memoryorredisREDIS_URL— Redis connection URLCACHE_TTL— seconds to keep cached sensor resultsMCP_PORT— internal HTTP/MCP service portOPCUA_CONFIG— path to the YAML config file
API Reference
MCP Exposure
src/opcua2mcp.py registers two MCP tools via FastMCP:
-
health.check- title: Machine Health Check
- returns current machine health, score, alerts, and sensor readings
-
read.sensors- title: Read All Sensors
- returns the latest sensor values for the configured machine
These tools are available through the MCP /mcp endpoint supported by FastMCP.
HTTP Routes
In addition to the MCP tools, opcua2mcp exposes three HTTP endpoints on the same service port:
-
GET /health- returns the current health status for the machine
- fields include:
machine_name,status,health_score,alerts,total_sensors,sensor_readings,timestamp
-
GET /sensors- returns latest sensor values and status for every configured sensor
- this forces a fresh read from OPC UA before replying
-
GET /cache- returns the current cache contents
- includes cached sensor readings stored in memory or Redis
Example HTTP usage
curl http://localhost:5011/health
curl http://localhost:5011/sensors
curl http://localhost:5011/cache
Why opcua2mcp?
This bridge is designed to sponsor MCP adoption by demonstrating a real IIoT use case:
- converting OPC UA telemetry into MCP tool semantics
- evaluating machine health automatically
- exposing both standard HTTP and MCP-compatible interfaces
- enabling multi-machine deployments with one YAML-driven config
Extending the bridge
You can extend src/opcua2mcp.py by:
- adding new MCP tools for individual sensor reads
- enriching health logic with custom scoring rules
- adding additional OPC UA namespaces or node discovery
- supporting more machine types in
app/config.yaml
Important files
src/opcua2mcp.py— main converter and MCP server definitionapp/app.py— launch script and environment-driven startupapp/opcua_simulator.py— OPC UA simulator serviceapp/config.yaml— sensor and simulator configurationdocker-compose.yml— multi-service orchestration
Notes
The MCP bridge uses FastMCP from the official mcp package, and the simulator uses opcua to host realistic sensor variables.
For development, run the stack locally and inspect the /health, /sensors, and /cache endpoints for immediate visibility into the OPC UA → MCP workflow.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。