digital-twin-mcp
digital-twin-mcp
디지털 트윈 시나리오의 장치 데이터 기능을 MCP 도구로 패키징합니다. 모든 MCP 클라이언트(WorkBuddy, Claude Desktop, Cursor 등)에서 장치 상태를 직접 조회하고, 실시간 지표를 읽고, 시계열 데이터를 가져오고, 알람을 확인할 수 있습니다.
디지털 파이프라인의 설계자 · 두 번째 블록: 장치 모니터링 파이프라인 첫 번째 블록: https://github.com/xici001/workflow-templates(AI 자동화 워크플로 템플릿)
기능
도구 | 설명 |
| 씬 내 모든 장치 나열 (유형 / 위치) |
| 장치 실시간 지표 읽기 (PLC 폴링 시뮬레이션) |
| 특정 지표의 최근 시계열 데이터 읽기 (추세 그래프 / 3D 시각화용) |
| 장치 매개변수 쓰기 (PLC 값 쓰기 / 장애 주입 테스트 시뮬레이션) |
| 임계값 알람 확인 (warning / critical 등급) |
리소스 | 설명 |
| 장치 대장: 메타데이터 + 지표 범위 및 알람 임계값 |
| 3D 씬 레이아웃: 장치 월드 좌표 (Three.js / Unity 직접 오버레이) |
프롬프트 | 설명 |
| 지정된 장치의 상태 보고서 생성 |
Related MCP server: AetherEdge
아키텍처
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.pyWorkBuddy 연동
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 分级告警列表。
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full disclosure burden and does meaningfully convey the all-device iteration default and the warning/critical tiering of results. It doesn't disclose whether the operation is safe/idempotent, whether the all-device scan has rate-limit or permission implications, or what happens with an invalid device_id. For a simple read-like check, it's adequate but not comprehensive.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single, front-loaded Chinese sentence delivers the verb, resource, conditional behavior, and return structure with zero fluff. Every clause earns its place, and the most decision-relevant behavior (the no-argument path) is placed at the core of the sentence.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with one optional parameter and an available output schema (which covers return structure), the description adequately covers purpose, the default no-argument path, and result tiering. The main omission is contrasting the provided-device_id case explicitly, but for this low complexity (1 param, no required fields, no nested objects), the description is nearly complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% — the schema only defines an unadorned nullable string with a null default. The description partially compensates by clarifying the meaningful null case (scan all devices), which is genuinely useful semantics beyond the schema. However, it never explicitly states what providing a device_id does (filtering to that device, presumably) or the expected format, so parameter meaning remains only partially established.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb-resource pairing ('检查告警' / check alerts) and adds concrete behavioral scope: when device_id is omitted, it iterates all devices and returns tiered alert lists ('warning / critical 分级告警列表'). It stops short of 5 because no sibling tool in the list (list_devices, get_device_metrics, etc.) obviously overlaps with alerts, so explicit differentiation isn't tested.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description conveys usage context by clarifying the default behavior when device_id is not passed ('不传 device_id 时遍历全部设备') and identifying the two severity tiers in the response, which helps an agent understand the tool's scope. However, it provides no explicit when-to-use vs. alternatives guidance, exclusions, or performance caveats about scanning all devices. The usage guidance is implicitly conveyed rather than explicitly directed.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_device_metricsA
读取设备实时指标,返回指标名 / 数值 / 单位(每次调用推进一个采样周期)。
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of behavioral transparency. It discloses a critical side effect: each call advances a sampling period, which is not obvious from the schema. This is valuable context beyond the basic read operation, though it doesn't detail auth or rate limits, which are less critical for a read tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, compact sentence that conveys purpose, output, and a key behavioral trait. It is front-loaded with the core function and contains no wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The output schema exists, so the description doesn't need to detail return values. The tool is simple with one parameter, but the description doesn't address edge cases like invalid device IDs or what happens if no metrics are available. It also doesn't connect to siblings for context, so completeness is adequate but not thorough.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description must compensate for undocumented parameters. It mentions device_id implicitly as 'device' but doesn't add any extra meaning like format, constraints, or default values. The description adds minimal value beyond the schema, and with only one parameter, the baseline is 3.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool reads real-time device metrics and returns metric name/value/unit. It also notes that each call advances one sampling period. This distinguishes it from siblings like get_metric_history and get_scene_snapshot, though it doesn't explicitly name alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for real-time data retrieval, and the note about advancing a sampling period hints at when to use it (call repeatedly to get successive samples). However, it does not explicitly state when to prefer get_metric_history over this tool for historical data, or provide clear exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_metric_historyA
读取设备某指标的最近 N 个采样值(时序数据,供趋势图 / 3D 可视化使用)。
| Name | Required | Description | Default |
|---|---|---|---|
| metric | Yes | ||
| points | No | ||
| device_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must convey all behavioral traits. It only states the action (reading sample values) and does not disclose side effects, permissions, or error behavior, nor explicitly confirm it is read-only.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence with no redundant information, making it highly concise and well-structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the tool's purpose, inputs, and intended use case. Output format is likely handled by the output schema (which exists). It lacks edge-case details but is adequate for a simple read operation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds meaning by indicating that '某指标' refers to the metric parameter, '设备' to device_id, and '最近 N 个采样值' to points. However, it does not explain the default value of points or any constraints, leaving some gaps given the schema lacks descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool reads recent N sample values of a device metric, specifying the verb (read), resource (metric history), and scope (device). It differentiates from siblings by mentioning time series data and visualization use cases.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description mentions a use case (trend charts / 3D visualization) but does not explicitly advise when to use this tool over alternatives like get_device_metrics. The guidance is implicit rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_scene_snapshotA
数字孪生场景快照:一次调用返回全部设备的坐标、实时指标与分级告警(专供可视化 / 监控轮询)。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral disclosure burden. It discloses a key behavioral trait—a single call returns all devices' data—and specifies the content categories (coordinates, real-time metrics, graded alerts). It does not detail potential payload size or data freshness, but for a zero-parameter read-only snapshot it provides meaningful transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, well-structured sentence that front-loads the core purpose and includes the key differentiator ('one call returns all devices'). Every word contributes value; there is no redundancy or filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter tool with an output schema and no destructive or mutating behavior, this description is complete. It states the return contents, scope, and recommended usage context, making it sufficient for an agent to select and invoke the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters and an empty input schema, so the baseline is 4. The description adds no parameter-specific details because none are needed; all behavior is encapsulated in the fixed snapshot semantics.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb-plus-resource pattern: 'returns all devices' coordinates, real-time metrics, and graded alerts in one call.' It clearly distinguishes this aggregate snapshot tool from sibling tools like get_device_metrics and check_alerts by emphasizing the scene-wide scope.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states the intended use case: 'exclusively for visualization / monitoring polling.' This gives clear context for when to choose this tool, though it does not explicitly name sibling alternatives or state when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_devicesA
列出数字孪生场景中的所有设备(含类型与所在位置)。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses that the tool lists all devices with type and location, which is a read-only behavior by implication. However, it does not explicitly state safety (read-only, no side effects), potential performance implications (e.g., large result sets), or any authentication requirements. This is adequate for a simple list operation but lacks explicit behavioral guarantees, so a 3 is appropriate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence in Chinese that is front-loaded with the action and resource. It contains zero filler words and directly states the purpose and key output fields. This is exemplary conciseness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's low complexity (no parameters, no nested objects) and the existence of an output schema, the description is fully complete. It states exactly what the tool does and what information is included. There is no ambiguity or missing context for an agent to select and invoke this tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, and the schema has 100% coverage (vacuous truth). The rubric sets a baseline of 4 for zero parameters. The description adds no parameter-specific info, but none is needed. It also hints at output content (type and location), which is not parameter semantics but does enrich the tool's usage context.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb (list), resource (all devices), and scope (digital twin scene), and specifies that type and location are included. It clearly distinguishes from sibling tools like get_device_metrics or get_metric_history, which focus on metrics and history, not device enumeration.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage context ('in digital twin scene') and it's obvious when to use this tool (to retrieve a device roster). It does not explicitly state when not to use it or name alternatives, but the sibling tool list makes the differentiation clear. This earns a 4 as clear context with no exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
set_device_valueA
写入设备参数(模拟 PLC 写值;也可用于演示故障注入,如手动抬高温度触发告警)。
| Name | Required | Description | Default |
|---|---|---|---|
| value | Yes | ||
| metric | Yes | ||
| device_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description must carry burden. It mentions simulation and fault injection but lacks details on side effects, persistence, or permissions needed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that conveys the core functionality without unnecessary words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given it's a simple setter with no output schema, the description could be complete, but it omits parameter details and behavioral implications, leaving gaps for a write operation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has no parameter descriptions and the tool description does not explain device_id, metric, or value. Parameter semantics are almost entirely missing.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it writes device parameters, simulating PLC writes, and mentions fault injection. This distinguishes it from sibling read/list tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It provides usage contexts (simulating PLC writes, fault injection demos) but does not explicitly contrast with alternatives; still clear enough for typical use.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.0- First observed
check_alerts - First observed
get_device_metrics - First observed
get_metric_history - First observed
get_scene_snapshot - First observed
list_devices - First observed
set_device_value
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.
Maintenance
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
- FlicenseBqualityCmaintenanceUniversal MCP server for industrial PLC communication, enabling AI agents to read sensors, alarms, status, setpoints, and write setpoints via adapters for Modbus, S7, or custom PLCs.6-
- AlicenseBqualityAmaintenanceExposes 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
- AlicenseAqualityBmaintenanceExposes 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-