
Mcp Server Sfmc
io.github.JoernBerkefeld由 GitHub 帳號 JoernBerkefeld 發布v2.10.1更新於 Oct 24, 2026
SFMC AMPscript/SSJS/GTL tools + searchable help for 7 MC products (Engagement, Pardot…) via MCP.
概覽
本機 MCP 伺服器,為助理提供 Salesforce Marketing Cloud 語言智慧:驗證、查詢、轉換與遷移 AMPscript、SSJS 和 MCN Handlebars,並可搜尋說明文件。
- 可以做什麼
- 驗證 AMPscript、SSJS 以及內嵌 AMPscript、SSJS 與 GTL 的混合 HTML,支援 Marketing Cloud Next 目標檢查
- 查詢與列出 AMPscript 和 SSJS 函式、簽章、MCN 相容性及補全項目
- 驗證、查詢與補全 Marketing Cloud Next Handlebars 輔助函式,並撰寫範本
- 審查統一 diff、提供修正建議並格式化程式碼
- 偵測目標平台、分析 MCN 就緒度,並在 AMPscript、SSJS 與 Handlebars 之間重寫或轉換程式碼
- 搜尋內建的 Marketing Cloud Engagement 說明與 Marketing Cloud Next 開發者文件
- 適用情境
- 適合撰寫、審查或遷移 Salesforce Marketing Cloud 程式碼時使用,尤其是把 AMPscript 或 SSJS 專案遷移到 Marketing Cloud Next,或希望答案依據內建的 Engagement 與 Next 文件而非模型記憶。
- 執行需求
- 以 stdio 在本機執行,通常透過 npx 啟動,因此需要 Node.js 與 npm;可選擇全域或專案內 npm 安裝以加快啟動。未宣告需要帳號、API 金鑰或環境變數。附帶 CLI 可在 CI 中執行 diff 審查。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mcp Server Sfmc,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-server-sfmc
MCP server providing Salesforce Marketing Cloud language intelligence — AMPscript, SSJS, GTL, and Marketing Cloud Next (MCN) Handlebars — as Model Context Protocol tools, resources, and prompts for AI-assisted development and code review. Ships two searchable doc indexes: MCE help (Salesforce Help for Marketing Cloud Engagement administration and setup) and MCN developer docs (Marketing Cloud Next REST API and developer reference). Includes full Marketing Cloud Next (MCN) platform awareness: auto-detects whether a project targets MCE or MCN, restricts completions and validation to MCN-supported functions, flags SSJS as unsupported in MCN, surfaces MCN behavioral differences in hover and diagnostics, validates MCN Handlebars templates, and provides a migration toolkit to analyze and rewrite code for MCN — including AMPscript ↔ Handlebars and SSJS → Handlebars conversion.
Built on sfmc-language-lsp, the same engine that powers the SFMC Language Service VS Code extension.
Shared-diagnostic migration
sfmc-language-lsp 4.0.0 changes shared validator codes to canonical sfmc/... IDs and preserves quick-fix variants and original payloads in a namespaced envelope. See the LSP migration and rule documentation. Documentation URLs are owned by the LSP version, not this MCP package.
Consumer regression coverage checks the canonical SSJS diagnostics, distinct polyfill/replacement payloads, and overlap suppression. This is not a new MCP tool or a promise that every tool response exposes raw LSP diagnostics.
Version 2.10.0 adopts ampscript-data: ^4.2.0 and sfmc-language-lsp: ^4.2.0 from npm. This Winter ’27 (API 68) catalog update makes the current AMPscript and shared language-service metadata available to MCP clients. MCP validation and review output continues to format locations, severities, and messages rather than expose raw LSP codes or envelopes.
VS Code MCP Server Gallery (@mcp)
This package is registered with the official MCP Registry as io.github.JoernBerkefeld/mcp-server-sfmc so it can appear in Visual Studio Code when you use the @mcp filter in the Extensions view (see the publish quickstart). Enable chat.mcp.gallery.enabled if the gallery does not show.
The registry only stores metadata; the server still runs locally via stdio (for example npx -y mcp-server-sfmc@latest). This is separate from @contribute:mcp, which lists VS Code extensions that contribute MCP definitions — use the SFMC Language Service for that path.
After publishing metadata (see Publish an MCP Server or the release workflow), you can confirm the entry with:
curl "https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.JoernBerkefeld/mcp-server-sfmc"
VS Code without manual MCP config
If you use the SFMC Language Service extension (1.101+), it registers this MCP server for discovery in VS Code — you normally do not need to edit .vscode/mcp.json or run npm install for that path; VS Code still launches the published package via npx when the server starts.
For other editors, or if you prefer explicit configuration, use the npx or install options below.
Using this package without the VS Code extension
You do not have to install the VS Code extension. Pick one way to run the server:
None of these replace the VS Code extension for editing (syntax, LSP, snippets); they only expose the MCP server to tools that speak the Model Context Protocol.
CI templates and sfmc-review-diff
Ready-to-copy workflows (GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, Bitbucket Pipelines) live under ci-templates/. They run eslint-plugin-sfmc on changed files and sfmc-review-diff on the PR/MR unified diff. See ci-templates/README.md for what each file does and how the two checks differ.
What it gives your AI assistant
Mixed HTML validation boundary
Starting with version 2.10.1, validate_sfmc_html validates embedded AMPscript/GTL and applies SSJS checks only to actual server JavaScript bodies (runat="server", excluding AMPscript script bodies). Browser scripts and non-JavaScript script data are not sent to the SSJS validator. Server diagnostics retain locations in the original HTML, and browser declarations, Core loads, or polyfills cannot suppress server warnings. HTML without server JavaScript does not receive an SSJS incompatibility error solely because target is 'next'.
This tool does not validate browser JavaScript or provide DOM/type diagnostics. The standalone validate_ssjs tool continues to validate raw SSJS with its existing target-platform behavior.
This boundary uses the published validateMixedDocumentSsjs API from sfmc-language-lsp 4.3.1 or newer. Version 2.10.1 raises the dependency floor to ^4.3.1; release verification uses a clean registry-only installation.
Connecting AI clients
VS Code (1.99+) + GitHub Copilot — manual mcp.json
If you are not using the SFMC Language Service extension's built-in MCP registration, add a .vscode/mcp.json file to your project (or copy it from this repo):
Open the file in VS Code — a Start button appears at the top. Click it to launch the server. Open GitHub Copilot Chat in Agent mode and the SFMC tools appear automatically.
Cursor
Add to your Cursor settings (~/.cursor/mcp.json or project-level .cursor/mcp.json):
Restart Cursor. The tools are available in Agent mode.
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Restart Claude Desktop.
Windsurf
Add to your Windsurf MCP settings (~/.codeium/windsurf/mcp_config.json):
Local install (faster startup than npx)
Then replace "command": "npx", "args": ["-y", "mcp-server-sfmc@latest"] with:
Tools
Resources
Prompts
Access via /mcp.sfmc.writeAmpscript etc. in VS Code, or via the prompts API:
Migrating code to Marketing Cloud Next
Marketing Cloud Next (MCN) supports 41 of the 155 AMPscript functions and does not support SSJS. Three supported functions have behavioral differences (see below). The migration toolkit guides you from analysis through to a fully rewritten result.
Recommended workflow
What check_mcn_compatibility tells you
Pass one or more { filename, content } pairs and get back:
- Per-function classification for every AMPscript call site:
- ✅ Supported — works as-is
- ⚠️ Needs review — supported but has behavioral differences in MCN
- ❌ Not supported — no MCN equivalent
- SSJS block analysis — classified as "needs conversion" (has AMPscript equivalents) or "not migratable" (uses JS-native constructs such as
try/catch,forEach, regex) - Migration difficulty per file — Ready / Minor changes needed / Significant rewrite / Not migratable
- Executive summary across all files
What rewrite_for_mcn does
Use the rewrite_for_mcn prompt — it is the primary interface and gives you the full result in one step. It first calls the rewrite_for_mcn tool internally for all deterministic rewrites, then applies AI reasoning to every section the tool could not handle mechanically. You get both the accuracy of rule-based conversion and the intelligence of an AI pass, without having to invoke them separately.
Deterministic rewrites (handled by the tool internally):
- Removes
StringToDate()wrappers fromFormatDate()calls (FormatDate(StringToDate(@x), fmt)→FormatDate(@x, fmt)) - Converts
.NET → Java SimpleDateFormatformat strings (e.g.tt→a) - Annotates
Lookup()calls with an odd number of search arguments - Marks MCE-only AMPscript functions with
%%-- NOT SUPPORTED IN MCN %% - Converts convertible SSJS blocks to AMPscript (
Platform.Function.*→ AMPscript equivalents,Platform.Variable.GetValue/SetValue→@variablereferences) - Flags JS-native SSJS constructs (
try/catch, array methods, regex, complex logic) asMANUAL_REWRITE_REQUIRED
AI reasoning layer (added by the prompt): for each MANUAL_REWRITE_REQUIRED section, the prompt instructs the AI to attempt a full conversion using its knowledge of AMPscript and SSJS, then produces a single final rewritten code block with a prose changelog covering every change.
Pipelines and programmatic use: call the
rewrite_for_mcntool directly when you need the structured JSON output ({ rewrittenCode, changes[], nonMigratableItems[], difficulty, summary }) without the AI layer — for example in a CI step that feeds results to another tool.
The same hybrid pattern applies to convertSsjsToAmpscript and convertAmpscriptToSsjs: always use the prompt for interactive use; use the tool when you need structured output in a pipeline.
MCN behavioral differences to watch for
CloudPages functions — not migratable
Functions that depend on CloudPages context (CloudPagesURL, RequestParameter, QueryParameter, Redirect, MicrositeURL) have no equivalent in Marketing Cloud Next. check_mcn_compatibility and rewrite_for_mcn flag these as Not migratable immediately.
MCN Handlebars
Marketing Cloud Next embeds a locked-down Handlebars templating layer (Handlebars.Net) alongside AMPscript. The server exposes the full helper catalog and conversion tooling, all data-driven from handlebars-data and the handlebarsEquivalent / handlebarsExact fields in ampscript-data — nothing is hand-maintained.
Authoring & lookup
validate_handlebars rejects constructs the MCN engine does not implement — partials ({{> name}}), decorators ({{#* ...}}), and built-in helpers absent from the locked-down runtime.
Conversion categories
AMPscript → Handlebars conversion classifies every function from ampscript-data:
The Approximate note names the closest helper so consumers can tell a function whose call shape merely differs (e.g. ContentBlockByKey → getContentBlock) apart from one with no MCN counterpart at all. convertSsjsToHandlebars is transitive (SSJS → AMPscript → Handlebars) and conservatively flags imperative SSJS for manual rewrite.
Writing effective prompts
Automatic tool use
Clients that honour the MCP instructions field (Cursor, Claude Desktop, GitHub Copilot Agent mode) will call search_help or search_mce_help automatically whenever you ask an MCE administration or setup question — no special phrasing needed. If your client does not process server instructions, or if you want explicit control, the templates below help.
Quick reference: which tool or prompt to use
Copy-paste prompt templates
Classic Engagement admin (most common)
Marketing Cloud Next — developer API
MCN migration analysis
Rewrite code for MCN
Use the rewrite_for_mcn prompt — it first runs the deterministic rewrite tool, then applies AI reasoning to any sections that need it. You get the full result in one step.
Unknown product / migration question
Explicit use of the answerMceHowTo prompt
In clients that support MCP prompts (e.g. VS Code with the /mcp.sfmc.answerMceHowTo command):
Combining MCE admin with code
What to expect from the AI
- The AI cites the product scope (Engagement or Next) in every answer.
- If the bundled excerpts do not cover the question fully, the AI says so and suggests verifying in the live Salesforce Help.
- Function signatures (AMPscript / SSJS) are always sourced from the language catalog, not from training data.
Refresh bundled help indexes
Marketing Cloud Engagement help
The published npm package includes bundled/mce-help/chunks.json, produced by npm run bundle-mce-help. By default the bundler uses the path in MCE_HELP_DOCS (see scripts/bundle-mce-help.mjs); set it to the root of your mirrored MCE Help Markdown tree when not using the maintainer default.
Example: MCE_HELP_DOCS=/absolute/path/to/mce-help-mirror npm run bundle-mce-help
Marketing Cloud Next developer docs
The published npm package includes bundled/mcn-help/chunks.json, produced by npm run bundle-mcn-help. Set MCN_HELP_DOCS to the root of your mirrored MCN developer docs tree when not using the maintainer default (see scripts/bundle-mcn-help.mjs).
To rebuild both indexes in one command: npm run bundle-all
AI code review in pull requests
Cursor Bugbot
Cursor Bugbot reviews pull requests (GitHub) and merge
requests (GitLab) automatically, leaves inline comments with fix suggestions, and publishes
a Cursor Bugbot check. It does not run sfmc-review-diff itself — you make it
SFMC-aware in two ways:
1. Repository rules (BUGBOT.md) — all plans. Copy
ci-templates/BUGBOT.md to .cursor/BUGBOT.md in your repo
root. It tells Bugbot how to review AMPscript, SSJS, and SFMC HTML — unknown functions,
arity, delimiter balance, ES3-only SSJS, and optional Marketing Cloud Next migration
rules. Bugbot reads the root file plus any nested .cursor/BUGBOT.md files near changed
files, so you can scope stricter rules to subfolders.
2. MCP tools (mcp-server-sfmc) — Team / Enterprise plans only. Bugbot can call MCP
tools during a review so its findings come from the same language catalog as the editor:
- In the Bugbot dashboard, enable Bugbot on the repository.
- Open the MCP configuration for Bugbot and add this server:
- Add the tools to Bugbot in the dashboard. The relevant review tools are
review_change,validate_ampscript,validate_ssjs,validate_sfmc_html, andsuggest_fix. TheBUGBOT.mdrules above instruct Bugbot when to call them.
Branch protection: require the
Cursor Bugbotcheck to make sure a review runs before merge. Findings default to aneutralconclusion; enable fail-on-unresolved-issues in the dashboard (where available) if you want findings to produce a failing check.
Run it locally first. In Cursor 3.7+, run /review-bugbot on your branch before you
push; Bugbot reuses that review on the PR/MR with the same diff, avoiding a duplicate run.
GitHub Copilot (cloud agent)
The .github/agents/sfmc-reviewer.agent.md custom agent in this repository configures a GitHub Copilot cloud agent that uses mcp-server-sfmc for SFMC-aware PR reviews.
To enable it in your own repository:
- Copy
.github/agents/sfmc-reviewer.agent.mdto your repo. - In your GitHub repo settings → Copilot → Cloud agent → MCP configuration, add:
- Assign the
sfmc-revieweragent to a pull request by mentioning it in a comment or via the @sfmc-reviewer agent in GitHub Copilot Chat.
GitHub Copilot (dedicated PR review)
Copy .github/copilot-instructions.md from this repo to your project. GitHub Copilot's dedicated PR review feature reads this file and applies the SFMC language rules when summarising your PRs.
GitLab Duo
- Copy the content of
ci-templates/gitlab-duo-review-instructions.mdto.gitlab/duo-instructions.mdin your repository. - GitLab Duo Code Review will apply these instructions on every merge request.
GitLab Duo's dedicated MR review does not support MCP directly. Use the CI lint job below for automated static analysis, and the Duo instructions for AI-assisted review comments.
CI linting (deterministic checks)
For deterministic, blocking CI validation, use the templates provided in ci-templates/.
Each one runs two checks on every PR/MR: eslint-plugin-sfmc on changed files, and
sfmc-review-diff (this package) on the unified diff — so a finding fails the job
regardless of which AI reviewer (Bugbot, Copilot, Duo) is also enabled.
The ESLint job posts lint results as PR/MR comments; the sfmc-review-diff job exits
non-zero on ERROR diagnostics by default (--fail-on warning|info to be stricter).
See ci-templates/README.md for the difference between the two
checks.
ESLint + @eslint/mcp
For AI assistants that don't support MCP but do support tool-calling, you can combine eslint-plugin-sfmc with the official @eslint/mcp server. Add it alongside mcp-server-sfmc:
Create an eslint.config.mjs in your project root:
The @eslint/mcp server exposes an eslint_lint tool that your AI can call to run the full ESLint rule set (including all AMPscript and SSJS rules from eslint-plugin-sfmc) on any file.
Architecture
Both the VS Code extension and the MCP server share exactly the same validation, completion, hover, and lookup logic through sfmc-language-lsp. This means the AI assistant sees the same errors and suggestions that the editor shows.
Contributing
See CONTRIBUTING.md.
License
MIT — see LICENSE.
來源:README.md,提交 105f89c
工具
0版本歷史
2- v2.10.1最新Oct 15, 2026
- v2.9.2Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。