
Sparkplug B
io.github.nagarjunr由 GitHub 帳號 nagarjunr 發布v0.1.0更新於 Oct 24, 2026
MCP server for Sparkplug B: node/device discovery, metrics, commands, host state over MQTT.
概覽
Sparkplug B MCP 伺服器,作為 MQTT 上的主宿主應用,讓助理探索邊緣節點與裝置、讀取指標、下達命令並監聽即時訊息。
- 可以做什麼
- 查看 Broker 連線狀態,並發布此連接器自身的保留 STATE 訊息
- 列出已探索的邊緣節點與裝置,讀取其最新指標值
- 向節點與裝置送出命令以寫入指標,並可要求節點重新發布 NBIRTH
- 啟動、讀取、列出與停止監聽工作階段,緩衝符合篩選條件的已解碼 Sparkplug 訊息
- 適用情境
- 適合助理需要檢視或操作 MQTT Broker 上工業/SCADA Sparkplug B 部署的情況:探索節點與裝置、讀取即時指標、下達命令,或監控出生、死亡與資料訊息。
- 執行需求
- 以 Python 套件透過 uvx 在本機以 stdio 執行。需要可連線的 MQTT Broker,以及必要的環境變數 SPARKPLUG_MQTT_HOST 與 SPARKPLUG_HOST_ID;選用設定包含連接埠、使用者名稱/密碼、TLS 與 CA/用戶端憑證、用戶端 ID、keepalive、連線逾時與群組篩選。僅支援桌面端。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Sparkplug B,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Sparkplug B MCP Server
A Model Context Protocol (MCP) server for Sparkplug B — the Eclipse-standard MQTT topic/payload convention for industrial/SCADA data (birth/death certificates, sequenced metrics, protobuf payloads). Works against any MQTT broker that carries Sparkplug B traffic; only the open Sparkplug B specification is used, no vendor-specific extensions.
This server acts as a Sparkplug B Primary Host Application: it subscribes to the entire spBv1.0 namespace, discovers Edge Nodes and Devices from their NBIRTH/DBIRTH messages, tracks their live metrics, and can send them commands (NCMD/DCMD) — the same role a SCADA/historian host application plays in a real deployment.
Built with FastMCP and pysparkplug (itself built on paho-mqtt).
Tools
Why watching is session-based
Like the MQTT wire protocol underneath it, Sparkplug B is a continuous stream, not a request/response API — a single MCP tool call can't "wait forever" for the next birth or data message. start_watch registers an optional filter (group/node/device/message-type) and buffers matching decoded messages in the background (this connector is always subscribed to the whole spBv1.0 namespace, so no extra broker subscription is needed per watch); get_events drains that buffer, optionally waiting a bounded amount of time for new data. Call stop_watch when done.
Supported metric datatypes
INT8/INT16/INT32/INT64, UINT8/UINT16/UINT32/UINT64, FLOAT, DOUBLE, BOOLEAN, STRING, TEXT, UUID, DATETIME, BYTES, FILE, and their *_ARRAY variants. DATASET, TEMPLATE, PROPERTYSET, and PROPERTYSETLIST are part of the Sparkplug B spec but unsupported by the underlying pysparkplug codec, so they're rejected with a clear error rather than silently mishandled.
For send_node_command/send_device_command, value shape depends on datatype: plain int/float/bool/str for scalars, an ISO 8601 string for DATETIME, a base64 string for BYTES/FILE, and a JSON list for *_ARRAY types.
Configuration
Running locally
See mcp.json for ready-to-use client configs (stdio and Docker).
Testing against a real broker
This repo's design principles call for testing against a real instance rather than mocks. docker-compose.yml spins up Eclipse Mosquitto (2.x) with an anonymous listener for local testing. Test fixtures use pysparkplug's own EdgeNode/Device classes to act as real simulated PLCs/devices — publishing genuine NBIRTH/DBIRTH/NDATA/DDATA/NDEATH messages and receiving genuine NCMD/DCMD commands over the wire — so coverage is protocol-level, not hand-rolled mocks. Only the "physical" node/device is simulated, since no free real PLC/edge-node hardware exists to test against; the Sparkplug B protocol handling on both sides is real.
License notes
docker-compose.yml and the files under docker/ configure the open-source Eclipse Mosquitto broker (EPL-2.0) for local testing only — they are not part of the MCP server itself.
來源:sparkplug-b/README.md,提交 5a985b6
工具
0版本歷史
1- v0.1.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分