feat: Add insights support#668
Conversation
| sendCommandResponse (request, response) { | ||
| const correlationData = request?.correlationData | ||
| const responseTopic = request?.responseTopic || this.responseTopic | ||
| const userProperties = request?.userProperties || {} |
There was a problem hiding this comment.
Confused with this name that it was msg.properties.userProperties (MQTTv5) not just a filed on the JSON in the msg.payload
There was a problem hiding this comment.
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,
hardillb
left a comment
There was a problem hiding this comment.
Just a question about a command to clear up
And confirmation that this shouldn't need MQTTv5 for the userProperties stuff
|
@hardillb hopefully answered yer questions (re-requested review) |
|
@Steve-Mcl approved, but @cstns should look at the |
|
@cstns check answers to comments & reply/resolve/suggest please - wanna get this moving. |
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_modulesdirectory of thenr-mcp-server-nodes. The logic/reasoning is :-Details
MCP SDK Integration and Lifecycle Management:
lib/mqtt.js) now instantiates anMCPhelper, making MCP features available for MQTT command handling. [1] [2]Launcherclass (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:
get-liveState,mcp:get-features,mcp:call-tool, andmcp:read-resource, delegating these to the MCP helper and sending structured responses or errors as appropriate.MQTT Command Response Improvements:
sendCommandResponsemethod now includesuserPropertiesfrom the request in the response message, allowing for richer metadata propagation. [1] [2]Dependency Management:
pathmodule is now required inlib/mqtt.jsto support MCP instantiation.Related Issue(s)
Checklist
flowforge.yml?FlowFuse/helmto update ConfigMap TemplateFlowFuse/CloudProjectto update values for Staging/ProductionLabels
area:migrationlabel