feat(expert): fetch flow-building tool catalog over MQTT - #8293
Conversation
…MQTT Replace the HTTP GET to the Expert service /mcp/flow-tools with an MQTT request to the gateway's list_flow_catalog meta-tool via the existing MCP gateway proxy. This removes the Expert service token from the tool-catalog path; the catalog is session-less so no team or scope context is sent, and a gateway failure degrades to the platform tools alone.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8293 +/- ##
==========================================
+ Coverage 77.34% 77.35% +0.01%
==========================================
Files 466 467 +1
Lines 25245 25277 +32
Branches 6720 6730 +10
==========================================
+ Hits 19525 19553 +28
- Misses 5720 5724 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…topic Move the flow-building catalog fetch off the third-party MCP session channel (ff/v1/mcp/<platformId>/<userId>/<mcpSessionId>) onto a dedicated first-party topic (ff/v1/mcp/catalog/<platformId>). The catalog is global and session-less, so the topic carries no user or session, and its ACL is not gated on the mcpThirdParty feature - deployments without third-party MCP still get the permissions-UI catalog. - mcpGateway: proxyCatalogRequest publishes on the catalog topic - commsClient: handle the catalog response and subscribe per-replica - aclManager: checkMcpCatalogTopic verify + forge_platform pub/sub rules - bridge: forward the catalog request and add a source for its response
|
not a review - just a quick eye over this. This PR introduces yet another topic for the bridge. I suspect we could use an existing topic channel e.g. ff/v1/mcp/+/+/+/request already. Could just set the "userid" and "mcpSessionId" fields of that topic as something arbitrary/known/checked e.g. |
# Conflicts: # forge/comms/aclManager.js
…channel Fetch the flow-building tool catalog over the existing third-party MCP request/response channel instead of a dedicated ff/v1/mcp/catalog/... topic, marked by a sentinel userId. The ACL treats that value as a first-party read: exempt from the mcpThirdParty gate and the user lookup, with every other topic check still applied. The EMQX bridge and the central gateway need no new topic, source or handler.
Move the CallToolResult unwrap out of the catalog route into a shared parseMcpToolResult helper, so other MCP-over-MQTT tool-call results can reuse it.
…lures Give the catalog request its own short budget instead of reusing the 60s HTTP timeout, so an MQTT publish to an absent bridge no longer blocks GET /mcp/tools for a full minute. Warn when the gateway returns an error, an error tool result, or an unparseable response, so a broken gateway is distinguishable from an empty flow catalog. Fold two identical catalog ACL tests into one.
Closes #8611
Description
The
/api/v4/expert/mcp/toolsroute (tool-permissions catalog, added in #7639) builds the list of tools shown in the permissions UI. It previously fetched the flow-building tools with a directaxios.getto the Expert instance's/mcp/flow-toolsendpoint, authenticated with theexpert.service.token.This replaces that HTTP fetch with a request over MQTT to the gateway's
list_flow_catalogtool, reusing the existing third-party MCP request/response channel:ff/v1/mcp/<platformId>/flow-building-tool-catalog/<uuid>/requestff/v1/mcp/<platformId>/flow-building-tool-catalog/<uuid>/responseThe
flow-building-tool-catalogsentinel sits in theuserIdtopic level to mark the fetch as the first-party, session-less catalog read.Design points:
ff/v1/mcp/+/+/+/request/.../response), so no new bridge source, rule, or gateway handler is required.list_flow_catalogis already a registered tool on the gateway's MCP server, so the request is served by the same dispatch as any other MCP call.mcpThirdParty. The ACL recognises the sentineluserIdand treats it as a first-party read: exempt from the third-party feature gate and from the user lookup. Every other check (platform client, platformId shape, topic-safe session id) still applies, so the sentinel can only perform the designed request/response exchange. Deployments that have not enabled third-party MCP still get the permissions-UI catalog.Backward compatibility
Forge no longer sends the service token on this path. The Expert instance keeps its HTTP
/mcp/flow-toolsendpoint for older Forge deployments; new Forge uses MQTT only, with no HTTP fallback.Testing
Unit tests cover the sentinel ACL path (including that the catalog channel works with
mcpThirdPartydisabled and without a real user, while the topic-shape checks still apply) and the route fetching the catalog over MQTT. Validated live on a self-hosted deployment with the central broker.