SFMC MCP Server
A zero-dependency Model Context Protocol server that gives AI agents direct, authenticated access to Salesforce Marketing Cloud, turning natural language into live SFMC queries
SFMC MCP Server
One-Line Summary: A zero-dependency Model Context Protocol server that gives AI agents direct, authenticated access to Salesforce Marketing Cloud. turning natural language into live SFMC queries.
--
Problem Statement
Salesforce Marketing Cloud (SFMC) is notoriously difficult to navigate. Querying assets, checking journey statuses, or inspecting automations requires clicking through a slow web UI or writing custom API integration code from scratch every time. For a team using AI coding agents, there was no way to say "show me all active journeys" and get a live answer. The AI agents had no connection to SFMC. they could only guess based on documentation, not query the actual tenant.
Solution
Built a custom MCP (Model Context Protocol) server that bridges AI agents to the SFMC REST API. The server implements the MCP stdio transport protocol, authenticates via SFMC's server-to-server OAuth 2.0 flow, and exposes a set of tools that any connected AI agent can call directly from natural language prompts. The entire server is a single Python file with zero external dependencies. only the Python standard library is used.
The server is designed to be team-sharable: the .mcp.json project config file can be committed to any repo, and each teammate only needs to create their own .env with SFMC credentials.
Tech Stack
| Layer | Technology |
|---|---|
| Protocol | Model Context Protocol (MCP) over stdio |
| Auth | SFMC OAuth 2.0 server-to-server (client_credentials grant) |
| Language | Python 3 (standard library only. no pip install required) |
| Transport | JSON-RPC 2.0 over stdin/stdout with Content-Length framing |
| Configuration | .env for secrets, .mcp.json for project registration |
Key Features
-
Zero External Dependencies: The entire server runs on Python's standard library (
urllib,json,sys,dataclasses). Nopip installstep, no virtual environment, no dependency conflicts. Copy the file and run it. -
Six Capabilities Exposed to the AI Agent:
-
Inspect non-secret configuration and safety flags before any call
-
Fetch and validate an SFMC access token on demand
-
Execute arbitrary REST API calls against the SFMC tenant
-
Browse Content Builder assets with pagination
-
List all journeys with pagination
-
List all automations with pagination
-
Read-First Safety Model: GET requests work by default. All mutating HTTP methods (POST, PATCH, PUT, DELETE) are blocked unless the
SFMC_ENABLE_MUTATIONS=trueenvironment variable is explicitly set. This prevents AI agents from accidentally modifying production marketing assets. -
Token Caching with Auto-Refresh: Access tokens are cached in memory and automatically refreshed 60 seconds before expiry. No redundant auth calls.
-
Full MCP Protocol Compliance: Implements
initialize,tools/list,tools/call, andnotifications/initializedhandlers with proper JSON-RPC 2.0 error codes. -
Team-Sharable via
.mcp.json: The project config file registers the server at the project level. Any teammate who opens the project gets prompted to approve the MCP server. no manual CLI setup. -
Validated Against Live Tenant: Successfully tested against the client's production SFMC instance. token acquisition, endpoint enumeration, asset listing, journey listing, and automation listing all confirmed working.
Impact / Metrics
- Replaced a multi-click web UI workflow (login, navigate, drill down, scroll, export) with a single natural-language query. Asset, journey, and automation lookups that took 3-5 minutes manually now run in under 10 seconds, with the result delivered as structured data the AI agent can act on directly.
- Enabled AI-assisted marketing cloud management. agents can now inspect journeys, assets, and automations without human navigation
- Zero onboarding friction for teammates: no dependencies to install, just add credentials
- Safety-first design prevents accidental mutations in production
Status
Production. Successfully tested against live SFMC tenant. Server is stable and in use for day-to-day SFMC queries via AI agent. Future planned tools include data extension queries, subscriber lookups, and send log inspection.
More from AI & Automation
More in this category
AI Voice Agent (Hunter)
AI-powered outbound and after-hours inbound calling system that qualifies leads, books appointments, and syncs call outcomes to Salesforce, replacing manual call handling with autonomous voice agents
AI & AutomationRemote Workstation Operations Bridge
A secure chat-based bridge that lets an authorized user trigger commands, run reports, and transfer files on a workstation when they are away from it, with a two-layer security model that blocks destructive operations by default and unlocks only with a password and auto-relocks after five minutes