digital-twin-mcp
digital-twin-mcp
把数字孪生场景中的设备数据能力打包成 MCP 工具——任何 MCP 客户端(WorkBuddy、Claude Desktop、Cursor 等)都能直接查询设备状态、读取实时指标、拉取时序数据、检查告警。
数字管道的建筑师 · 第二块积木:设备监控管道 第一块积木:https://github.com/xici001/workflow-templates(AI 自动化工作流模板)
效果预览
3D 工厂渲染(factory-twin-viz 消费本服务的 get_scene_snapshot):

Related MCP server: mcp-live-telemetry
它能做什么
工具 | 说明 |
| 列出场景内所有设备(类型 / 位置) |
| 读取设备实时指标(模拟 PLC 轮询) |
| 读取某指标最近时序数据(供趋势图 / 3D 可视化) |
| 写入设备参数(模拟 PLC 写值 / 故障注入测试) |
| 阈值告警检查(warning / critical 分级) |
资源 | 说明 |
| 设备台账:元数据 + 指标量程与告警阈值 |
| 3D 场景布局:设备世界坐标(Three.js / Unity 直接叠加) |
提示词 | 说明 |
| 生成指定设备的健康报告 |
架构
MCP 客户端(WorkBuddy / Claude Desktop / ...)
│ stdio 或 streamable-http
┌───────▼───────────────┐
│ server.py (FastMCP) │ ← 工具 / 资源 / 提示词定义
└───────┬───────────────┘
│
┌───────▼───────────────┐
│ alerts.py │ 告警规则引擎(阈值分级)
│ device_registry.py │ 设备台账 + 指标配置 + 3D 坐标
│ simulator.py │ PLC 数据驱动(BasePLCDriver 接口)
└───────────────────────┘v0 数据源为模拟 PLC 驱动(固定随机种子、可复现;注塑机温度故意贴近阈值上漂,方便演示告警升级)。
接真实设备时继承
BasePLCDriver实现read_metrics/write_value(OPC-UA / Modbus / 网关 API 皆可),Server 层零改动。
快速开始
pip install -e .
# 方式一:stdio 传输(MCP 客户端默认)
python -m digital_twin_mcp.server
# 方式二:streamable-http 传输
python -m digital_twin_mcp.server --transport streamable-http端到端测试(启动 server 子进程并通过 stdio 协议调用):
python examples/client_test.py接入 WorkBuddy
把 examples/workbuddy_mcp.json 的内容合并到 C:\Users\33033\.workbuddy\mcp.json 的 mcpServers 中,然后在连接器管理页右上角的自定义连接器入口对 digital-twin-mcp 点击「信任」启用。
与 workflow-templates 的关系
同一个"数字管道"品牌下的两块积木:
workflow-templates:把脑力劳动(财报分析等)打包成工作流digital-twin-mcp:把设备数据能力(数字孪生 / PLC)打包成 MCP 工具
两者未来可组合:工作流模板的「设备健康报告」等模板,可直接调用本 MCP 的工具获取真实数据。
路线图
v0.1:模拟 PLC + 5 个工具 + 2 个资源 + 1 个提示词(当前)
v0.2:OPC-UA 真实接入、时序数据落库(SQLite/InfluxDB)、WebSocket 推送
v0.3:3D 场景联动(场景布局资源对接 Three.js 渲染)、多工厂实例
许可
MIT License
Available Tools
6 toolscheck_alertsA
检查告警:不传 device_id 时遍历全部设备,返回 warning / critical 分级告警列表。
Inputs: device_id. Returns: result
get_device_metricsA
读取设备实时指标,返回指标名 / 数值 / 单位(每次调用推进一个采样周期)。
Inputs: device_id (required). Returns: object
get_metric_historyA
读取设备某指标的最近 N 个采样值(时序数据,供趋势图 / 3D 可视化使用)。
Inputs: metric (required), device_id (required), points. Returns: object
get_scene_snapshotA
数字孪生场景快照:一次调用返回全部设备的坐标、实时指标与分级告警(专供可视化 / 监控轮询)。
Inputs: no named parameters. Returns: object
list_devicesA
列出数字孪生场景中的所有设备(含类型与所在位置)。
Inputs: no named parameters. Returns: result
set_device_valueA
写入设备参数(模拟 PLC 写值;也可用于演示故障注入,如手动抬高温度触发告警)。
Inputs: value (required), metric (required), device_id (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool addresses a distinct concern: device enumeration, live metric read, historical metric retrieval, parameter write, alert checking, and a full scene snapshot. No two tools overlap in purpose, and the descriptions reinforce their boundaries.
All tool names follow the verb_noun pattern in snake_case (list_devices, get_device_metrics, get_metric_history, set_device_value, check_alerts, get_scene_snapshot). The pattern is predictable and consistent.
Six tools form a well-scoped set for a digital twin server, covering read, write, history, alerts, and snapshot use cases without bloat. The count is ideal for the domain and avoids both thin and heavy footprints.
The tool surface covers the full lifecycle of interacting with a simulated twin: listing devices, reading live metrics and history, writing values for control or fault injection, checking alerts, and obtaining a complete scene snapshot. No obvious gaps exist for the stated purpose.
Related MCP Connectors
Public MCP digital twin with synthetic systems and an agent firewall. No customer data.
Protocol-native energy infrastructure orchestration for AI data centers. Provides 46 MCP tools across 8 grid protocols (IEC-61850, DNP3, Modbus, OCPP, OpenADR, IEEE 2030.5, IEC 60870-5-104, ICCP) with 5 core API primitives: connect, dispatch, settle, comply, and intel. Enables AI agents to programmatically interact with substations, grid interfaces, and energy assets for real-time workload-grid coordination.
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Hosted MCP endpoint with realistic fake data for prototyping agents. 12 tools, no setup.
Related MCP Servers
- AlicenseBqualityBmaintenanceExposes a deterministic IoT edge runtime — Modbus/CAN/J1939 acquisition, local rules, alarms, and history — to AI assistants as typed, governed MCP tools. Reads are safe by default; device control stays deny-by-default, explicitly confirmed, and audited.233Apache 2.0
- AlicenseAqualityCmaintenanceExposes live industrial IoT telemetry to any MCP client, streaming simulated sensor data from a fleet of machines and detecting anomalies, with the ability to inject faults on demand.4MIT
- FlicenseNot gradedqualityDmaintenanceProvides 19 tools for discovery, data analysis, configuration, and simulation, enabling an agent to drive digital twin workflows with session persistence and knowledge graph capabilities.1-
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to connect to OPC UA servers and read real-time industrial data or write control values through standardized MCP tools.MIT