
OPC-UA MCP Server
io.github.mwieczorkiewicz由 GitHub 账号 mwieczorkiewicz 发布v1.0.0更新于 Oct 27, 2026
Read, write, browse, search, and subscribe to live data on an OPC-UA industrial automation server.
概览
让助手读取、写入、浏览、搜索并订阅 OPC-UA 工业自动化服务器实时数据的 MCP 服务器。
- 可以做什么
- 按节点 ID 或浏览名读取节点值,写入时会做类型校验
- 逐层或递归浏览地址空间,并查看节点元数据
- 通过后台发现索引搜索和模糊匹配节点名称
- 订阅推送式实时更新,列出并取消订阅
- 管理连接,查看服务器信息、发现统计与诊断信息
- 适用场景
- 适合需要查看或修改 OPC-UA 服务器(如 PLC、SCADA 系统)实时数值的场景,例如按名称查找变量、持续监控数值,或在工程调试中写入设定值。
- 运行要求
- 以本地进程运行(构建需 Go 1.26+,也可使用已发布的容器镜像);自带测试服务器可选装 Docker。需要 OPCUA_ENDPOINT 指定目标服务器。用户名密码认证需 OPCUA_USERNAME 与 OPCUA_PASSWORD;证书认证需证书与密钥文件。需能访问 OPC-UA 端点。
安装
在 SourceWeft 中
- 打开 控制台中的 OPC-UA MCP Server,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
OPC-UA MCP Server
An MCP server that lets an LLM read, write, browse, search, and subscribe to live data on an OPC-UA industrial automation server - over stdio or HTTP, with a persistent cache and a searchable index of the address space built in.
https://github.com/user-attachments/assets/0b676e6e-17ce-42f5-918f-9a615e939008
Quick start
The fastest way to see it working end-to-end, using the bundled Microsoft OPC-UA test server and a public tunnel Claude can reach:
Paste that URL into Claude at Settings → Connectors → Add custom
connector, then ask it to browse the server or read a value. Stop with
make compose-down when you're done - see
docs/deployment.md for what that tunnel exposes and
how to run against your own OPC-UA server instead.
Building and running locally
Requires Go 1.26+ and, optionally, Docker for the test server / containerized deployment.
What it does
- Read / write node values, with type validation on writes so a mismatched value is rejected before it reaches the device.
- Browse the address space one level at a time or recursively, and look nodes up by name instead of by node ID.
- Subscribe to push-based live updates - subscriptions persist across restarts and are automatically re-established on reconnect.
- Cache reads, browse results, and type info on disk (bbolt), so repeat lookups don't round-trip to the device; writes invalidate the relevant entry automatically.
- Discover and search the address space in the background, indexed with Bleve for fuzzy/partial browse-name lookups.
- Anonymous, username/password, or certificate auth, with configurable OPC-UA security policy and mode.
See docs/architecture.md for how the caching layer, subscription manager, and discovery index fit together.
MCP tools
Read-only mode
Set MCP_READ_ONLY=true to expose only tools that don't change anything on
the OPC-UA server or the connection: opcua_write, opcua_disconnect,
opcua_subscribe and opcua_unsubscribe are hidden from tools/list, and a
client that calls one of them by name gets an error instead of running it.
opcua_connect and the discovery tools stay available.
To approve specific tools on top of the read-only set, list them in
MCP_ALLOWED_TOOLS, for example MCP_ALLOWED_TOOLS=opcua_subscribe,opcua_unsubscribe.
An unknown tool name stops the server at startup, so a typo can't silently
leave a tool disabled. Any tool added in a future release is excluded from
read-only mode until it is classified as read-only.
MCP resources
Configuration
Configuration is loaded (via viper) from three sources, in ascending order of precedence:
- Built-in defaults (shown in the tables below).
- An optional config file - TOML, YAML, JSON, or any other format viper
supports. By default
./config.{yaml,yml,toml,json,...}is read if present; point at an explicit path withCONFIG_FILE=/path/to/config.toml. A config file is entirely optional - env vars alone are still enough. - Environment variables (
SERVER_*,OPCUA_*,MCP_*,SEARCH_*,STORE_*) - always win over the config file, so existing env-var-only deployments keep working unchanged.
A config file mirrors the env var names, lowercased and nested under each
prefix, e.g. SERVER_HTTP_PORT becomes:
Server
OPC-UA connection
MCP
Discovery and search
Persistent store
Backs read-through caching and subscription persistence with an on-disk bbolt database.
If the store fails to open (e.g. a stale lock from a prior ungraceful shutdown, or a read-only filesystem), the server logs a warning and keeps running with caching forced off and subscription tools returning an error - every other tool is unaffected.
Telemetry
opcua-mcp collects anonymous, aggregate usage telemetry (which tools get used, cache hit rate, error categories - never node IDs, endpoint URLs, node values, or credentials) to help prioritize maintenance of this open-source project. It's on by default; see docs/telemetry.md for exactly what is and isn't collected.
Opt out with either:
Docker
Multi-stage build on Chainguard's minimal Go image, running from scratch -
no shell, small attack surface. Mount ./search_index and
./mcp_opcua_store.db as volumes to persist discovery/cache/subscription
state across restarts. Full auth-mode examples, the Compose dev stack, and
the Claude-connector tunnel setup are in
docs/deployment.md.
Development
VS Code launch configs are in .vscode/launch.example.json - copy to
.vscode/launch.json to get stdio/HTTP/auth debug targets that start and
stop the test server automatically. make help lists every available
target.
Tests are table-driven and mock the OPC-UA client at the opcuaClient
interface seam (internal/opcua/mock_client_test.go) rather than against a
live/simulated server - see docs/architecture.md for
how the pieces being tested fit together, and
docs/COMMIT_CONVENTION.md for this repo's
commit message format.
Changelog
Unreleased
- New: read-only mode.
MCP_READ_ONLY=truehides and rejectsopcua_write,opcua_disconnect,opcua_subscribeandopcua_unsubscribe;MCP_ALLOWED_TOOLSre-enables named tools. Off by default, so existing setups see all 18 tools as before. - New: automatic recovery from a dead OPC-UA session. When the server
rejects a request with
BadSessionIDInvalidorBadServerNotConnected(for example after the server restarted or dropped the session), the client reconnects once with the same security settings and retries reads once. Writes are not replayed: they return an error saying the write was not applied, and the next call uses the new session. Subscriptions are restored after the reconnect. - Changed:
opcua_connectverifies the connection. When already connected it now probes the server and rebuilds the session if it is no longer usable, instead of only reporting "Already connected". - Fixed:
opcua_disconnectstays disconnected. Disconnecting no longer makes the subscription reconnect watcher bring the connection back.
Contributing
Fork it, make your changes, open a PR - see CONTRIBUTING.md.
License
来源:README.md,提交 62f6121
工具
0版本历史
1- v1.0.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分