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

6
MCP tools exposed
0
external dependencies
seconds
SFMC query reduction vs web UI

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

LayerTechnology
ProtocolModel Context Protocol (MCP) over stdio
AuthSFMC OAuth 2.0 server-to-server (client_credentials grant)
LanguagePython 3 (standard library only. no pip install required)
TransportJSON-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). No pip install step, 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=true environment 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, and notifications/initialized handlers 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.

Model Context ProtocolPythonSFMC OAuthJSON-RPC

More in this category