@salesforce/afv-skills 1.68.0 → 1.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/package.json +1 -1
  2. package/skills/afcc-setup-coordinate/SKILL.md +348 -0
  3. package/skills/afcc-setup-coordinate/assets/console-app/AFCC_Service_Console.app-meta.xml +19 -0
  4. package/skills/afcc-setup-coordinate/assets/console-app/Admin.profile-meta.xml +8 -0
  5. package/skills/afcc-setup-coordinate/assets/console-app/Standard.profile-meta.xml +8 -0
  6. package/skills/afcc-setup-coordinate/assets/gap_report_template.md +35 -0
  7. package/skills/afcc-setup-coordinate/assets/org_profile_template.json +16 -0
  8. package/skills/afcc-setup-coordinate/references/gotchas.md +22 -0
  9. package/skills/afcc-setup-coordinate/scripts/audit_org.sh +159 -0
  10. package/skills/agentforce-bot-upgrade/SKILL.md +117 -66
  11. package/skills/agentforce-bot-upgrade/assets/_vendored/agent-spec-template.md +139 -0
  12. package/skills/agentforce-bot-upgrade/references/_vendored/agent-design-and-spec-creation.md +1211 -0
  13. package/skills/agentforce-bot-upgrade/references/_vendored/agent-script-core-language.md +1390 -0
  14. package/skills/agentforce-bot-upgrade/references/_vendored/agent-subagent-map-diagrams.md +341 -0
  15. package/skills/agentforce-bot-upgrade/references/_vendored/agent-user-setup.md +672 -0
  16. package/skills/agentforce-bot-upgrade/references/_vendored/agent-validation-and-debugging.md +904 -0
  17. package/skills/agentforce-bot-upgrade/references/_vendored/agentscript-toolchain.md +112 -0
  18. package/skills/agentforce-bot-upgrade/references/_vendored/architecture-patterns.md +277 -0
  19. package/skills/agentforce-bot-upgrade/references/_vendored/common-control-flow-pitfalls.md +255 -0
  20. package/skills/agentforce-bot-upgrade/references/_vendored/control-flow-actions-sequencing.md +198 -0
  21. package/skills/agentforce-bot-upgrade/references/_vendored/control-flow-lifecycle-side-effects.md +87 -0
  22. package/skills/agentforce-bot-upgrade/references/_vendored/data-library-reference.md +891 -0
  23. package/skills/agentforce-bot-upgrade/references/_vendored/instruction-resolution.md +658 -0
  24. package/skills/agentforce-bot-upgrade/references/_vendored/org-setup-for-adl.md +551 -0
  25. package/skills/agentforce-bot-upgrade/references/_vendored/patterns-by-requirement.md +88 -0
  26. package/skills/agentforce-bot-upgrade/references/_vendored/posture-and-determinism.md +215 -0
  27. package/skills/agentforce-bot-upgrade/references/extraction-blueprint.md +11 -4
  28. package/skills/agentforce-bot-upgrade/references/generate-agent-spec.md +19 -3
  29. package/skills/agentforce-bot-upgrade/references/handoff-output-format.md +82 -52
  30. package/skills/agentforce-bot-upgrade/references/input-contract.md +8 -8
  31. package/skills/agentforce-bot-upgrade/references/mapping-rules.md +19 -6
  32. package/skills/agentforce-bot-upgrade/references/post-conversion-enhancements-reference.md +65 -6
  33. package/skills/agentforce-bot-upgrade/references/quality-checklist.md +4 -4
  34. package/skills/agentforce-bot-upgrade/references/sf-cli-bot-reference.md +17 -3
  35. package/skills/agentforce-hyperclassifier-configure/README.md +24 -0
  36. package/skills/agentforce-hyperclassifier-configure/SKILL.md +111 -0
  37. package/skills/agentforce-hyperclassifier-configure/assets/customer-org.env.example +4 -0
  38. package/skills/agentforce-hyperclassifier-configure/assets/sample_descriptions.json +8 -0
  39. package/skills/agentforce-hyperclassifier-configure/assets/sample_evals.csv +17 -0
  40. package/skills/agentforce-hyperclassifier-configure/references/api-contract.md +41 -0
  41. package/skills/agentforce-hyperclassifier-configure/references/authentication.md +35 -0
  42. package/skills/agentforce-hyperclassifier-configure/references/evaluation.md +46 -0
  43. package/skills/agentforce-hyperclassifier-configure/references/installation.md +35 -0
  44. package/skills/agentforce-hyperclassifier-configure/references/onboarding.md +93 -0
  45. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/__init__.py +1 -0
  46. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/client.py +219 -0
  47. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/eca.py +178 -0
  48. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/evaluation.py +207 -0
  49. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/onboarding.py +191 -0
  50. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/optimizer.py +187 -0
  51. package/skills/agentforce-hyperclassifier-configure/scripts/hyperclassifier.py +111 -0
  52. package/skills/agentforce-hyperclassifier-configure/scripts/report_hyperclassifier.py +149 -0
  53. package/skills/agentforce-hyperclassifier-configure/scripts/setup_hyperclassifier.py +74 -0
  54. package/skills/agentforce-hyperclassifier-configure/scripts/tests/test_hyperclassifier_skill.py +887 -0
  55. package/skills/agentforce-offline-experimentation-run/scripts/btlib/judge.py +23 -31
  56. package/skills/agentforce-offline-experimentation-run/scripts/btlib/messages.py +2 -1
  57. package/skills/agentforce-offline-experimentation-run/scripts/btlib/sfap.py +118 -2
  58. package/skills/agentforce-offline-experimentation-run/scripts/build_report.py +2 -2
  59. package/skills/agentforce-offline-experimentation-run/scripts/resolve-token.sh +9 -2
  60. package/skills/agentforce-offline-experimentation-run/scripts/sfap_replay.py +12 -1
  61. package/skills/commerce-react-storefront-create/SKILL.md +54 -21
  62. package/skills/dx-lifecycle-center/SKILL.md +24 -18
  63. package/skills/dx-lifecycle-center/examples/workflows.md +57 -34
  64. package/skills/dx-lifecycle-center/references/connect-api.md +33 -4
  65. package/skills/dx-lifecycle-center/references/connect-org.md +59 -28
  66. package/skills/dx-lifecycle-center/references/deploy.md +3 -3
  67. package/skills/dx-lifecycle-center/references/hub-org.md +19 -3
  68. package/skills/dx-lifecycle-center/references/list-orgs.md +50 -24
  69. package/skills/dx-lifecycle-center/references/troubleshooting.md +22 -1
  70. package/skills/dx-lifecycle-center/scripts/hub-get.sh +41 -0
  71. package/skills/dx-lifecycle-center/scripts/resolve-environment.sh +151 -4
  72. package/skills/dx-packaging-convert-1gp-to-2gp-create/SKILL.md +63 -0
  73. package/skills/dx-packaging-convert-1gp-to-2gp-create/references/conversion-operations.md +252 -0
  74. package/skills/dx-packaging-move-to-2gp-migrate/SKILL.md +2 -3
  75. package/skills/dx-packaging-move-to-2gp-migrate/references/api-operations.md +10 -7
  76. package/skills/dx-packaging-push-upgrade-configure/README.md +47 -0
  77. package/skills/dx-packaging-push-upgrade-configure/SKILL.md +355 -0
  78. package/skills/dx-packaging-push-upgrade-configure/references/best-practices.md +61 -0
  79. package/skills/dx-packaging-push-upgrade-configure/references/cli-reference.md +148 -0
  80. package/skills/dx-packaging-push-upgrade-configure/references/objects.md +106 -0
  81. package/skills/dx-packaging-push-upgrade-configure/references/soql-recipes.md +144 -0
  82. package/skills/experience-afv-analytics-query/SKILL.md +239 -0
  83. package/skills/experience-afv-analytics-query/references/references.md +176 -0
  84. package/skills/experience-app-mcp-delivery-generate/SKILL.md +142 -0
  85. package/skills/experience-app-mcp-delivery-generate/references/eca-consumer-key.md +26 -0
  86. package/skills/experience-app-mcp-delivery-generate/references/mcp-config-delivery.md +38 -0
  87. package/skills/experience-app-mcp-delivery-generate/references/plugin-format-and-publishing.md +80 -0
  88. package/skills/experience-app-mcp-delivery-generate/scripts/developer_name.mjs +9 -0
  89. package/skills/experience-app-mcp-delivery-generate/scripts/discover_mcp_context.mjs +114 -0
  90. package/skills/experience-app-mcp-delivery-generate/scripts/generate_mcp_config.mjs +27 -0
  91. package/skills/experience-app-mcp-delivery-generate/scripts/generate_plugin.mjs +184 -0
  92. package/skills/experience-app-mcp-delivery-generate/scripts/mcp_config.mjs +57 -0
  93. package/skills/experience-app-mcp-delivery-generate/scripts/preflight.mjs +109 -0
  94. package/skills/experience-app-mcp-delivery-generate/scripts/retrieve_eca_consumer_key.mjs +143 -0
  95. package/skills/experience-app-mcp-generate/SKILL.md +174 -0
  96. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.eca-meta.xml +7 -0
  97. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaGlblOauth-meta.xml +15 -0
  98. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaOauth-meta.xml +6 -0
  99. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaOauthPlcy-meta.xml +12 -0
  100. package/skills/experience-app-mcp-generate/assets/__ECA_NAME___defaultPolicy.ecaPlcy-meta.xml +7 -0
  101. package/skills/experience-app-mcp-generate/assets/__MCP_SERVER_NAME__.mcpServerDefinition-meta.xml +5 -0
  102. package/skills/experience-app-mcp-generate/references/eca-fields.md +76 -0
  103. package/skills/experience-app-mcp-generate/references/mcp-objects.md +66 -0
  104. package/skills/experience-app-mcp-generate/references/tool-bindings.md +85 -0
  105. package/skills/experience-app-mcp-generate/references/troubleshooting.md +41 -0
  106. package/skills/experience-app-mcp-generate/references/ui-frameworks.md +19 -0
  107. package/skills/experience-app-mcp-generate/references/widget-resources.md +96 -0
  108. package/skills/experience-app-mcp-generate/scripts/activate_server.mjs +166 -0
  109. package/skills/experience-app-mcp-generate/scripts/check_setup_progress.mjs +212 -0
  110. package/skills/experience-app-mcp-generate/scripts/list_sites.mjs +211 -0
  111. package/skills/experience-app-mcp-generate/scripts/merge_tools.mjs +407 -0
  112. package/skills/experience-app-mcp-generate/scripts/preflight.mjs +127 -0
  113. package/skills/experience-app-mcp-generate/scripts/render_eca.mjs +144 -0
  114. package/skills/experience-app-mcp-generate/scripts/render_mcp_server.mjs +64 -0
  115. package/skills/experience-app-mcp-generate/scripts/retrieve_existing_prompts.mjs +145 -0
  116. package/skills/experience-app-mcp-generate/scripts/retrieve_existing_tools.mjs +72 -0
  117. package/skills/experience-app-mcp-generate/scripts/scan_tool_candidates.mjs +195 -0
  118. package/skills/experience-app-mcp-generate/scripts/utils/callback_url.mjs +36 -0
  119. package/skills/experience-app-mcp-generate/scripts/utils/developer_name.mjs +9 -0
  120. package/skills/experience-app-mcp-generate/scripts/utils/eca_check.mjs +156 -0
  121. package/skills/experience-app-mcp-generate/scripts/utils/metadata_path.mjs +13 -0
  122. package/skills/experience-app-mcp-generate/scripts/verify_server.mjs +118 -0
  123. package/skills/experience-cms-content-type-generate/SKILL.md +1 -1
  124. package/skills/nonprofit-fundraising-configure/SKILL.md +1 -1
  125. package/skills/nonprofit-fundraising-configure/references/mcp-invocation.md +52 -4
  126. package/skills/nonprofit-fundraising-configure/references/permission-targeting.md +19 -2
  127. package/skills/platform-custom-field-generate/SKILL.md +24 -16
  128. package/skills/platform-custom-metadata-type-generate/SKILL.md +1 -0
  129. package/skills/platform-custom-setting-generate/SKILL.md +1 -0
  130. package/skills/platform-dataspace-access-configure/SKILL.md +25 -10
  131. package/skills/platform-flexipage-generate/SKILL.md +7 -10
  132. package/skills/platform-flexipage-generate/references/mcp_action_examples.md +42 -38
  133. package/skills/platform-policy-rule-generate/SKILL.md +9 -7
  134. package/skills/platform-policy-rule-generate/references/condition-model.md +3 -3
  135. package/skills/platform-policy-rule-generate/references/conjunction-expression.md +9 -1
  136. package/skills/platform-policy-rule-generate/references/consumer-datacloud-ui.md +9 -1
  137. package/skills/platform-policy-rule-generate/references/examples/ExistsJoinRLS/policyRuleDefinitionSets/ExistsJoinRLS.policyRuleDefinitionSet +1 -2
  138. package/skills/platform-policy-rule-generate/references/examples/FieldReadDeny/policyRuleDefinitionSets/FieldReadDeny.policyRuleDefinitionSet +1 -2
  139. package/skills/platform-policy-rule-generate/references/examples/LastCharactersFieldMasking/policyRuleDefinitionSets/LastCharactersFieldMasking.policyRuleDefinitionSet +1 -2
  140. package/skills/platform-policy-rule-generate/references/examples/PrincipalFieldMatchRLS/policyRuleDefinitionSets/PrincipalFieldMatchRLS.policyRuleDefinitionSet +1 -2
  141. package/skills/platform-policy-rule-generate/references/examples/TaggedObjectAccess/policyRuleDefinitionSets/TaggedObjectAccess.policyRuleDefinitionSet +1 -0
  142. package/skills/platform-policy-rule-generate/references/headless-transport.md +2 -2
  143. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +1 -1
  144. package/skills/platform-policy-rule-generate/references/policy-shapes.md +33 -0
  145. package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
  146. package/skills/platform-policy-rule-generate/references/ui-compatibility.md +5 -5
  147. package/skills/platform-report-generate/SKILL.md +20 -1
  148. package/skills/platform-report-generate/references/summary-formulas-sorting-limits.md +118 -0
  149. package/skills/platform-report-generate/references/verification-checklist.md +12 -0
  150. package/skills/service-digital-engagement-channel-configure/SKILL.md +44 -107
  151. package/skills/service-digital-engagement-channel-configure/assets/messaging_channel_template.xml +2 -0
  152. package/skills/service-digital-engagement-channel-configure/examples/asa_agent_channel.xml +2 -2
  153. package/skills/service-digital-engagement-channel-configure/examples/auth_queue_channel.xml +58 -0
  154. package/skills/service-digital-engagement-channel-configure/examples/omni_flow_channel.xml +2 -2
  155. package/skills/service-digital-engagement-channel-configure/examples/omni_queue_channel.xml +3 -3
  156. package/skills/service-digital-engagement-channel-configure/references/channel_settings.md +18 -14
  157. package/skills/service-digital-engagement-channel-configure/references/onboarding_contract.md +16 -20
  158. package/skills/service-digital-engagement-channel-configure/references/prechat_params.md +10 -0
  159. package/skills/service-digital-engagement-channel-configure/references/recaptcha_handoff.md +38 -0
  160. package/skills/service-digital-engagement-channel-configure/references/user_verification.md +9 -0
  161. package/skills/service-digital-engagement-channel-configure/scripts/check-api-version.sh +4 -4
  162. package/skills/service-digital-engagement-channel-configure/scripts/normalize-channel-name.sh +12 -7
  163. package/skills/service-e911-configure/SKILL.md +242 -0
  164. package/skills/service-itsm-agentic-setup-agent-runtime-access-assign/SKILL.md +1 -1
  165. package/skills/service-itsm-agentic-setup-agentforce-coordinate/SKILL.md +1 -1
  166. package/skills/service-itsm-agentic-setup-agentforce-studio-configure/SKILL.md +1 -1
  167. package/skills/service-itsm-agentic-setup-agentforce-studio-validate/SKILL.md +1 -1
  168. package/skills/service-itsm-agentic-setup-employee-agent-configure/SKILL.md +1 -1
  169. package/skills/service-itsm-agentic-setup-fulfiller-agent-configure/SKILL.md +1 -1
  170. package/skills/service-itsm-agentic-setup-incident-management/SKILL.md +47 -44
  171. package/skills/service-itsm-agentic-setup-incident-management/examples/output-templates.md +110 -83
  172. package/skills/service-itsm-agentic-setup-incident-management/references/manage-incidents-with-ai.md +7 -3
  173. package/skills/service-itsm-agentic-setup-incident-management/references/priority-matrix.md +7 -5
  174. package/skills/service-itsm-agentic-setup-incident-management/references/sla-milestones.md +2 -2
  175. package/skills/service-itsm-agentic-setup-incident-management/references/status-checks.md +437 -0
  176. package/skills/service-itsm-agentic-setup-itsm-agentforce-permset-assign/SKILL.md +1 -1
  177. package/skills/agentforce-bot-upgrade/references/planner-workflow-reference.md +0 -78
  178. package/skills/dx-lifecycle-center/assets/widgets/connect-connected/connect-connected.json +0 -65
  179. package/skills/dx-lifecycle-center/assets/widgets/connect-connected/schema.json +0 -32
  180. package/skills/dx-lifecycle-center/assets/widgets/connect-sign-in/connect-sign-in.json +0 -57
  181. package/skills/dx-lifecycle-center/assets/widgets/connect-sign-in/schema.json +0 -21
  182. package/skills/dx-lifecycle-center/scripts/card-policy.jq +0 -71
  183. package/skills/dx-lifecycle-center/scripts/fill-widget.jq +0 -29
  184. package/skills/dx-lifecycle-center/scripts/widget.sh +0 -28
  185. package/skills/experience-content-media-image-generate/SKILL.md +0 -83
  186. package/skills/experience-content-media-image-generate/scripts/download-image.sh +0 -84
  187. package/skills/experience-content-media-stock-image-search/SKILL.md +0 -193
  188. package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +0 -102
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: experience-app-mcp-generate
3
+ description: "Create, extend, deploy, review readiness for, or activate an App MCP, a Salesforce custom hosted MCP server for an Aura Experience Site. Trigger when the user wants to expose an Experience UI or backend action to agents, create local ECA and server metadata, add eligible global invocable Apex or autolaunched Flow tools, add Prompt Builder templates as MCP prompts or tools, preview or perform server activation, deploy the existing MCP stack, or review its readiness. For server setup, offer optional HXL widgets for eligible Apex-backed tools through platform-mcp-tool-widget-coordinate. For a standalone request to generate Custom Lightning Types or widgets for an Apex-backed MCP tool, route directly to platform-mcp-tool-widget-coordinate; do not trigger this skill for HXL generation alone. Do not trigger for remote MCP registration or generic Apex and Flow work unrelated to Experience Site agent access."
4
+ metadata:
5
+ relatedSkills:
6
+ - experience-app-mcp-delivery-generate
7
+ - platform-apex-generate
8
+ - platform-mcp-tool-widget-coordinate
9
+ version: "1.0"
10
+ minApiVersion: "68.0"
11
+ domains:
12
+ - "Experience"
13
+ cliTools:
14
+ - tool:
15
+ - "node"
16
+ semver: ">=18.0.0"
17
+ - tool:
18
+ - "sf"
19
+ semver: ">=2.0.0"
20
+ ---
21
+
22
+ # Set Up Custom MCP for an Experience Site
23
+
24
+ End-to-end recipe: **ExternalClientApplication (ECA) → custom hosted MCP server → tools and prompts → deploy → optional HXL widgets + Custom Lightning Types + MCP widget resources → activate → verify → optional client delivery**. The Experience Site scopes naming and discovery; the MCP server is org-level.
25
+
26
+ Supports Aura Experience Sites with local ExperienceBundle source. The inventory checks the selected site's view components to determine source support.
27
+
28
+ ## Shared rules
29
+
30
+ - `<skill-dir>` means the absolute directory containing this `SKILL.md`. Keep the shell working directory at the SFDX project root, replace `<skill-dir>` before running bundled scripts, and resolve `references/...` links relative to this `SKILL.md`.
31
+ - Run Phase 0 before every entry path, including repair, resume, and preview/activate-only requests. Proceed only on `decision: continue`.
32
+ - Reconcile with existing state before creating or changing anything. Reuse compatible ECAs, servers, and tool bindings by default. On interruption, use [the progress check](#check-progress--after-phase-2-or-on-resume).
33
+ - `McpServerDefinition` and related runtime records are Tooling API objects. Query them with `sf data query --use-tooling-api` or `sf api request rest` against `/tooling/query`; the default `sf data query` endpoint does not support them.
34
+ - For authoring, create a missing `sfdx-project.json` with `packageDirectories` `[{"path": "force-app", "default": true}]` and `sourceApiVersion` `"68.0"`. Preserve existing configuration; review/deploy-only requests require an existing project.
35
+ - `<default-package>` is the `path` of the `packageDirectories` entry with `"default": true`, or the first entry when none is marked. Pass `<default-package>/main/default` as the metadata directory to the render scripts. Phase 1 still inspects every package directory for the site.
36
+ - Track the exact metadata files created or changed during the run. Phase 5 deploys only those MCP stack files or existing stack files selected for deployment; Phase 6 deploys only its generated artifacts and named server.
37
+ - Handle preflight results as specified in Phase 0. For later failures, stop and report what changed. Read the relevant section of `references/troubleshooting.md` before proposing recovery.
38
+
39
+ ## Review or deploy an existing stack
40
+
41
+ Run Phase 0, recover confirmed site/server/ECA identities, then use the progress check and [existing-stack review](references/mcp-objects.md#existing-stack-review). For readiness/review requests, inspect and report findings and unknowns only; do not create files, retrieve, repair, deploy, activate, or audit end-user permissions. For deployment requests, reconcile existing files and intended bindings, then continue at Phase 5 using applicable prior approvals; author only explicitly requested missing changes. Script success or file presence does not establish readiness.
42
+
43
+ ## Repair existing ECA or MCP metadata
44
+
45
+ For ECA files, run the renderer in read-only comparison mode:
46
+ ```bash
47
+ node "<skill-dir>/scripts/render_eca.mjs" <default-package>/main/default <ECA_DEV_NAME> --check
48
+ ```
49
+ Follow the report's field findings, `expectedValues`, and `nextActions`. To resolve `unverifiedFields`, rerun the Phase 2 render command with confirmed inputs plus `--check`. Differences are baseline findings, not automatic errors or permission to change intentional overrides. For field ownership, read [references/eca-fields.md](references/eca-fields.md).
50
+
51
+ For MCP repairs, read `assets/__MCP_SERVER_NAME__.mcpServerDefinition-meta.xml` and [references/mcp-objects.md](references/mcp-objects.md). Patch only approved root-field differences; preserve tools, prompts, resources, and relationships. Use `merge_tools.mjs` for binding changes.
52
+
53
+ ## Phase 0 — Preflight
54
+
55
+ IMPORTANT: Set `<skill-named>` to `true` only if the user's request explicitly names `experience-app-mcp-generate`; otherwise use `false`. Do not count the agent's own skill selection or messages.
56
+
57
+ ```bash
58
+ node "<skill-dir>/scripts/preflight.mjs" <target-org-alias> --skill-named <skill-named>
59
+ ```
60
+
61
+ Read the JSON `decision`:
62
+
63
+ - `continue`: follow the requested entry path; authoring starts at Phase 1. Proceed without mentioning preflight or explaining why it can't be skipped.
64
+ - `skip`: immediately exit this skill and pursue the original request another way. Say nothing about this skill, its check, or the result.
65
+ - `disabled`: say only the returned `userMessage`, without error details; exit this skill and pursue the original request another way.
66
+ - `needs_input` or `error`: show only `userMessage` and `nextAction`, obtain corrections and rerun preflight. Proceed only on `continue`; never infer entitlement from errors.
67
+
68
+ ## Phase 1 — Experience Site + naming
69
+
70
+ 1. **List local sites** from the SFDX project root:
71
+ ```bash
72
+ node "<skill-dir>/scripts/list_sites.mjs"
73
+ ```
74
+ Stop if the script fails. Report only each site's name and status, without framework, metadata/source-format labels, or extra discovery explanations. Match the user's site to an entry; if unclear, show the choices and ask the user to select one. The site scopes naming and UI review; the MCP server remains org-level.
75
+ 2. **Check the selected entry's status before continuing.** For `ready`, report **Ready** and continue with its supported Aura ExperienceBundle views. For `unsupported`, stop with a short report only: the site name and **Unsupported**, one sentence that this skill supports only Aura Experience Sites with local ExperienceBundle source, and that no ECA, MCP server, or tool bindings were created. Omit script output, framework details, file-by-file lists, and next steps unless asked; if you created `sfdx-project.json` only to run the scripts, mention it in one clause. For `metadata-incomplete`, report its `reason` when present and resolve the selected site's source errors or Network-to-bundle association; obtain its ExperienceBundle or DigitalExperienceBundle and Network metadata as needed, then rerun the inventory. Inspect the entry's metadata evidence for its Network name and `<urlPathPrefix>`. For `ui-not-found`, or a requested site absent from the inventory, ask the user to confirm the site and provide its ExperienceBundle source location or authorize retrieval, then rerun the inventory. Continue with a `ready` entry and usable UI source. Problems with unselected sites do not block this workflow.
76
+ 3. List deployed Experience Sites in the target org:
77
+ ```sql
78
+ SELECT Name, UrlPathPrefix FROM Network
79
+ ```
80
+ (via `sf data query` or Tooling REST.)
81
+ Reconcile the local and org results:
82
+ - If the site exists in both and the names and path prefixes agree, continue.
83
+ - If it exists only locally, treat it as a valid planned site and continue the local MCP generation workflow. The MCP server is org-level, so an undeployed Network does not block local MCP authoring. Report that the site is not deployed; do not claim there is no site or that nothing can be bound. Before Phase 5 deployment or Phase 7 activation, confirm that the site has been deployed by its owning workflow. Do not add unchanged site metadata to this skill's targeted deployment.
84
+ - If it exists only in the org, obtain its local site metadata as required by step 2 and rerun the inventory to determine source support before continuing.
85
+ - If local and org definitions conflict, show the mismatch and ask which definition is authoritative before continuing.
86
+ - Only report that the site must be created first when neither the local project nor the org contains it.
87
+ 4. Derive a `McpServerDefinition.DeveloperName` from the site name and let the user know. The MCP server name must contain 2–60 alphanumeric characters; remove spaces, punctuation, and other symbols. Check for a collision by querying existing MCP servers using tooling API:
88
+ ```bash
89
+ sf data query --use-tooling-api --target-org <target-org-alias> --query "SELECT Id, DeveloperName FROM McpServerDefinition" --json
90
+ ```
91
+ If a matching MCP Server already exists, then check with the user if it can be reused.
92
+ 5. Report to the user on whether we're creating a new MCP server with the derived name or if we're going to use an existing one.
93
+
94
+ ## Phase 2 — ECA (reuse-or-create)
95
+
96
+ When reviewing rendered ECA metadata or changing its settings after rendering, read `references/eca-fields.md` to locate the owning metadata component and field. Treat callback URLs, OAuth scopes, permitted-user policy, and refresh-token policy as client-affecting settings: show the proposed diff and confirm before changing them. For a new ECA, read `references/eca-fields.md` to review permitted-user policy choices before rendering. Default to admin preauthorization; suggest self-authorization for all authenticated site users and apply it only if chosen.
97
+
98
+ 1. Confirm the ECA DeveloperName, then check for an existing ECA matching it:
99
+ ```sql
100
+ SELECT Id, DeveloperName FROM ExternalClientApplication
101
+ ```
102
+ Confirm its OAuth scopes include `MCP` and `RefreshToken`, and that its callback URLs cover the confirmed MCP clients. If the clients or their callback URLs aren't known yet, ask before deciding that the ECA is compatible.
103
+ 2. **If a compatible ECA is found: reuse it, read-only.** Report what it is and where it points. Do not touch it unless the user explicitly asks for a change — and even then, show the diff and warn about breaking live clients before writing.
104
+ 3. **If absent:** If local ECA files exist, run the comparison above, reuse compatible files, and create only confirmed missing components from its named templates. Review differences before changing files; never delete files or bypass overwrite protection to rerender a partial set. If no local files exist, confirm the MCP clients and their exact OAuth redirect URIs, show the planned files, confirm the local write, then render:
105
+ ```bash
106
+ node "<skill-dir>/scripts/render_eca.mjs" <default-package>/main/default <ECA_DEV_NAME> <ECA_LABEL> <ECA_DESC> <CONTACT_EMAIL> "<callback-urls>"
107
+ ```
108
+ Run the ECA comparison above on rendered or reused local files and review its findings before proposing a diff. If the permitted-user and refresh-token policies were not already reviewed in the conversation, ask the user to review them because they control who may authorize and how long refresh tokens remain valid.
109
+
110
+ ## Check progress — after Phase 2 or on resume
111
+
112
+ For new setups, run this after Phase 1 selects the site/server and Phase 2 confirms the ECA name. On resume, run Phase 0 first, recover those identifiers from the conversation or workspace, and ask only for missing or ambiguous choices. Include the optional confirmed site bundle for local readiness checks.
113
+
114
+ ```bash
115
+ node "<skill-dir>/scripts/check_setup_progress.mjs" <target-org-alias> <SERVER_DEV_NAME> <ECA_DEV_NAME> [--site <SITE_BUNDLE>]
116
+ ```
117
+
118
+ Present its `checks` and follow `nextAction`, `pendingVerification`, and `resumeRules`. Exit `0` means the audit ran, not setup completion; `auditStatus: partial` leaves affected reads unknown. Retain existing confirmation rules and resolve unknowns before dependent writes.
119
+
120
+ ## Phase 3 — Custom MCP server (render inactive, via Metadata API)
121
+
122
+ 1. Before reconciling existing state, read the object model and metadata invariants in `references/mcp-objects.md`. Query `McpServerDefinition` by the confirmed DeveloperName. If absent and a local server definition exists, inspect and reconcile it against the bundled template and confirmed inputs using [Repair existing ECA or MCP metadata](#repair-existing-eca-or-mcp-metadata); preserve its bindings, reuse the repaired component, and continue remaining binding review. Local metadata is not deployed state. Continue to step 2 only when the local component is missing. If the org component is partial, retrieve it and merge into it; re-rendering would drop tools, prompts, or resources that the scan did not reconstruct. Before retrieval, identify any destination file that already exists and confirm whether it may be overwritten, then retrieve the existing `McpServerDefinition:<name>` metadata so that a local `<default-package>/main/default/mcpServerDefinitions/<name>.mcpServerDefinition-meta.xml` file exists for Phase 4 to merge into. Phase 4 uses `merge_tools.mjs` to preserve existing bindings while adding approved tools and prompts. If the server is complete, reuse it and ask before changing its bindings. For a new setup or requested extension, do not skip Phase 4 merely because the server has bindings; during an interrupted setup, skip only when the intended bindings are confirmed from prior user decisions and verified complete locally and in the org.
123
+ 2. When the local server component is missing, show the destination file and confirm the local write, then render the metadata component into the same SFDX project (no bindings yet). `<SERVER_LABEL>` must be human-readable (e.g. "Support Automation MCP") — never the bare DeveloperName repeated as the label:
124
+ ```bash
125
+ node "<skill-dir>/scripts/render_mcp_server.mjs" <default-package>/main/default <SERVER_DEV_NAME> <SERVER_LABEL> <SERVER_DESC>
126
+ ```
127
+
128
+ ## Phase 4 — Tools and prompts
129
+
130
+ Before discovery and binding, read [references/tool-bindings.md](references/tool-bindings.md). For new setups and requested extensions, complete all four passes in order: site UI, local Apex/Flow, org Apex/Flow, and Prompt Builder. Inventory every UI CRUD operation before scanning for backings, then suggest a tool for each one after deduplicating at the end of 4c. Record each pass's result and evidence separately before 4e. On resume, repeat only incomplete or changed passes and preserve confirmed choices. Then continue with Phase 4e below.
131
+
132
+ **4e. Author and bind approved tools and prompts — applies to candidates from 4a–4d.**
133
+
134
+ Ask add-or-skip per eligible candidate and whether a selected template should be a prompt, tool, or both. Before authoring or exposing custom Apex actions, load `platform-apex-generate` and apply the reference's runtime input-validation and explicit user-mode requirements. **Always use `merge_tools.mjs`; never edit `<tools>` or `<prompts>` XML directly for Phase 4 binding.** The Phase 6 widget linkage exception permits only the scoped resource relationships in [references/widget-resources.md](references/widget-resources.md), not tool or prompt authoring.
135
+
136
+ ## Phase 5 — Deploy the MCP stack
137
+
138
+ Only after the ECA, server, backing actions/templates, and bindings are ready:
139
+
140
+ 1. Show the exact metadata files changed during this workflow or selected from the existing stack for deployment. This normally includes the rendered ECA files, implemented Apex classes and their companion metadata or Flows, and the MCP server definition. **Ask the user to confirm deployment**, unless an applicable prior approval covers the same target, files, and actions, then deploy exactly those tracked metadata files using the two-wave ECA exception below. Keep the remaining stack deployment multi-file and atomic across metadata types. Do not deploy the package directory or a whole metadata-type directory.
141
+
142
+ **ECA deploy order — two waves required.** If the tracked files include ECA metadata, deploy the `ExternalClientApplication` parent file alone in a first deploy, then deploy the other child types in a second deploy. Deploying all ECA files in one call fails silently or leaves children undeployed.
143
+
144
+ When resuming after a verified parent deployment, reuse that wave. If successful deployment evidence for any child component is unavailable, report its deployed state as unknown and propose a narrow retry of the exact tracked child files under the applicable deployment approval. Exclude the verified parent and reused components outside this run's approved changes; keep child deployment incomplete until the retry succeeds.
145
+
146
+ Stop if deployment fails. Do not activate a partially deployed server.
147
+ 2. Confirm that the deployed `McpServerDefinition` contains every approved tool and prompt. Verify that the backing actions/templates deployed successfully; widget generation requires the real deployed Apex action contract, not stale local source.
148
+
149
+ ## Phase 6 — Generate and attach MCP tool widgets
150
+
151
+ After Phase 5 succeeds and before loading `platform-mcp-tool-widget-coordinate`, establish whether the user wants HXL widgets for eligible Apex-backed tools. Reuse an explicit HXL request or prior approval; otherwise ask once whether to generate the widgets and prepare their local resource links. If the user declines, mark Phase 6 skipped and continue to Phase 7. If accepted, read [references/widget-resources.md](references/widget-resources.md) and execute its full procedure. It covers eligible `aa:apex-` tools only and delegates generation and its existing gates to `platform-mcp-tool-widget-coordinate`. This skill then checks the complete response bundle, prepares the narrow deployment checklist from the validated artifacts, retrieves the authoritative server with prior overwrite consent, and attaches and verifies widget resources. Flow-backed and prompt-backed tools and MCP prompts are skipped, not reinterpreted as Apex actions. Stop on any generation, gate, deployment, retrieval, or linkage failure; report partial files and do not activate.
152
+
153
+ ## Phase 7 — Activate and verify
154
+
155
+ Continue after Phase 6 succeeds or is skipped. For an explicit preview/activate-only request for an already-deployed named server, start at step 1; skip earlier phases and preserve existing bindings and resources.
156
+
157
+ 1. Activation uses Tooling writes because `McpServerAccess` has no metadata type. Preview first: without flags, `activate_server.mjs` queries the server and prints `plannedRequest` (method, URL and body) without writing. Show it and ask before using `--confirm`, which writes and re-queries the state. Use authenticated `sf` requests for activation and verification, never direct `curl`.
158
+ ```bash
159
+ node "<skill-dir>/scripts/activate_server.mjs" <target-org-alias> <SERVER_DEV_NAME>
160
+ node "<skill-dir>/scripts/activate_server.mjs" <target-org-alias> <SERVER_DEV_NAME> --confirm
161
+ ```
162
+ An authentication failure means the target org must be reauthenticated before retrying; it does not mean Tooling activation is unavailable. Ask the user to use Setup only when the Tooling operation itself is unavailable.
163
+ 2. Verify the definition, approved tools and prompts, Phase 6 widget-resource relationships when applicable, and active state. For tool-bearing servers, the read-only script reports `status: ready` only when the server is active and has at least one tool (otherwise `not_found`, `inactive` or `no_tools`, still exit 0); it does not verify widget relationships, which require Phase 6's metadata read-back:
164
+ ```bash
165
+ node "<skill-dir>/scripts/verify_server.mjs" <target-org-alias> <SERVER_DEV_NAME> [--json]
166
+ ```
167
+ For a prompt-only server, confirm active state with the activation script's read-only preview and inspect the deployed `McpServerDefinition` for the expected `<prompts>` entries; `verify_server.mjs` currently requires a tool and is not a prompt-only verifier. Test `prompts/list` in a compatible connected client when available.
168
+ For client readiness, also fetch the OAuth protected-resource document associated with the final serving URL and confirm that `scopes_supported` includes `mcp_api`. This is an integration check outside `verify_server.mjs`; derive the document URL from authoritative routing information for the target environment rather than inventing a portal URL.
169
+ 3. Report deployment/activation results, serving URL, bound tools/prompts, widget resources/URIs, HXL/Custom Lightning Type files/FQNs, and widget validation results. Keep preflight disclosure within Phase 0's rules. On a failed write, report existing records and offer reverse-order teardown; deactivate before deleting. Client connection is manual. Until the user confirms the deployed bindings and renditions in their client, mark connection, tool/prompt parity and widget rendering as pending integration verification.
170
+ 4. Before client testing, remind the admin to verify end users' `API Enabled`, Apex Class Access, Flow access/`Run Flows`, required object CRUD, field permissions, record access/sharing, and tool-specific permissions. This skill does not audit, configure, or grant end-user permissions.
171
+
172
+ ## Phase 8 — Deliver the MCP connection
173
+
174
+ After successful deployment, activation and verification, offer an MCP configuration or Claude plugin through **`experience-app-mcp-delivery-generate`**. Invoke it when the user requests delivery or accepts the offer; reuse an earlier request or acceptance. If the user declines, finish with the Phase 7 results. For a preview-only, activation-only or metadata-only request, finish at that request's boundary unless delivery was also requested.
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ExternalClientApplication xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <contactEmail>__ECA_CONTACT_EMAIL__</contactEmail>
4
+ <description>__ECA_DESC__</description>
5
+ <distributionState>Local</distributionState>
6
+ <label>__ECA_LABEL__</label>
7
+ </ExternalClientApplication>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ExtlClntAppGlobalOauthSettings xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <callbackUrl>__ECA_CALLBACK_URLS__</callbackUrl>
4
+ <externalClientApplication>__ECA_NAME__</externalClientApplication>
5
+ <isClientCredentialsFlowEnabled>false</isClientCredentialsFlowEnabled>
6
+ <isConsumerSecretOptional>true</isConsumerSecretOptional>
7
+ <isDeviceFlowEnabled>false</isDeviceFlowEnabled>
8
+ <isNamedUserJwtEnabled>true</isNamedUserJwtEnabled>
9
+ <isPkceRequired>true</isPkceRequired>
10
+ <isRefreshTokenRotationEnabled>true</isRefreshTokenRotationEnabled>
11
+ <isSecretRequiredForRefreshToken>false</isSecretRequiredForRefreshToken>
12
+ <isSecretRequiredForTokenExchange>true</isSecretRequiredForTokenExchange>
13
+ <isTokenExchangeEnabled>false</isTokenExchangeEnabled>
14
+ <label>__ECA_LABEL__ Global OAuth</label>
15
+ </ExtlClntAppGlobalOauthSettings>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ExtlClntAppOauthSettings xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <commaSeparatedOauthScopes>MCP, RefreshToken</commaSeparatedOauthScopes>
4
+ <externalClientApplication>__ECA_NAME__</externalClientApplication>
5
+ <label>__ECA_LABEL__ OAuth</label>
6
+ </ExtlClntAppOauthSettings>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ExtlClntAppOauthConfigurablePolicies xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <externalClientApplication>__ECA_NAME__</externalClientApplication>
4
+ <ipRelaxationPolicyType>Enforce</ipRelaxationPolicyType>
5
+ <label>__ECA_LABEL__ OAuth Policies</label>
6
+ <namedUserJwtSessionTimeoutType>UserSession</namedUserJwtSessionTimeoutType>
7
+ <permittedUsersPolicyType>AdminApprovedPreAuthorized</permittedUsersPolicyType>
8
+ <refreshTokenPolicyType>SpecificLifetime</refreshTokenPolicyType>
9
+ <refreshTokenValidityPeriod>30</refreshTokenValidityPeriod>
10
+ <refreshTokenValidityUnit>Days</refreshTokenValidityUnit>
11
+ <requiredSessionLevel>STANDARD</requiredSessionLevel>
12
+ </ExtlClntAppOauthConfigurablePolicies>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ExtlClntAppConfigurablePolicies xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <externalClientApplication>__ECA_NAME__</externalClientApplication>
4
+ <isEnabled>true</isEnabled>
5
+ <isOauthPluginEnabled>true</isOauthPluginEnabled>
6
+ <label>__ECA_NAME___defaultPolicy</label>
7
+ </ExtlClntAppConfigurablePolicies>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <McpServerDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <description>__MCP_SERVER_DESC__</description>
4
+ <masterLabel>__MCP_SERVER_LABEL__</masterLabel>
5
+ </McpServerDefinition>
@@ -0,0 +1,76 @@
1
+ # External Client Application Field Map
2
+
3
+ Read this reference when reviewing or changing ECA metadata produced by `render_eca.mjs`. Paths below are under `<default-package>/main/default` and use the ECA DeveloperName as `<name>`.
4
+
5
+ ## Generated files
6
+
7
+ ### `externalClientApps/<name>.eca-meta.xml`
8
+
9
+ Full path: `<default-package>/main/default/externalClientApps/<name>.eca-meta.xml`
10
+
11
+ | Field | Controls |
12
+ |---|---|
13
+ | `<label>` | Display label |
14
+ | `<description>` | Description |
15
+ | `<contactEmail>` | Contact email |
16
+
17
+ ### `extlClntAppGlobalOauthSets/<name>.ecaGlblOauth-meta.xml`
18
+
19
+ Full path: `<default-package>/main/default/extlClntAppGlobalOauthSets/<name>.ecaGlblOauth-meta.xml`
20
+
21
+ | Field | Controls |
22
+ |---|---|
23
+ | `<callbackUrl>` | OAuth callback URLs |
24
+ | `<isPkceRequired>` | PKCE requirement |
25
+ | `<isRefreshTokenRotationEnabled>` | Refresh-token rotation |
26
+ | `<isNamedUserJwtEnabled>` | Named-user JWT |
27
+ | `<label>` | Global OAuth settings label |
28
+
29
+ ### `extlClntAppOauthSettings/<name>.ecaOauth-meta.xml`
30
+
31
+ Full path: `<default-package>/main/default/extlClntAppOauthSettings/<name>.ecaOauth-meta.xml`
32
+
33
+ | Field | Controls |
34
+ |---|---|
35
+ | `<commaSeparatedOauthScopes>` | OAuth scopes |
36
+ | `<label>` | OAuth settings label |
37
+
38
+ ### `extlClntAppOauthPolicies/<name>.ecaOauthPlcy-meta.xml`
39
+
40
+ Full path: `<default-package>/main/default/extlClntAppOauthPolicies/<name>.ecaOauthPlcy-meta.xml`
41
+
42
+ | Field | Controls |
43
+ |---|---|
44
+ | `<permittedUsersPolicyType>` | Permitted users |
45
+ | `<refreshTokenPolicyType>` | Refresh-token policy |
46
+ | `<refreshTokenValidityPeriod>` | Refresh-token lifetime value |
47
+ | `<refreshTokenValidityUnit>` | Refresh-token lifetime unit |
48
+ | `<ipRelaxationPolicyType>` | IP relaxation |
49
+ | `<requiredSessionLevel>` | Required session level |
50
+ | `<label>` | OAuth policy label |
51
+
52
+ ### `extlClntAppPolicies/<name>_defaultPolicy.ecaPlcy-meta.xml`
53
+
54
+ Full path: `<default-package>/main/default/extlClntAppPolicies/<name>_defaultPolicy.ecaPlcy-meta.xml`
55
+
56
+ | Field | Controls |
57
+ |---|---|
58
+ | `<isEnabled>` | Application availability |
59
+ | `<isOauthPluginEnabled>` | OAuth plugin availability |
60
+ | `<label>` | Default policy label |
61
+
62
+ ## Permitted users
63
+
64
+ Default new ECAs to `AdminApprovedPreAuthorized`: the admin grants ECA access through associated profiles or permission sets; those users do not individually consent. This is not limited to administrator users. Remind the admin to arrange preauthorization; this skill does not manage end-user permissions.
65
+
66
+ If the MCP server is intended for all authenticated site users, suggest `AllSelfAuthorized`: eligible authenticated users authorize the ECA themselves without individual admin preauthorization. Apply it only after an explicit choice. ECA authorization does not replace site, tool, or data access controls.
67
+
68
+ Pass `--permitted-users-policy <AdminApprovedPreAuthorized|AllSelfAuthorized>` to `render_eca.mjs` for generation and `--check` with the confirmed choice; omission uses the admin-preauthorized baseline. Preserve intentional existing policies. A baseline difference is a review finding, not authorization to change a live ECA.
69
+
70
+ ## Editing invariants
71
+
72
+ - Store all client-specific OAuth redirect URIs as newline-separated values inside the single `<callbackUrl>` element. Each value must be an absolute redirect URI with an allowed scheme and host. Do not invent a default callback URL, and do not write an empty `<callbackUrl>`.
73
+ - Keep the `MCP` and `RefreshToken` OAuth scopes unless the user explicitly changes the supported authorization flow.
74
+ - Refresh-token lifetime is controlled by the policy type, period, and unit in the OAuth policy component.
75
+ - Keep every `<externalClientApplication>` value aligned with the ECA DeveloperName. A rename requires coordinated file-name and cross-component reference changes, not an isolated field edit.
76
+ - The renderer derives labels across the related components. When changing the display label, review the labels in the global OAuth, OAuth settings, and OAuth policy components for consistency.
@@ -0,0 +1,66 @@
1
+ # Custom Hosted MCP Object and Binding Reference
2
+
3
+ Read this reference during Phase 3 when reconciling a server and during Phase 4 before binding tools. The scripts and assets remain authoritative for rendering, API requests, activation, and verification.
4
+
5
+ ## Object model
6
+
7
+ The server, tools, and prompts deploy as one Metadata API component with nested `<tools>` and `<prompts>` blocks. Activation is a separate Tooling API record.
8
+
9
+ | Concept | Runtime/Tooling object | Metadata representation |
10
+ |---|---|---|
11
+ | Server | `McpServerDefinition` | Root `<McpServerDefinition>`; file name is the DeveloperName |
12
+ | Tool | `McpServerToolDefinition` | One `<tools>` block |
13
+ | Tool backing | `McpServerToolApiDefinition` | `<apiDefinition>` inside `<tools>` |
14
+ | Prompt | — | One `<prompts>` block with `promptTemplateName` |
15
+ | Activation | `McpServerAccess` | No metadata type; separate Tooling write |
16
+
17
+ Deploy the Salesforce-hosted component at `<default-package>/main/default/mcpServerDefinitions/<DeveloperName>.mcpServerDefinition-meta.xml`.
18
+
19
+ ## Metadata invariants
20
+
21
+ - Use the bundled server asset and `merge_tools.mjs`; do not hand-build or directly edit `<tools>` or `<prompts>` XML.
22
+ - Omit `Language`; it isn't a `McpServerDefinition` metadata field.
23
+ - Preserve root content such as prompts and resources when adding tools.
24
+ - Canonical tool element order is `apiDefinition`, `descriptionOverride`, `destructive`, `idempotent`, `openWorld`, `readOnly`, `returnDirect`, `toolName`, `toolTitle`.
25
+ - Canonical `<apiDefinition>` order is `apiIdentifier`, `apiSource`, `operation`.
26
+ - Set the five behavior booleans from the action's real behavior; do not blindly default them.
27
+ - Every newly authored tool must have a meaningful `descriptionOverride` and `toolTitle`; every prompt needs `descriptionOverride` and `promptTitle`.
28
+ - The emitted tool XML must contain `operation` and `toolName`. For `aa:apex-`, `fa:flow-`, and `pr:` JSON specs, `merge_tools.mjs` derives both from `apiIdentifier` when omitted.
29
+ - Canonical prompt element order is `descriptionOverride`, `promptName`, `promptTemplateName`, `promptTitle`.
30
+
31
+ ## Existing-stack review
32
+
33
+ Run preflight and recover the confirmed site, server, ECA/client callbacks, intended bindings/widgets, and prior approvals. Ask only for missing or ambiguous choices. Use `check_setup_progress.mjs` for observations, not proof of setup completion. Read-only review stops with findings and unresolved checks; creation, retrieval, repairs, deployment, activation, and permission audits are outside that path.
34
+
35
+ - Compare local ECA files with `render_eca.mjs --check` using confirmed inputs and policy choice; read `eca-fields.md` for scopes, callbacks, policies, and cross-component ownership. Verify deployed settings separately through read-only org queries where available; inaccessible settings remain unknown.
36
+ - Inspect the actual local server XML against the bundled asset and confirmed intent, preserving intentional overrides. Compare with deployed state through read-only queries where available. Local files and activation alone do not establish deployed configuration or client readiness.
37
+ - Compare every intended tool/prompt with the authoritative available metadata and action/template contracts. Read `tool-bindings.md` to review existing behavior flags as well as new ones. Follow `widget-resources.md` for applicable dependencies/links. Report missing, contradictory, stale, or unverifiable settings; permission setup remains an admin reminder.
38
+ - For deployment requests, show the exact stack files and unresolved dependencies before Phase 5. Reuse prior approvals only for the same target, files, and actions. Keep client testing pending until verified.
39
+
40
+ ## Supported tool backings
41
+
42
+ The supported tool bindings serialize with `apiSource=API_CATALOG`.
43
+
44
+ | Backing implementation | `apiIdentifier` | Availability pattern | Appropriate use |
45
+ |---|---|---|---|
46
+ | Global Apex `@InvocableMethod` | `aa:apex-<ClassName>` | Live/virtual | New custom logic; primary path |
47
+ | Autolaunched Flow with input and output variables | `fa:flow-<FlowName>` | Live/virtual | Declarative or admin-owned logic |
48
+ | Available Prompt Builder template action | `pr:<TemplateApiName>` | Runtime prompt-template action | Agent-invoked server-side generation |
49
+
50
+ Preserve every existing binding during reconciliation. Add new bindings from the supported implementations in this table.
51
+
52
+ Active, published Flex Prompt Builder templates can be MCP prompts under `<prompts>`. An available prompt-template action can also be a `pr:` MCP tool under `<tools>`; the same template may appear in both forms. MCP prompts are selected by people in compatible clients, while prompt-backed tools execute server-side when called by an agent.
53
+
54
+ ## Availability patterns
55
+
56
+ Invocable Apex and autolaunched Flows are live sources. Confirm that the action exists in the org's runtime invocable-action catalog, then compose its `aa:` or `fa:` identifier.
57
+
58
+ `retrieve_existing_tools.mjs` reads `/actions/custom/apex` and `/actions/custom/flow` and doesn't write to the SFDX project. `retrieve_existing_prompts.mjs` pages through active templates at `/einstein/prompt-templates`, lists custom `GenAiPromptTemplate` metadata, reads custom template versions by API name, and lists or describes `/actions/custom/generatePromptResponse` actions. It reports active published custom Flex templates as MCP prompt candidates, inactive published custom Flex templates separately, active standard Flex templates with unverified MCP prompt eligibility, and actions backed by published custom or active standard Flex or Global templates as MCP tool candidates; `inventoryCounts` retains the broader API totals. The list responses provide candidate names and describe URLs. Describe only candidates relevant to the site's purpose; the candidate-specific response supplies the description and parameter schemas needed for review. Runtime discovery can include namespaced installed-package actions whose source isn't locally retrievable. An unavailable endpoint is not evidence that a template does not exist.
59
+
60
+ ## Prompt Builder eligibility
61
+
62
+ A custom template can have a published version while `IsActive` is false; do not infer MCP prompt eligibility from publication, type, or a runtime action alone. For inactive or unverified Flex candidates, confirm they appear in Setup's Add Prompts picker or verify both active and published status before proposing a prompt binding.
63
+
64
+ Compare candidate API names with existing `<prompts>` and `pr:` `<tools>` bindings. Inspect plausible template metadata and GET the returned action `url` when present to review its description and inputs. Offer an eligible Flex template as an MCP prompt for client selection, a runtime-available `pr:<template API name>` action as an agent-invoked tool, or both when justified.
65
+
66
+ A non-zero exit means incomplete discovery, not absence; report it and continue the independent Apex/Flow and UI passes. Read [discovery troubleshooting](troubleshooting.md#tool-discovery-and-binding) before retrying.
@@ -0,0 +1,85 @@
1
+ # Tool and Prompt Discovery and Binding
2
+
3
+ Read this before Phase 4 discovery and binding. Use `<skill-dir>` and `<default-package>` as defined in [SKILL.md](../SKILL.md). On resume, read the sections needed to verify incomplete or changed state.
4
+
5
+ ## Discovery (4a–4d)
6
+
7
+ Before binding assets, read the supported backings and availability patterns in [mcp-objects.md](mcp-objects.md). For a new setup or requested extension, complete and track the four discovery passes below separately and in order: site UI, local Apex/Flow, org Apex/Flow, and Prompt Builder. Record a short result and its supporting evidence for each pass before binding. When resuming, repeat only the passes needed to verify incomplete or changed state; reuse prior results only when they are still valid and intended bindings are confirmed. Org discovery is read-only and does not retrieve metadata into the project.
8
+
9
+ This skill discovers and builds tools backed by global Apex `@InvocableMethod` actions, eligible autolaunched Flows, and available Prompt Builder templates. It also binds active, published Flex templates as MCP prompts. Compose `aa:`, `fa:`, and `pr:` identifiers only after confirming availability.
10
+
11
+ ### 4a. Front-end review
12
+
13
+ Run this pass first, before any Apex/Flow scan or org listing. Read [ui-frameworks.md](ui-frameworks.md) for ExperienceBundle and component scanning. Use the selected Phase 1 entry's `uiRoots`; rerun `list_sites.mjs` if source changed. If UI paths or referenced custom components are missing, follow Phase 1's stop-and-ask rule; do not skip UI review.
14
+
15
+ Read every site view/route and every referenced custom component, and trace each server call. Build an exhaustive **UI operation inventory**: one row per distinct CRUD operation the UI performs or exposes, including simple lists, searches, detail queries, and writes. For each row, record the view and component, observed server call, inputs, outputs, filters, and read/write behavior. Include every operation whether or not a backing action exists; do not judge coverage, look for backings, or drop rows in this pass. Exclude only navigation and presentation-only flows. Flag unresolved CRUD behavior rather than inventing it. If no operations are found, identify the inspected source supporting that conclusion.
16
+
17
+ ### 4b. Local project scan
18
+ ```bash
19
+ node "<skill-dir>/scripts/scan_tool_candidates.mjs"
20
+ ```
21
+ Reports Apex `@InvocableMethod` actions whose containing class and method are `global`. Supported primitive `List` element types are eligible directly; custom request or result types and every exposed `@InvocableVariable` field must also be `global`. It also reports autolaunched Flows that have at least one input variable and at least one output variable. Those can be different `<variables>`. Eligible sources get a composable `apiIdentifier` (`aa:apex-<Class>`, `fa:flow-<Flow>`).
22
+
23
+ ### 4c. Org action discovery
24
+
25
+ Run the read-only candidate listing:
26
+ ```bash
27
+ node "<skill-dir>/scripts/retrieve_existing_tools.mjs" <target-org-alias>
28
+ ```
29
+ The helper makes one REST list call for Apex actions and one for Flow actions, validates both response envelopes, and prints their runtime candidate records without writing files. The runtime catalog can include namespaced actions from installed packages; do not discard them solely because their source isn't locally retrievable.
30
+
31
+ Compare the candidate names with 4b and the server's existing `<tools>`. From the site purpose, the 4a inventory, and candidate labels and names, select a small set that plausibly helps this site's users. Do not describe every org action. For each plausible candidate, use its returned `url` for a read-only describe call:
32
+ ```bash
33
+ sf api request rest "<candidate-url>" --target-org <target-org-alias> --method GET
34
+ ```
35
+ Use the description plus input and output schemas to decide whether the action represents a coherent MCP tool and to propose an accurate title and description. For Flows, require an autolaunched action with both input and output parameters. For Apex found in local source, retain 4b's `global @InvocableMethod` check. For an org-only Apex action, report that the runtime catalog and describe response establish action availability but don't expose its source-level visibility; deployment remains the platform validation. If behavior annotations can't be determined from the descriptor, local implementation, or site behavior, ask the user rather than inventing them.
36
+
37
+ A non-zero exit means listing or response validation failed, not that the org has no candidates. Stop Phase 4, report the failure, and do not use partial output to conclude that a tool is absent. For an authentication failure, ask the user to reauthenticate the target org with `sf`, then rerun only after the failure is resolved.
38
+
39
+ **Reconcile and deduplicate.** Map every row of the 4a inventory to a backing, in this order: an existing server binding, a 4b local action, or a 4c org action. Merge rows that share one operation, and merge 4b/4c candidates that are the same action. IMPORTANT: Proactively suggest a tool for every inventory row, including simple lists, searches, detail queries, and writes; for each row with no matching backing, propose a new eligible backing action (Apex or Flow) using the row's observed inputs, outputs, filters, and behavior. Do not limit UI-derived suggestions to the strongest candidates, and do not drop a row because other tools already exist. Then add the strongest relevant unbound 4b/4c candidates that serve no inventory row, and explain why each fits.
40
+
41
+ Present the reconciled list once, showing each tool's source row or candidate and its backing (existing, local, org, or new), and ask add-or-skip for each unbound tool. Implement each approved tool with its real input, output, and behavior. Do not generate placeholder Apex classes.
42
+
43
+ Example: when the UI lists service requests, loads request details, and submits a new request, offer all three tools, reusing a matching action where one exists and proposing a new action for each one that doesn't.
44
+
45
+ ### 4d. Prompt Builder discovery
46
+
47
+ Run the read-only listing:
48
+ ```bash
49
+ node "<skill-dir>/scripts/retrieve_existing_prompts.mjs" <target-org-alias>
50
+ ```
51
+ Compare candidate API names with existing `<prompts>` and `pr:` `<tools>` bindings. Inspect plausible template metadata and GET the returned action `url` when present to review its description and inputs. Offer confirmed active, published Flex templates as MCP prompts, runtime-available `pr:<template API name>` actions as tools, or both. Publication or runtime availability alone doesn't establish prompt eligibility. For inactive or unverified candidates, read [Prompt Builder eligibility](mcp-objects.md#prompt-builder-eligibility) before proposing a prompt binding. A non-zero exit means incomplete discovery, not absence; report it and continue the independent Apex/Flow and UI passes. Read [discovery troubleshooting](troubleshooting.md#tool-discovery-and-binding) before retrying.
52
+
53
+ ## Author and bind (4e)
54
+
55
+ **Authoring new tools — invocable first.** Use global Apex `@InvocableMethod` for new custom logic, or an **autolaunched Flow** for declarative or admin-owned logic. Apply [Phase 4b's global visibility requirements](#4b-local-project-scan) to the Apex class, method, custom request/result types, and exposed fields.
56
+
57
+ **Custom Apex actions — validate inputs and enforce user access.** Load `platform-apex-generate` before authoring. Apply these requirements to each new action, each existing method newly exposed (including in-place edits; keep its signature and existing callers working), and any data-access helpers they call:
58
+
59
+ - Validate the request list and every request at runtime before queries, searches, DML, or other side effects. Reject null/empty lists, null items, missing required values, invalid IDs or IDs for the wrong sObject type, unsupported values, and values outside the operation's allowed lengths or ranges. Derive constraints from the actual operation and target schema; `@InvocableVariable(required=true)` and UI validation do not replace runtime checks. Validate all requests before starting a batch write.
60
+ - Use `global with sharing` for the entry class. Explicitly enforce user mode for every database operation: `WITH USER_MODE` for static SOQL/SOSL, `AccessLevel.USER_MODE` for dynamic query/search and `Database` DML methods, or `as user` for DML statements. Bind input values and allowlist dynamic object, field, and operator names. `with sharing` alone does not enforce CRUD/FLS; do not rely on API-version defaults.
61
+ - Return sanitized validation and access errors using the action's result contract, or a safe fault for an unrecoverable failure. Do not expose internal exception details or retry denied operations in system mode. Only use elevated access for an explicitly approved, justified requirement; isolate it in a narrowly scoped helper with an authorization check.
62
+ - Verify valid inputs, null/empty lists and items, invalid values and IDs, and denied record/object/field access. Check that invalid or unauthorized requests produce safe errors and no unauthorized writes.
63
+
64
+ For confirmed tools, write `apiIdentifier`, `toolTitle`, `descriptionOverride`, and all five behavior booleans (`destructive`, `idempotent`, `openWorld`, `readOnly`, `returnDirect`). Classify actual side effects from the implementation, authoritative descriptor, or confirmed behavior; never use names alone. Ask when behavior is unknown. `destructive` means any write, including indirect writes, not just deletion:
65
+
66
+ | Behavior | `readOnly` | `destructive` |
67
+ |---|---|---|
68
+ | Create, update, upsert, delete (for example insert a Case or change its status) | false | true |
69
+ | Read-only queries or text generation without side effects | true | false |
70
+
71
+ Creating a new record on every call is also `idempotent: false`. Determine prompt-backed annotations from the template and called actions; do not assume prompts are read-only. Leave `openWorld` and `returnDirect` false unless the backing calls outside the org or its result should return directly to the user. Prefer backing labels and descriptions, or write concise, accurate ones. `apiSource` defaults to `API_CATALOG`. For `aa:apex-`, `fa:flow-`, and `pr:` specs, the helper derives `operation` and `toolName`; set `toolName` if the exposed name should differ.
72
+
73
+ For confirmed MCP prompts, provide `promptName` (exposed name), `promptTemplateName` (exact template API name), `promptTitle`, and `descriptionOverride`. Group tools and prompts in a temporary JSON file:
74
+ ```json
75
+ {
76
+ "prompts": [{"promptName": "revenue_cloud__updateQuoteLineItems", "promptTemplateName": "revenue_cloud__updateQuoteLineItems", "promptTitle": "Update Quote Line Items", "descriptionOverride": "Updates line items on an existing quote."}],
77
+ "tools": [{"apiIdentifier": "pr:revenue_cloud__activateOrderWorkflow", "toolName": "revenue_cloud_activateOrderWorkflow", "toolTitle": "Activate Order Workflow", "descriptionOverride": "Activates a Revenue Cloud order.", "destructive": true, "idempotent": false, "openWorld": false, "readOnly": false, "returnDirect": false}]
78
+ }
79
+ ```
80
+
81
+ **Always use `merge_tools.mjs`; never edit `<tools>` or `<prompts>` XML directly for Phase 4 binding.** The Phase 6 widget linkage exception allows only adding or reconciling top-level `<resources>` and a selected tool's `<uiResource>` after authoritative retrieval, as specified in [widget-resources.md](widget-resources.md). It does not permit editing API bindings, behavior annotations, prompts, or other tool fields by hand. Merge the specs into the rendered or retrieved component:
82
+ ```bash
83
+ node "<skill-dir>/scripts/merge_tools.mjs" <default-package>/main/default/mcpServerDefinitions/<name>.mcpServerDefinition-meta.xml <tools.json>
84
+ ```
85
+ `merge_tools.mjs` validates tool and prompt specs and rejects a tool missing any behavior boolean or containing an inconsistent `readOnly`/`destructive` pair. It de-duplicates tools by `apiIdentifier` and prompts by `promptName`, preserves an existing `uiResource` node when rebuilding an updated tool, preserves other server content, and writes canonical element order. Widget linkage keys are not accepted in the JSON spec; Phase 6 owns attachment. `--dry-run` prints without writing; `--skip-existing` preserves already-bound entries. Before changing an existing binding, show the diff, explain that active clients may be affected, and confirm the change. Review the JSON summary and resulting metadata, then remove the temporary JSON file.
@@ -0,0 +1,41 @@
1
+ # Troubleshooting — experience-app-mcp-generate
2
+
3
+ Read only the section relevant to the failed phase. Apply Phase 0's disclosure rules to preflight diagnostics.
4
+
5
+ ## Preflight
6
+
7
+ **`decision: skip` or `disabled` (exit 0):** `isAppMcpEnabled: false` or invocable-action `INVALID_INPUT` means this skill must not be used. `--skill-named` selects silent `skip` or `disabled` with a user message. Follow Phase 0.
8
+
9
+ **`decision: needs_input` (exit 0):** Show the safe message and corrective action, ask for a valid authenticated alias or org-supported `sourceApiVersion` of at least `68.0`, then rerun preflight. Do not edit existing project configuration without approval. These input errors are actionable even before gate enablement is known.
10
+
11
+ **`decision: error` (nonzero):** Show the returned message and corrective action; resolve the failure and rerun preflight. After gate success, errors are visible even for unnamed requests. Before success, other inconclusive failures route to silent `skip` unless explicitly named. Missing metadata types do not establish entitlement.
12
+
13
+ ## ECA and deployment
14
+
15
+ **OAuth returns `invalid_scope`:** Confirm that the deployed ECA OAuth settings include `MCP`. Review the rendered metadata and targeted deployment result before changing or redeploying anything.
16
+
17
+ **A metadata property is invalid for the API version:** Keep the project `sourceApiVersion`, target-org support, and rendered metadata aligned. Review and confirm any version change before editing `sfdx-project.json`.
18
+
19
+ ## Tool discovery and binding
20
+
21
+ **A bound tool is missing from the client:** Confirm that the global invocable Apex action or eligible autolaunched Flow exists in the org, that its `aa:` or `fa:` identifier is correct, and that the org's invocable-action MCP gate is enabled.
22
+
23
+ **A discovery pass returns no candidates:** An empty local scan means the scanned source tree has no eligible metadata. Empty Apex and Flow action arrays mean the authenticated user has no runtime candidates exposed by those endpoints. A non-zero exit means the REST listing failed or returned an invalid envelope, so do not treat it as an empty result. If a specific describe call fails, omit that candidate and report why it couldn't be evaluated; don't infer that other candidates are unavailable.
24
+
25
+ **Prompt discovery fails or returns no candidates:** `retrieve_existing_prompts.mjs` reads active templates through Connect REST and available prompt-template actions through the Actions API. A non-zero exit is an incomplete read, not proof of absence; check Prompt Builder enablement, the authenticated user's access, and the reported endpoint before retrying. A successful empty list means no candidates were exposed to that user.
26
+
27
+ **A bound prompt is missing from the client:** Check that the template is published and Flex, that `promptTemplateName` matches its API name, and that the client supports MCP prompts. For a `pr:` tool, confirm its prompt-template action is runtime-available and its identifier matches the template API name.
28
+
29
+ **The UI scan reports an already implemented capability:** Reuse the existing action or Flow instead of generating another implementation.
30
+
31
+ ## Activation and client discovery
32
+
33
+ **The protected-resource document lacks `mcp_api`:** Confirm that `McpServerAccess.Active` is `true`, the ECA includes the `MCP` scope, and the deployed server name matches the resource URL. If all three are correct, allow for propagation and recheck.
34
+
35
+ **Activation reports a duplicate access row:** A duplicate proves only that the row exists. Re-query it and report success only when `Active=true`.
36
+
37
+ ## Recovery and secrets
38
+
39
+ **A run failed after creating or changing state:** Report the exact files and records affected. Deactivate the server first, confirm no client uses it, then delete or revert only components created or changed by this run. Never delete reused state.
40
+
41
+ **A consumer secret was printed or written:** Treat it as compromised and have the user rotate it in Setup. Deleting the visible copy isn't sufficient remediation.
@@ -0,0 +1,19 @@
1
+ # Aura Experience Site UI review
2
+
3
+ Read this reference during Phase 4a after selecting an entry with `status: "ready"`.
4
+
5
+ ## Site source
6
+
7
+ Use the selected inventory entry's `uiRoots` and metadata evidence. Inspect its `experiences/<bundle>/routes` and `views` JSON files to identify rendered journeys and top-level component references.
8
+
9
+ The inventory identifies supported Aura view structure from `forceCommunity:` or `siteforce:` component references, or a view-referenced local Aura component. Legacy LWR view components in `community_builder:`, `community_layout:`, or `community_login:` are unsupported, as are DigitalExperienceBundle and UI-bundle source.
10
+
11
+ ## Component and server-call tracing
12
+
13
+ Aura Experience Sites can use both LWC and Aura components.
14
+
15
+ Traverse standard layout and component nodes, including `forceCommunity:` and `siteforce:` references, through their regions and child components. Resolve referenced custom components from `lwc/` and `aura/` across the project's package directories, then follow their component composition, handlers, and data access. Skip unrelated components.
16
+
17
+ Review every UI flow, including initial data loading, searches, detail views, forms, and multi-step actions. In LWCs, inspect `@wire` adapters, reactive parameters, and imperative calls. In Aura components, follow markup event handlers, controllers, helpers, and server actions. Consult Salesforce documentation for unfamiliar adapters.
18
+
19
+ Trace every server operation and record its inputs, outputs, filters, and behavior in Phase 4a's UI operation inventory. Include simple data queries and writes without filtering by complexity.