forcedotcom/sf-skills / skills/experience-app-mcp-generate
experience-app-mcp-generate
VerifiedCreate, 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, always ask whether the user wants 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.
scripts/render_eca.mjs
View on GitHub#!/usr/bin/env node
// Render ECA metadata, or compare existing files with the same templates.
//
// Usage: node render_eca.mjs <METADATA_DIR> <ECA_DEV_NAME> <ECA_LABEL> <ECA_DESC> <CONTACT_EMAIL> <CALLBACK_URLS>
// Optional: --permitted-users-policy <AdminApprovedPreAuthorized|AllSelfAuthorized>.
// Add --check for read-only comparison; metadata directory and ECA name alone
// check fixed fields while leaving unconfirmed input fields unverified.
//
// Reads the flat __ECA_NAME__*.xml templates from assets/, substitutes
// placeholders, renames each to <ECA_DEV_NAME>, and writes it under METADATA_DIR.
// METADATA_DIR is <default-package>/main/default, passed by the skill. Run from the project root.
//
// CALLBACK_URLS is a required space- or comma-separated list of absolute
// client redirect URIs. Empty values and wildcards are rejected.
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { callbackRejection } from "./utils/callback_url.mjs";
import { isValidDeveloperName } from "./utils/developer_name.mjs";
import { checkEcaPlan } from "./utils/eca_check.mjs";
import { requireProjectDestination } from "./utils/metadata_path.mjs";
function fail(msg) {
process.stderr.write(msg + "\n");
process.exit(1);
}
const args = [];
let checkOnly = false;
let permittedUsersPolicy;
const rawArgs = process.argv.slice(2);
for (let i = 0; i < rawArgs.length; i++) {
const arg = rawArgs[i];
if (arg === "--check" && !checkOnly) {
checkOnly = true;
} else if (arg === "--permitted-users-policy" && permittedUsersPolicy === undefined) {
permittedUsersPolicy = rawArgs[++i];
if (!["AdminApprovedPreAuthorized", "AllSelfAuthorized"].includes(permittedUsersPolicy)) {
fail("--permitted-users-policy must be AdminApprovedPreAuthorized or AllSelfAuthorized.");
}
} else if (arg.startsWith("--")) {
fail(`Unknown or duplicate option: ${arg}`);
} else {
args.push(arg);
}
}
permittedUsersPolicy ??= "AdminApprovedPreAuthorized";
if (args.length !== 6 && !(checkOnly && args.length === 2)) {
fail("Usage: render_eca.mjs <METADATA_DIR> <ECA_DEV_NAME> [<ECA_LABEL> <ECA_DESC> <CONTACT_EMAIL> <CALLBACK_URLS>] --check; omit --check and supply all inputs to create files.");
}
const [metadataDirArg, ecaName, ecaLabel, ecaDesc, contactEmail, callbackUrls] = args;
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
const assetDir = path.join(scriptDir, "..", "assets");
const projectRoot = path.resolve(process.cwd());
const defaultDir = path.resolve(projectRoot, metadataDirArg);
if (defaultDir !== projectRoot && !defaultDir.startsWith(projectRoot + path.sep)) {
fail(`ABORT: metadata directory '${metadataDirArg}' escapes the project root`);
}
// DeveloperName is used in filenames, so validate it before constructing paths.
if (!isValidDeveloperName(ecaName)) {
fail(
`Invalid DeveloperName '${ecaName}': letters, digits, single underscores, optional namespace__ prefix, start with a letter, <= 80 chars.`,
);
}
// Map each template suffix to its metadata source directory. Order matters:
// more specific suffixes must be matched before more general ones.
function folderFor(base) {
if (base.endsWith(".ecaGlblOauth-meta.xml")) return "extlClntAppGlobalOauthSets";
if (base.endsWith(".ecaOauthPlcy-meta.xml")) return "extlClntAppOauthPolicies";
if (base.endsWith(".ecaOauth-meta.xml")) return "extlClntAppOauthSettings";
if (base.endsWith(".ecaPlcy-meta.xml")) return "extlClntAppPolicies";
if (base.endsWith(".eca-meta.xml")) return "externalClientApps";
return "";
}
const templates = fs.existsSync(assetDir)
? fs.readdirSync(assetDir).filter((f) => f.startsWith("__ECA_NAME__") && f.endsWith(".xml"))
: [];
if (templates.length === 0) {
fail(`No __ECA_NAME__*.xml templates found in ${assetDir}`);
}
function escapeXml(s) {
return String(s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
}
const replacements = { __ECA_NAME__: ecaName };
if (args.length === 6) {
const callbacks = callbackUrls.trim().split(/[,\s]+/).filter(Boolean);
if (callbacks.length === 0) fail("ABORT: at least one callback URL is required. There is no safe default redirect.");
for (const callback of callbacks) {
const rejection = callbackRejection(callback);
if (rejection) fail(`ABORT: ${rejection}`);
}
Object.assign(replacements, {
__ECA_LABEL__: escapeXml(ecaLabel),
__ECA_DESC__: escapeXml(ecaDesc),
__ECA_CONTACT_EMAIL__: escapeXml(contactEmail),
__ECA_CALLBACK_URLS__: callbacks.map(escapeXml).join("\n"),
});
}
// Check every destination before writing any of them so a collision cannot
// leave a partially rendered ECA in the project.
const plan = [];
for (const base of templates) {
const folder = folderFor(base);
if (!folder) fail(`Unknown metadata suffix for ${base}.`);
// Strip the __ECA_NAME__ prefix to keep any compound suffix (e.g.
// _defaultPolicy.ecaPlcy-meta.xml), then re-prefix with the real name.
const suffix = base.slice("__ECA_NAME__".length);
const destDir = path.join(defaultDir, folder);
const dest = path.join(destDir, `${ecaName}${suffix}`);
if (!checkOnly) {
try {
requireProjectDestination(projectRoot, dest);
} catch {
fail("ABORT: metadata destination is unreadable or resolves outside the project root");
}
}
if (!checkOnly && fs.lstatSync(dest, { throwIfNoEntry: false })) fail(`Refuse to overwrite existing file: ${dest}`);
const src = path.join(assetDir, base);
const template = fs.readFileSync(src, "utf8").replace(
"<permittedUsersPolicyType>AdminApprovedPreAuthorized</permittedUsersPolicyType>",
`<permittedUsersPolicyType>${permittedUsersPolicy}</permittedUsersPolicyType>`,
);
let expected = template;
for (const [key, value] of Object.entries(replacements)) expected = expected.split(key).join(value);
plan.push({ src, destDir, dest, template, expected });
}
if (checkOnly) {
const report = checkEcaPlan(plan);
console.log(JSON.stringify(report, null, 2));
} else {
for (const { destDir, dest, expected } of plan) {
fs.mkdirSync(destDir, { recursive: true });
fs.writeFileSync(dest, expected, "utf-8");
}
console.log(`Rendered ECA metadata in ${defaultDir}`);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |