Skip to content

feat: Add insights support#668

Merged
Steve-Mcl merged 6 commits into
mainfrom
625-insights-support
Jun 25, 2026
Merged

feat: Add insights support#668
Steve-Mcl merged 6 commits into
mainfrom
625-insights-support

Conversation

@Steve-Mcl

Copy link
Copy Markdown
Contributor

Description

TLDR

Add support for MCP tasks (get features, call tool, read resource) command-able via the established command-response pattern (over MQTT) - thus permitting AI Insights Agent to request/execute MCP things via bridge.

Add support for requesting live-state from the device (via command-response pattern (over MQTT)) so that live state can be queried before attempting (and timing out) to get MCP features / execute MCP thing.

NOTE: To avoid adding the MCP SDK to the dependencies, they are loaded from the node_modules directory of the nr-mcp-server-nodes. The logic/reasoning is :-

  1. the MCP SDK is a fast changing package
  2. if mcp server nodes are not installed, there is no need for this lib to be installed or instantiated
  3. version parity with MCP server nodes is maintained

Details

MCP SDK Integration and Lifecycle Management:

  • The MQTT client (lib/mqtt.js) now instantiates an MCP helper, making MCP features available for MQTT command handling. [1] [2]
  • The Launcher class (lib/launcher.js) now resets any cached MCP SDK reference both when starting and stopping, ensuring that the SDK is always up-to-date and not reused if the underlying files have changed. [1] [2]

New MQTT Command Support:

  • The MQTT client now handles several new commands: get-liveState, mcp:get-features, mcp:call-tool, and mcp:read-resource, delegating these to the MCP helper and sending structured responses or errors as appropriate.

MQTT Command Response Improvements:

  • The sendCommandResponse method now includes userProperties from the request in the response message, allowing for richer metadata propagation. [1] [2]

Dependency Management:

  • The path module is now required in lib/mqtt.js to support MCP instantiation.

Related Issue(s)

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@Steve-Mcl Steve-Mcl requested review from cstns and hardillb June 25, 2026 07:53
@Steve-Mcl Steve-Mcl changed the title Add insights support Feat: Add insights support Jun 25, 2026
@Steve-Mcl Steve-Mcl changed the title Feat: Add insights support feat: Add insights support Jun 25, 2026
Comment thread lib/mqtt.js
sendCommandResponse (request, response) {
const correlationData = request?.correlationData
const responseTopic = request?.responseTopic || this.responseTopic
const userProperties = request?.userProperties || {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused with this name that it was msg.properties.userProperties (MQTTv5) not just a filed on the JSON in the msg.payload

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are correct. As device agent is currently (from inception) using the MQTT default protocol version v4 (3.1) v5 properties are not available. What we do to achieve req-resp pattern is to nest the payload in the MQTT payload (request object) and add the correlationData for tracking responses.
This addition here includes userProperties so that we have the ability to pass through (and pass back) any user properties that need to be carried through,

Comment thread lib/mqtt.js

@hardillb hardillb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question about a command to clear up

And confirmation that this shouldn't need MQTTv5 for the userProperties stuff

@Steve-Mcl

Copy link
Copy Markdown
Contributor Author

@hardillb hopefully answered yer questions (re-requested review)

@Steve-Mcl Steve-Mcl requested a review from hardillb June 25, 2026 09:05
@hardillb

Copy link
Copy Markdown
Contributor

@Steve-Mcl approved, but @cstns should look at the mcp.js file

Comment thread lib/mcp.js Outdated
Comment thread lib/mcp.js
Comment thread lib/mcp.js
@Steve-Mcl

Copy link
Copy Markdown
Contributor Author

@cstns check answers to comments & reply/resolve/suggest please - wanna get this moving.

@Steve-Mcl Steve-Mcl mentioned this pull request Jun 25, 2026
@Steve-Mcl Steve-Mcl merged commit a653c29 into main Jun 25, 2026
9 checks passed
@Steve-Mcl Steve-Mcl deleted the 625-insights-support branch June 25, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants