Token导航 LogoToken导航TokenDH.com
Br Automation Pvi MCP Server logo
运维云端未说明官方级别未说明来源级核验

Br Automation Pvi MCP Server

MCP Server

一款统一的MCP服务器,用于B&R自动化工作室,支持构建项目、连接PLC、读写变量、趋势数据分析、生成图表和查询本地变量数据库等功能。

工具数

38

提示词数

0

GitHub Stars

0

资源数

0
TypeScriptClaude云端部署Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

googoles

提供方

googoles

最后核验

2026/5/17 20:19

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

BnR MCP服务器

B&R Automation Studio的统一MCP(模型上下文协议)服务器——构建项目、连接到PLC、读/写变量、趋势数据、生成图表和查询本地变量数据库,所有这些都来自Claude或任何兼容MCP的AI助手。

38工具 |TypeScript+C#配套| SQLite变量索引| MIT许可证

______________________________________________________________________

特性

类别工具描述
构建4构建AS6项目,转移到目标,解析构建日志
连接5ANSL/TCP连接到PLC或ARSim,自动检测,ping,切换目标
变量4读/写标量、结构、数组、批处理操作
变量数据库3SQLite支持的变量索引——无需PLC往返即可快速查询
手表6轮询变量、列出会话、导出CSV、实时网络仪表板
快速趋势3通过C#伴随+PNG图表进行高频监测(10-100ms)
PLC信息4CPU信息、任务列表、模块列表、错误日志
模块3上传/下载/比较 .br 模块文件
控制3冷启动、热启动、诊断模式(带安全确认)
工作流程2一次性部署工作流程,完整的健康报告

先决条件

必需

依赖关系版本目的
B&R自动化工作室6AS6提供 BR.AS.Build.exePVITransfer.exe
B&R PVI 6PVI 6.xPLC通信运行时(与AS6一起安装)
Node.js18+MCP服务器运行时
npm9+包管理器

可选(用于高频趋势分析)

依赖关系版本目的
.NET框架4.8.1x86必填项 BR.AN.PviServices.dll
MSBuild/.NET命令行界面.NET SDK 8.0+构建C#伴侣
视窗10/11PVIServices仅适用于Windows(x86)
重要提示: BR.AN.PviServices.dll 是PE32(x86)。NET Framework程序集。确实如此 工作下。NET 8.0 x64。同伴必须瞄准 net481PlatformTarget=x86.

自动检测路径

服务器自动检测B&R安装路径。如果需要,用环境变量覆盖:

组件默认位置
BR.AS.Build.exeC:\Program Files (x86)\BrAutomation\AS6\bin-en\BR.AS.Build.exe
PVITransfer.exeC:\Program Files (x86)\BrAutomation\PVI6\PVI\Tools\PVITransfer\PVITransfer.exe
PviCompanion.execompanion\bin\Release\net481\PviCompanion.exe (相对于项目)

安装

# Clone
git clone https://github.com/your-username/BnR-MCP-Server.git
cd BnR-MCP-Server

# Install dependencies
npm install

# Build TypeScript
npm run build

# (Optional) Build C# companion for high-frequency trending
npm run build:companion
# or manually:
dotnet build companion/PviCompanion.csproj -c Release

配置

克劳德桌面/克劳德代码

添加到MCP设置(claude_desktop_config.json 或克劳德代码设置):

{
  "mcpServers": {
    "bnr": {
      "command": "node",
      "args": ["C:/path/to/BnR-MCP-Server/dist/index.js"],
      "env": {
        "PVI_PLC_IP": "192.168.0.10",
        "BR_PROJECTS_ROOT": "C:/Users/you/projects"
      }
    }
  }
}

环境变量

所有配置都是可选的——提供了合理的默认值。

变量默认值描述
BR_BUILD_EXE*(自动检测)*通往 BR.AS.Build.exe
BR_PROJECTS_ROOT当前目录项目扫描的根目录
BR_BUILD_TIMEOUT_MS300000 (5分钟)构建超时(毫秒)
BR_EXCLUDED_DIRSnode_modules,Temp,Binaries,.git扫描时要跳过的目录
PVI_TRANSFER_EXE*(自动检测)*通往 PVITransfer.exe
PVI_PLC_IP192.168.0.10默认PLC IP地址
PVI_WAIT_TIME30连接超时(秒)
PVI_TEMP_DIR%TEMP%/pvi-mcpPIL脚本的临时目录
PVI_WATCH_MAX_SAMPLES3600每个观察时段的最大样本数
PVI_COMPANION_EXE*(自动检测)*通往 PviCompanion.exe
BNR_DB_PATH%TEMP%/pvi-mcp/bnr-mcp.dbSQLite数据库路径

总工作流

使用BnR MCP服务器的完整开发到调试周期:

┌─────────────────────────────────────────────────────────────────────────┐
│                        TOTAL WORKFLOW                                  │
│                                                                       │
│  ┌─────────┐    ┌─────────┐    ┌─────────┐    ┌─────────┐            │
│  │ 1.SETUP │───▶│ 2.BUILD │───▶│3.CONNECT│───▶│ 4.DEBUG │            │
│  └─────────┘    └─────────┘    └─────────┘    └─────────┘            │
│       │              │              │              │                   │
│       ▼              ▼              ▼              ▼                   │
│  Install &      Build AS6      Connect to     Read/Write              │
│  Configure      Project        PLC/ARSim      Variables               │
│                                                    │                   │
│                                          ┌─────────▼─────────┐        │
│                                          │  5. VAR DATABASE  │        │
│                                          │  Refresh + Query  │        │
│                                          └─────────┬─────────┘        │
│                                                    │                   │
│  ┌─────────┐    ┌─────────┐    ┌─────────┐    ┌───▼─────┐            │
│  │9.CONTROL│◀───│8.EXPORT │◀───│ 7.CHART │◀───│ 6.TREND │            │
│  └─────────┘    └─────────┘    └─────────┘    └─────────┘            │
│       │              │              │              │                   │
│       ▼              ▼              ▼              ▼                   │
│  Restart PLC    CSV / Web       PNG Chart     Watch & Fast            │
│  Diagnostics    Dashboard       OxyPlot       Trend (10ms+)           │
│                                                                       │
└─────────────────────────────────────────────────────────────────────────┘

步骤1--设置

npm install && npm run build          # Build MCP server
npm run build:companion               # (Optional) Build C# companion

将MCP服务器添加到Claude配置中→ 准备使用。

第二步——构建项目

"Build my project"
  → list_projects        Find .apj files in workspace
  → get_project_info     Check configurations
  → build_project        Build (mode: Build / Rebuild / BuildAndTransfer)
  → parse_build_log      Review errors & warnings
┌──────────────────────────────────────────────────────────────┐
│  AS6 Project (.apj)                                         │
│                                                             │
│  ┌─────────┐    ┌──────────────┐    ┌───────────────────┐   │
│  │ Sources │───▶│BR.AS.Build.exe│───▶│ Build Output      │   │
│  │ .st .c  │    │              │    │ ✓ 0 = Success     │   │
│  └─────────┘    │ -buildMode   │    │ ⚠ 1 = Warnings   │   │
│                 │  "Build"     │    │ ✗ 3 = Errors      │   │
│                 │  "Rebuild"   │    └───────────────────┘   │
│                 │  "BuildAnd   │             │               │
│                 │   Transfer"  │             ▼               │
│                 └──────────────┘    ┌───────────────────┐   │
│                                    │ parse_build_log    │   │
│                                    │ → structured JSON  │   │
│                                    └───────────────────┘   │
└──────────────────────────────────────────────────────────────┘

构建和转移 --构建项目并将安装包传输到连接的目标(ARSim或真实PLC)。这是B&R标准的“转移到目标”机制:

Sources → BUILD → Modules (.br) → PACK → Installation Package → TRANSFER → PLC

步骤3——连接PLC

"Connect to my PLC"
  → pvi_ping             Quick TCP probe to check reachability (~2s)
  → pvi_auto_connect     Try hardware PLC first (if PVI_PLC_IP set), then ARSim
  → pvi_connect          Manual: specify IP address
  → pvi_switch_target    Switch between hardware PLC and ARSim in one call
  → get_config           Verify paths and connection state
┌───────────────────────────────────────────────────────────────┐
│  Connection Flow (pvi_auto_connect with PVI_PLC_IP set)      │
│                                                              │
│       ├──▶ Try PVI_PLC_IP (hardware) ──────▶ Connected?      │
│       │         │                              │             │
│       │         │ No                          Yes ──▶ Done   │
│       │         ▼                                            │
│       └──▶ Try 127.0.0.1:11169 (ARSim) ──▶ Connected?       │
│                                               │              │
│                                   Yes ──▶ Done │              │
│                                                              │
│  Response: CPU type, AR version, PLC status, IP source       │
└───────────────────────────────────────────────────────────────┘

步骤4——调试(读/写变量)

"What is the current temperature?"
  → pvi_read_variable            Read single variable (scalar/struct/array)
  → pvi_write_variable           Write single variable with read-back
  → pvi_write_variables_batch    Write multiple variables at once
┌─────────────────────────────────────────────────────────────────┐
│  Variable Access Patterns                                      │
│                                                                │
│  Scalar:    pvi_read_variable { name: "gTemperature" }         │
│                                                                │
│  Struct:    pvi_read_variable { name: "stSensor",              │
│                                 member: "rValue",              │
│                                 task: "Control" }              │
│                                                                │
│  Array:     pvi_read_variable { name: "aValues", index: 3 }   │
│                                                                │
│  Nested:    pvi_read_variable { name: "stBatch",               │
│                                 member: "aSensors[0].rValue" } │
│                                                                │
│  Batch:     pvi_write_variables_batch {                        │
│               variables: [                                     │
│                 { name: "gSetpoint", value: "75.0" },          │
│                 { name: "gMode",     value: "2"    }           │
│               ]                                                │
│             }                                                  │
└─────────────────────────────────────────────────────────────────┘

步骤5——变量数据库(SQLite索引)

构建一个本地变量索引,用于快速、离线查询,而无需每次访问PLC。

"Show me all REAL variables in HMIMain"
  → pvi_refresh_variables    Fetch variables from PLC → store in SQLite
  → pvi_query_variables      Fast SQL query (no PLC round-trip)
  → pvi_db_status            Check DB health and last refresh time
┌──────────────────────────────────────────────────────────────────┐
│  Variable Database Workflow                                     │
│                                                                 │
│  Once:   pvi_refresh_variables { scope: "all" }                 │
│              → fetches globals (VariableListGlobal)             │
│          pvi_refresh_variables { scope: "local",                │
│                                  task: "HMIMain" }              │
│              → fetches task-local variables                     │
│                                                                 │
│  Anytime (fast):                                                │
│          pvi_query_variables { namePattern: "Reactor",          │
│                                dataTypeFilter: ["REAL"],        │
│                                task: "HMIMain",                 │
│                                limit: 50 }                      │
│              → SQL query, returns in  **注:** `VariableListAll` 从PVITransfer只返回全局作用域变量。对于任务局部变量(例如 `Module_0.var`),跑 `pvi_refresh_variables` 和 `scope: "local"` 以及具体的任务名称。

### 第6步——趋势(随时间监测)

有两种趋势引擎可供选择——根据速度要求进行选择:

┌────────────────────────────────────────────────────────────────┐ │ │ │ PVITransfer Trending (500ms+) C# Companion (10-100ms) │ │ ───────────────────────────── ──────────────────────── │ │ pvi_watch_variables pvi_fast_watch │ │ pvi_get_trend_data pvi_fast_trend_chart │ │ pvi_stop_watch pvi_fast_stop │ │ pvi_list_watch_sessions │ │ │ │ ┌──────────┐ spawn ┌───────────────┐ persistent conn │ │ │ Node.js │─────────▶ │PVITransfer.exe│ ────▶ PLC │ │ │ (poll) │ per read │ (one-shot) │ │ │ └──────────┘ └───────────────┘ │ │ vs. │ │ ┌──────────┐ stdin/ ┌───────────────┐ event-driven │ │ │ Node.js │──stdout──▶│PviCompanion │ ────▶ PLC │ │ │ (IPC) │ JSON │ .exe (x86) │ PVIServices │ │ └──────────┘ └───────────────┘ │ │ │ └────────────────────────────────────────────────────────────────┘

"Monitor temperature every 500ms for 30 seconds" → pvi_watch_variables Start polling → (wait 30 seconds) → pvi_get_trend_data Retrieve time-series data → pvi_stop_watch Stop session (samples persisted to SQLite)

"Fast-trend 4 variables at 100ms" → pvi_fast_watch Start C# companion monitoring → pvi_fast_trend_chart Generate PNG chart → pvi_fast_stop Stop session


> **会话持久性:** 当你打电话的时候 `pvi_stop_watch`,所有样本都会刷新到SQLite数据库。如果服务器重新启动, `pvi_get_trend_data` 和 `pvi_export_csv` 对于已停止的会话,自动回退到数据库。 `pvi_list_watch_sessions` 显示活动(内存中)和历史(SQLite)会话。

### 第7步——图表(可视化)

┌─────────────────────────────────────────────────────────────┐ │ Visualization Options │ │ │ │ ┌─────────────────┐ ┌──────────────────────────────┐ │ │ │ pvi_fast_trend │ │ pvi_dashboard │ │ │ │ _chart │ │ │ │ │ │ │ │ ┌────────────────────────┐ │ │ │ │ OxyPlot PNG │ │ │ Chart.js Live View │ │ │ │ │ ┌────────────┐ │ │ │ localhost:3333 │ │ │ │ │ │ ╱╲ ╱╲ │ │ │ │ │ │ │ │ │ │╱ ╲╱ ╲╱╲ │ │ │ │ Auto-refresh 1s │ │ │ │ │ │ ╲ │ │ │ │ Multi-variable │ │ │ │ │ └────────────┘ │ │ └────────────────────────┘ │ │ │ │ Base64 PNG │ │ Open in browser │ │ │ │ in MCP response │ │ │ │ │ └─────────────────┘ └──────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────┘


### 第8步——导出

"Export the trend data" → pvi_export_csv Save to CSV file (timestamp + variable columns) → pvi_dashboard Or open live web dashboard in browser

CSV output: timestamp,gTemperature,gPressure,gFlowRate 2026-03-22T10:00:00.123,72.5,1.013,15.2 2026-03-22T10:00:00.623,72.8,1.014,15.1 ...


> 两者 `pvi_export_csv` 和 `pvi_get_trend_data` 如果会话不再在内存中,则自动回退到SQLite。

### 步骤9——PLC控制和诊断

"Check PLC status and restart" → pvi_get_cpu_info CPU type, AR version, memory, status → pvi_list_tasks All running tasks with versions → pvi_list_modules All modules (system + application) → pvi_read_error_log Error logbook entries → pvi_warmstart Warm restart (preserves retained vars) → pvi_coldstart Cold restart (clears non-retained vars) → pvi_diagnostics Enter diagnostics mode


### 端到端示例(自然语言)

You: "Build ECELL_Base and transfer to ARSim" Claude: → build_project (BuildAndTransfer, simulation=true) ✓ Build succeeded (0 errors, 2 warnings) ✓ Transferred to ARSim

You: "Connect and show me what's running" Claude: → pvi_ping → reachable (3ms) → pvi_auto_connect → Connected to hardware PLC (192.168.10.50) → pvi_get_cpu_info → AR V6.5.1, CPU: 4PPC80.156B-13B → pvi_list_tasks → 40 tasks running

You: "Index all HMIMain variables" Claude: → pvi_refresh_variables { scope: "local", task: "HMIMain" } ✓ 2121 variables indexed to SQLite

You: "Find all REAL variables related to temperature" Claude: → pvi_query_variables { namePattern: "Temp", dataTypeFilter: ["REAL"] } → 12 matches returned instantly (no PLC round-trip)

You: "Watch temperature and pH for 1 minute" Claude: → pvi_watch_variables { variables: [...], intervalMs: 500 } → (collecting samples over 60 seconds...) → pvi_get_trend_data → Temperature: 25.1°C, pH: 6.8

You: "Export that to CSV" Claude: → pvi_stop_watch → samples flushed to SQLite → pvi_export_csv → saved to C:/data/trend.csv

You: "Warm restart the PLC" Claude: → pvi_warmstart { confirm: true } ✓ PLC warm restarted — retained variables preserved


______________________________________________________________________

## 使用参考

### 连接

pvi_ping → { mode: "tcp" } # fast probe (~2s) pvi_auto_connect → {} # auto-detect hardware/ARSim pvi_connect → { ipAddress: "192.168.0.10" } pvi_switch_target → { target: "arsim" } # or "hardware"


### 变量数据库

pvi_refresh_variables → { scope: "all" } # globals pvi_refresh_variables → { scope: "local", task: "HMIMain" } # task-local pvi_query_variables → { namePattern: "Reactor", limit: 50 } pvi_query_variables → { dataTypeFilter: ["REAL", "BOOL"], task: "HMIMain" } pvi_db_status → {} # count + last refresh


### 读/写变量

pvi_read_variable → { name: "gTemperature" } pvi_read_variable → { name: "stSensor", member: "rValue", task: "MainTask" } pvi_read_variable → { name: "aValues", index: 3 } pvi_write_variable → { name: "gSetpoint", value: "75.5", dataType: "REAL" }


### 趋势数据

pvi_watch_variables → { variables: [...], intervalMs: 500 } pvi_get_trend_data → { watchId: "...", lastN: 100 } pvi_export_csv → { watchId: "...", filePath: "C:/data/trend.csv" } pvi_list_watch_sessions → {} # active + SQLite history pvi_stop_watch → { watchId: "..." } # flushes to SQLite pvi_dashboard → { watchId: "..." } # opens Chart.js at localhost:3333


### 高频趋势分析(C#伴侣)

pvi_fast_watch → { variables: [...], intervalMs: 100 } pvi_fast_trend_chart → { watchId: "..." } # generates PNG chart via OxyPlot pvi_fast_stop → { watchId: "..." }


### PLC控制(需要 `confirm: true`)

pvi_warmstart → { confirm: true } pvi_coldstart → { confirm: true } pvi_diagnostics → { confirm: true }


______________________________________________________________________

## 全部38个工具

|#|工具|类别|描述|
|---|------|----------|-------------|
| 1 | `build_project` |构建|构建AS6项目(构建/重建/构建和转移)|
| 2 | `list_projects` |生成|扫描目录 `.apj` 项目文件|
| 3 | `get_project_info` |构建|读取项目元数据和配置|
| 4 | `parse_build_log` |构建|将构建输出解析为结构化错误/警告|
| 5 | `pvi_connect` |连接|通过ANSL/TCP连接到PLC|
| 6 | `pvi_disconnect` |连接|断开连接并清除连接状态|
| 7 | `pvi_auto_connect` |连接|自动检测硬件PLC(PVI_PLC_IP)或ARSim|
| 8 | `pvi_ping` |连接|TCP或完整PVI可达性检查|
| 9 | `pvi_switch_target` |连接|在一次通话中在硬件PLC和ARSim之间切换|
| 10 | `get_config` |连接|显示当前服务器配置和同伴状态|
| 11 | `pvi_read_variable` |变量|读取标量、结构体成员或数组元素|
| 12 | `pvi_write_variable` |变量|写一个带有读回确认的变量|
| 13 | `pvi_list_variables` |变量|列出所有/全局/局部变量及其值(PLC往返)|
| 14 | `pvi_write_variables_batch` |变量|在一次操作中写入多个变量|
| 15 | `pvi_refresh_variables` |变量数据库|从PLC获取变量并存储在SQLite中|
| 16 | `pvi_query_variables` |变量数据库|针对局部变量索引的快速SQL查询|
| 17 | `pvi_db_status` |变量数据库|显示数据库路径、变量计数、上次刷新时间|
| 18 | `pvi_watch_variables` |观察|每隔(500ms+)开始轮询变量|
| 19 | `pvi_get_trend_data` |观察|获取收集的时间序列数据(内存中或SQLite回退)|
| 20 | `pvi_stop_watch` |观看|停止观看会话并将样本刷新到SQLite|
| 21 | `pvi_list_watch_sessions` |观察|列出所有会话——活动(内存)+历史(SQLite)|
| 22 | `pvi_export_csv` |观察|将趋势数据导出到CSV文件(内存中或SQLite回退)|
| 23 | `pvi_dashboard` |观看|使用Chart.js的实时网络仪表板(自动刷新1秒)|
| 24 | `pvi_fast_watch` |快速趋势|通过C#伴侣进行高频监测(10-100ms)|
| 25 | `pvi_fast_trend_chart` |快速趋势|通过OxyPlot生成PNG趋势图|
| 26 | `pvi_fast_stop` |快速趋势|停止快速观察会话|
| 27 | `pvi_get_cpu_info` |PLC信息|CPU类型、AR版本、内存、硬件|
| 28 | `pvi_list_tasks` |PLC信息|列出所有正在运行的任务|
| 29 | `pvi_list_modules` |PLC信息|列出所有模块(系统+应用程序)|
| 30 | `pvi_read_error_log` |PLC信息|读取PLC错误日志|
| 31 | `pvi_download_module` |模块|传输 `.br` 文件PC→ PLC |
| 32 | `pvi_upload_module` |模块|传输模块PLC→ PC |
| 33 | `pvi_check_module` |模块|比较本地与PLC模块版本|
| 34 | `pvi_coldstart` |控制|冷重启(清除非保留变量)|
| 35 | `pvi_warmstart` |控制|热重启(保留保留变量)|
| 36 | `pvi_diagnostics` |控制|进入诊断模式(停止任务)|
| 37 | `pvi_deploy_workflow` |工作流|构建+转移+连接一次通话|
| 38 | `pvi_health_report` |工作流|完整的PLC健康检查(CPU、任务、模块、错误)|

______________________________________________________________________

## 建筑

┌─────────────────────────────────────────────────────┐ │ Claude / MCP Client │ └──────────────────┬──────────────────────────────────┘ │ MCP Protocol (stdio) ┌──────────────────▼──────────────────────────────────┐ │ BnR-MCP-Server (Node.js / TypeScript) │ │ │ │ ┌────────┐ ┌──────────┐ ┌───────┐ ┌───────────┐ │ │ │ Build │ │Variables │ │Watch │ │ Control │ │ │ │ tools │ │ tools │ │tools │ │ tools │ │ │ └───┬────┘ └────┬─────┘ └───┬───┘ └─────┬─────┘ │ │ │ │ │ │ │ │ ┌───▼───────────▼───────────▼────────────▼──────┐ │ │ │ PIL Generator → PVITransfer.exe → Parser │ │ │ └──────────────────────────────────────────────┘ │ │ │ │ │ ┌───▼──────────────────────┐ ┌────────────────┐ │ │ │ SQLite DB (bnr-mcp.db) │ │ C# Companion │ │ │ │ • pvi_variables │ │ (optional) │ │ │ │ • watch_sessions │ │ PviCompanion │ │ │ │ • trend_samples │ │ .exe (x86) │ │ │ └──────────────────────────┘ │ PVIServices + │ │ │ │ OxyPlot │ │ │ └────────────────┘ │ └──────────────────┬──────────────────────────────────┘ │ ANSL/TCP (port 11169) ┌──────────────────▼──────────────────────────────────┐ │ B&R PLC or ARSim │ └─────────────────────────────────────────────────────┘


### SQLite数据库架构

-- Variable index (populated by pvi_refresh_variables) pvi_variables (id, name, task, scope, data_type, size, last_value, updated_at)

-- Watch session metadata (written on start/stop) watch_sessions (id, variables, interval_ms, max_samples, started_at, stopped_at)

-- Trend samples (flushed from memory on pvi_stop_watch) trend_samples (id, session_id, ts, sample_values)


______________________________________________________________________

## 限制和已知限制

### 基于PVITransfer的工具

- **轮询间隔** 最小值为~500ms(PVITransfer进程生成开销)
- **ReadVariable文件输出** 对于某些数据类型可以返回空值--use `pvi_list_variables` 作为后备
- **ARSim上的模块下载** PVI错误#11156-use失败 `build_project` 和 `BuildAndTransfer` 改为模式
- **PIL脚本执行** 是连续的——每个工具调用都会生成一个新的 `PVITransfer.exe` 过程
- **VariableList所有范围** --仅返回全局作用域变量;使用 `scope: "local"` 带有程序局部变量的任务名称

### C#伴侣(快速趋势)

- **仅限Windows** — `BR.AN.PviServices.dll` 是Windows x86程序集
- **需要.NET Framework 4.8.1** — .NET 8.0 x64导致静默通信失败
- **本地任务变量** 通过PVIServices获取PVI错误11033 `Variable` 对象——快速趋势只支持全局变量。使用基于PVITransfer的 `pvi_watch_variables` 对于局部变量
- **需要WinForms消息泵** — `[STAThread]` + `Application.Run()` PVI事件交付所需

### PLC控制

- `pvi_coldstart`, `pvi_warmstart`, `pvi_diagnostics` 需要明确 `confirm: true` 参数
- **无法撤消** --重启命令立即生效
- 不建议在没有操作员意识的生产系统上使用

### 将军

- **单个连接** --一次连接一个PLC
- **无OPC UA** --仅通过PVI/ANSL进行通信
- **没有实时保证** --趋势时间戳是近似的(取决于操作系统调度)
- **临时文件** --PIL脚本和输出文件是在 `PVI_TEMP_DIR` 使用后清理干净

______________________________________________________________________

## 项目结构

BnR-MCP-Server/ ├── src/ │ ├── index.ts # MCP server entry — 38 tools registered │ ├── tools/ │ │ ├── build.ts # build_project, list_projects, get_project_info, parse_build_log │ │ ├── connect.ts # pvi_connect, pvi_disconnect, pvi_auto_connect, pvi_ping, │ │ │ # pvi_switch_target, get_config │ │ ├── control.ts # pvi_coldstart, pvi_warmstart, pvi_diagnostics │ │ ├── logs.ts # pvi_read_error_log │ │ ├── modules.ts # pvi_download/upload/check_module │ │ ├── plcinfo.ts # pvi_get_cpu_info, pvi_list_tasks, pvi_list_modules │ │ ├── projects.ts # Project scanning utilities │ │ ├── trending.ts # pvi_fast_watch, pvi_fast_trend_chart, pvi_fast_stop │ │ ├── vardb.ts # pvi_refresh_variables, pvi_query_variables, pvi_db_status │ │ ├── variables.ts # pvi_read/write/list_variables, pvi_write_variables_batch │ │ ├── watch.ts # pvi_watch/get_trend/stop/list_sessions, pvi_export_csv, │ │ │ # pvi_dashboard │ │ └── workflow.ts # pvi_deploy_workflow, pvi_health_report │ ├── types/ │ │ ├── build.ts # Build-related type definitions │ │ └── pvi.ts # PVI-related type definitions │ └── utils/ │ ├── build-parser.ts # Parse BR.AS.Build.exe output │ ├── build-runner.ts # Execute build commands │ ├── companion.ts # C# companion process manager │ ├── config.ts # Environment config + auto-detection │ ├── connection-state.ts # Global PLC connection state │ ├── db.ts # SQLite helpers (variables, watch sessions, trend samples) │ ├── parsers.ts # PVITransfer output parsers │ ├── pil-generator.ts # PIL script generator │ ├── pvi-runner.ts # PVITransfer.exe executor │ ├── tool-helpers.ts # Shared helpers (notConnectedError, etc.) │ └── trend-buffer.ts # In-memory trend data buffer ├── companion/ │ ├── PviCompanion.csproj # .NET Framework 4.8.1 (x86) │ ├── Program.cs # Entry point + JSON IPC │ ├── PviClient.cs # PVIServices wrapper │ └── ChartGenerator.cs # OxyPlot PNG chart generation ├── package.json └── tsconfig.json


______________________________________________________________________

## 发展

Build TypeScript (watch mode not available — rebuild manually)

npm run build

Build C# companion

npm run build:companion

Start server directly (for testing)

npm start

Test with ARSim

1. Open your project in Automation Studio

2. Start ARSim: Online → Simulation

3. Transfer project: Online → Transfer to target

4. The MCP server will auto-detect ARSim on localhost


## 许可证

麻省理工学院

## 作者

Yunsoo Jang(张润秀)

目录标签

目录标签

TypeScriptClaude云端部署PLC控制本地部署自动化调试变量管理数据趋势工业自动化

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

session

工具数量(toolCount,工具数)

38

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明session部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP