platform-mcp-tool-widget-coordinate
Rendering a Custom MCP Tool Output With a Widget
Coordinate two object-based Custom Lightning Types (CLTs) and an HXL widget to render the output of a custom MCP server tool whose implementation is an Apex @InvocableMethod. This skill never authors content directly — it loads and invokes leaf skills in dependency order, gates progress on user approval, and runs validation gates before reporting completion.
Ownership boundary — this skill owns only:
- the MCP-tool use case — resolving the tool's output shape and orchestrating the leaf skills in the right order; and
- the envelope CLT's default
renderer.json— the one artifact it authors inline, bridging the envelope to the widget.
The CLTs are authored by platform-custom-lightning-type-generate, and all widget metadata (schema + body + .uiwidget-meta.xml) is authored and validated by platform-widget-generate. This skill never writes widget metadata and never modifies the Apex class — it supplies each leaf skill its inputs and wires the result together.
Scope
Custom MCP server tools backed by an Apex Invocable Action only. The MCP tool returns the platform's invocable-action result envelope — an object with actionName, isSuccess, and an outputValues node that carries the tool's real payload. To render this envelope with a widget, model it as two object-based CLTs (lightning__objectType) of equal standing — the only reason there are two is that one must reference the other by name (a CLT cannot reference itself), so they need distinct deployed names. Name and describe each by what it actually models — never by an invented role-label pair like "Payload CLT"/"Envelope CLT" or "Inner CLT"/"Outer CLT":
- The CLT that mimics the tool-result envelope, named
<toolApiName>. ItsoutputValuesproperty is typed to the other CLT viac__<responseCLT>(the CLT-reference prefix — see the namespace note below). - The CLT that is the exact shape of the Invocable Action's response (
@InvocableVariablefields on the@InvocableMethodresponse class), named<toolApiName>Response— "Response" is not an invented role word; it is the word the Apex source itself uses for that class.
The widget grounds on the response fields (flat), and the default renderer.json in the envelope CLT bridges the envelope nesting to the flat widget via {!$attrs.outputValues.<field>}.