modbus-copilot

modbus-copilot

Ask a Modbus device questions by tag name instead of register number. Provides read-only tools to list devices, search tags, and read values with provenance.

Category
访问服务器

README

modbus-copilot

Ask a Modbus device questions by tag name instead of by register number.

you:     what's the suction pressure on Pump-01?
claude:  2.0 bar — holding register 0, raw 20, scaled x0.1, read 1s ago

Not this, which is what a raw Modbus MCP server gives you:

you:     read holding registers 40001 to 40010

That difference is the whole project. A Modbus device answers questions about register 40001. An engineer asks about suction pressure. The meaning in between lives in a vendor PDF and in the head of whoever commissioned the panel.

Write-up: I gave Claude a live Modbus device


Run the whole lab

Two simulated devices, Node-RED polling them, an MCP server, and a setup UI:

git clone https://github.com/aradhsai/modbus-copilot
cd modbus-copilot
docker compose up -d
MCP endpoint http://localhost:1882/mcp
Setup UI http://localhost:3002
Node-RED editor http://localhost:1882
Pump / chiller (Modbus TCP) localhost:5022 / localhost:5023

Ports are off the defaults because 1880 and 3000 are usually taken on a machine that runs other things. Override with NODERED_PORT, WIZARD_PORT, PUMP_PORT, CHILLER_PORT.

Connect Claude Desktop

{
  "mcpServers": {
    "modbus-copilot": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "http://127.0.0.1:1882/mcp", "--allow-http"]
    }
  }
}

Claude Desktop launches stdio servers, so a bare { "url": ... } will not work — mcp-remote bridges stdio to the HTTP endpoint. With a token set, add "--header", "Authorization: Bearer <token>".

Then ask it: what devices can you see? · give me a snapshot of both · where exactly did that number come from?

It does not write

There is no write tool. Not disabled by a flag, not gated behind a role — absent from the codebase, so no misconfiguration can enable one.

An LLM holding a writable handle to running plant is a bad idea, and the only way to be certain a misconfiguration cannot enable one is for the code not to exist. If you need supervisory writes, build that path deliberately, with an interlock and an operator in front of it. Do not inherit it from a chat client.

The profile is the asset

One YAML file per device model. Version it, review it, share it — so one person's afternoon with the vendor manual becomes a reusable artefact instead of tribal knowledge.

device:
  name: Pump-01
  host: 192.0.2.10
  unit_id: 1
  byte_order: big
  word_order: big      # stated, never defaulted

tags:
  - name: suction_pressure
    kind: holding
    address: 0          # the manual says 40001
    type: uint16
    scale: 0.1
    unit: bar

Two things it is strict about, because both are where Modbus work quietly goes wrong:

Addresses are zero-based protocol addresses. A manual saying 40001 means holding register 0. The conversion happens once, at import, so nothing downstream has to work out which convention a number is written in.

Word order must be declared. A 32-bit value assembled the wrong way round produces a number that looks plausible and is wrong, which is worse than an error. A profile that does not say is rejected at load.

Check the map before you trust it

node tools/validate.js --profile profiles/pump-01.yaml --host localhost --port 5022

Reads every tag several times and reports what answers, what never moves, and what does not exist. Findings roll up: if every tag under a branch is unreachable then the branch is the finding, one line rather than forty.

▲  3 live · 3 static · 0 zero · 3 unreachable

✗  Plant-Room/Dosing-01   NOT RESPONDING — 3 tags, none answered.
                          One cause, not 3: wrong address block, unwired card, or device offline.
●  Plant-Room/Pump-01     3 live · 3 static
      running_hours              214.00 h    holding@20
         ↳ word_order: reads 214 as mapped, 14024704 with words swapped — confirm which is right

It deliberately knows nothing about processes. An earlier version carried plausible ranges per unit so it could catch a missing scale factor; it passed a temperature reading 386 °C because the band was wide, and narrowing the band would have failed legitimate plants. There is no setting that works, because the information needed is not in the tag map — and a tool that argues with an engineer about their own process gets uninstalled. What is left is structural and generalises to any device.

Import a tag database

node tools/import-csv.js --in samples/site-taglist.csv --device Site-A --host 192.0.2.10

Column names are matched loosely, 4xxxx/3xxxx/1xxxx/0xxxx are converted, and Area/Equipment columns become the hierarchy the report rolls up by.

Tools the model gets

Tool Answers
list_devices what is configured
list_tags every point, with units
search_tags "which tags mention temperature?"
read_tag one point, with provenance
read_tags several, sharing a moment
read_all a snapshot

The tag map is exposed as tools rather than pasted into a prompt, because small models act on tools and ignore paragraphs.

Architecture

device ──▶ Node-RED ──▶ tag layer ──▶ MCP ──▶ assistant
           any protocol   name · unit ·        read-only
                          scale · age

Node-RED does acquisition, and that is the point rather than a compromise: node-red-contrib-modbus alone gets ~12,400 downloads a week, and the same ecosystem covers OPC UA, S7 and BACnet. What it has never had is a tag model. Add one, and adding a protocol becomes a wiring job rather than a code change.

Not production

The simulator behaves like plant — the pump's discharge follows a curve, its bearing holds heat, the chiller's delta-T narrows as load falls — but it is still a simulator behaving well. A real panel has a serial gateway that drops requests under load, a manual that disagrees with the device, and a unit ID nobody wrote down. Take this as a commissioning aid and a starting point, not a product.

Credit

The idea of putting Modbus behind MCP is not mine — alejoseb/ModbusMCP got there first and proved the shape. This takes a different line: it adds the semantic layer, and it drops write support on purpose.

Apache-2.0.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选