Salesforce MCP Server
The Salesforce MCP Server lets AI agents connect to a Salesforce org to query, search, modify, and administer data through standard Salesforce APIs.
Query & search: Run SOQL (
sf_query, auto-paginated) and SOSL (sf_search).Record CRUD: Create, read, update, upsert (by external ID), and delete records (
sf_get_record,sf_create_record,sf_update_record,sf_upsert_record,sf_delete_record).Bulk operations: Query or load large record volumes via Bulk API 2.0 (
sf_bulk_query,sf_bulk_load).Composite API: Bundle multiple sub-requests into one atomic call (
sf_composite).Discovery & metadata: Describe objects, list objects with filters, and access object/schema MCP resources (
sf_describe_object,sf_list_objects).Org health & limits: Check API usage (
sf_api_usage) and broader org health including limits and license seats (sf_org_health).Custom Apex REST APIs: Call any
@RestResourceendpoint via generic pass-through (sf_call_apex_rest).Platform events / CDC: Subscribe to and replay platform event or Change Data Capture batches (
sf_subscribe_platform_event).Prompts: Ready-made templates like summarize_account, draft_followup_email, and data_hygiene_check.
Safety/elicitation: Confirms risky unscoped queries and deletions before execution (configurable).
Multiple auth options: Interactive OAuth + PKCE per-user login or fixed-identity Client Credentials flow.
Flexible deployment: Runs locally via stdio or remotely via Streamable HTTP; supports uvx, Python source, and Docker.
Provides tools for interacting with Salesforce orgs, including querying and searching data (SOQL/SOSL), record CRUD operations, bulk operations via Bulk API 2.0, composite requests, object discovery, API usage monitoring, and calling custom Apex REST endpoints.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Salesforce MCP Server Find opportunities closed won this quarter and their amounts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Salesforce MCP Server
A custom-built, self-hosted MCP server that lets AI agents (Claude Desktop, Claude Code, the MCP Inspector, or any other MCP client) connect to Salesforce — to query, search, and modify data in an org.
Not a Salesforce product. This is an independent, personal learning project — not affiliated with, endorsed by, or supported by Salesforce, Inc. Full explanation: docs/ARCHITECTURE.md.
New to MCP? If "server," "client," and "tool call" aren't already familiar terms, read docs/MCP_PRIMER.md first — five minutes, and everything else here will make more sense.
Quickstart
You'll need: a Salesforce org with an External Client App set up — a free Developer Edition org works fine — and its Consumer Key in hand. docs/SETUP.md walks through creating that (10–15 min); do it first, then come back here.
Three ways to get a running server — pick whichever fits:
Option A — uvx (fastest; no clone, no venv; requires uv):
export SF_LOGIN_URL=https://your-domain.my.salesforce.com
export SF_CLIENT_ID=your-client-id
uvx --from sf-mcp-server sf-mcp-login # one-time interactive login — opens your browser
uvx sf-mcp-server(sf-mcp-login needs the explicit --from sf-mcp-server — uv only infers
the package name from a bare command when they match, and this package
provides two commands. sf-mcp-server matches its own package name, so it
doesn't need --from.)
Or drop straight into an MCP client's config (Claude Desktop's
claude_desktop_config.json, Claude Code's .mcp.json) with "command": "uvx", "args": ["sf-mcp-server"] and the same env vars, plus
SF_PKCE_TOKEN_CACHE set to an absolute path (the client launches the
server from its own working directory, not wherever you ran
sf-mcp-login, so the default relative cache path won't be found
otherwise) — see docs/USAGE.md for the full config
example. That login step is only needed once — see
docs/AUTHENTICATION.md for what it does and why,
and for the alternative Client Credentials Flow (SF_CLIENT_SECRET, no
login step) if you'd rather use a fixed service identity instead.
Option B — Python from source (for contributing, or if you'd rather not
use uv):
git clone <this-repo-url> && cd salesforce-mcp-server
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
cp .env.example .env # fill in SF_LOGIN_URL / SF_CLIENT_ID
python -m salesforce_mcp.login # one-time interactive login — opens your browser
python -m salesforce_mcp.serverOption C — Docker (no Python setup needed; requires Docker installed
and running — check with docker info):
git clone <this-repo-url> && cd salesforce-mcp-server
docker build -t salesforce-mcp-server .
docker run --rm -i \
-e SF_LOGIN_URL=https://your-domain.my.salesforce.com \
-e SF_CLIENT_ID=your-client-id \
-e SF_CLIENT_SECRET=your-client-secret \
-e SF_AUTH_FLOW=client_credentials \
-e MCP_TRANSPORT=stdio \
salesforce-mcp-serverDocker explicitly pins SF_AUTH_FLOW=client_credentials here rather than
using the default interactive login — there's no browser or display inside
a container for that flow to use. See
docs/AUTHENTICATION.md if you actually want PKCE
in a container anyway (mount a pre-existing .salesforce_pkce_token.json
from the host).
Whichever you pick, that's it running. Next: point the MCP Inspector or Claude Desktop at it and actually try a tool — see docs/USAGE.md.
Quick note on that -e MCP_TRANSPORT=stdio flag in Option C: Python vs.
Docker and stdio vs. HTTP are two separate choices, not tied together —
Python defaults to stdio and Docker's image defaults to HTTP purely for
convenience, but all four combinations actually work. See
docs/MCP_PRIMER.md#the-two-transports-stdio-and-streamable-http
for what each transport actually is and why. For hosting this on a network
instead of running it locally, see docs/DEPLOYMENT.md.
Related MCP server: MCP Salesforce Lite
What it can do
Query & search —
sf_query(SOQL, auto-paginated),sf_search(SOSL)Record CRUD —
sf_get_record,sf_create_record,sf_update_record,sf_upsert_record(by external ID),sf_delete_recordBulk API 2.0 —
sf_bulk_query,sf_bulk_load, for record volumes too large for the one-record-per-call REST tools aboveComposite —
sf_composite, to bundle several sub-requests into one atomic callDescribe/discovery —
sf_describe_object,sf_list_objects(trimmed fields + optionalname_contains/custom_onlyfilters, so it doesn't dump 800+ objects' full raw metadata), also available as MCP Resources (salesforce://objects,salesforce://schema/{sobject})Ops —
sf_api_usage(quick API-limit check),sf_org_health(fuller report: org info, all limits, and license seat usage)Custom APIs —
sf_call_apex_restcalls any custom Apex REST endpoint (@RestResource) your org exposes, no code changes needed — see docs/USAGE.mdPrompts — ready-made task templates for common requests:
summarize_account,draft_followup_email,data_hygiene_check— see docs/USAGE.mdPlatform events / Change Data Capture —
sf_subscribe_platform_eventreplays a bounded batch of events from a platform event or CDC channel, honoring Salesforce's 72-hour Pub/Sub API retention window — see docs/USAGE.mdElicitation — confirms before an unscoped
sf_query/sf_searchor any delete (sf_delete_record,sf_bulk_load(operation="delete")); disable withSF_ELICITATION_ENABLED=false— see docs/USAGE.mdTwo auth options — the default interactive "Login with Salesforce" (OAuth Authorization Code + PKCE, per-user), via
python -m salesforce_mcp.loginor the in-sessionsf_logintool, or the OAuth Client Credentials Flow (one fixed service identity) for headless/shared use, switched withSF_AUTH_FLOW=client_credentials— see docs/AUTHENTICATION.mdResilient by default — retries transient (5xx /
REQUEST_LIMIT_EXCEEDED) Salesforce errors automatically; every other error comes back as a clean, readable message instead of a stack trace
Every tool above talks to a standard Salesforce API out of the box — none
of them are specific to any one org. Two ways to add your own: call
sf_call_apex_rest (works today, zero code) or add a first-class tool of
your own — docs/EXTENDING.md is a step-by-step guide.
Running it remotely (cloud)
The same server also runs as a container behind a network-reachable Streamable HTTP endpoint, for when you want an agent that isn't on the same machine to reach it. This has been built and run locally with Docker and confirmed working — it has not yet been deployed to a real cloud account. docs/DEPLOYMENT.md has the full picture, including that caveat up front, plus two ready-to-try recipes (GCP Cloud Run, AWS App Runner).
Tests
pytest tests/ -v # all Salesforce calls are mocked with respx — no live org needed
ruff check src testsThis is the automated suite — fast, no Salesforce org or Docker required. There are two other, manual checks, each testing something different: Inspector-against-a-real-org (functional — see docs/USAGE.md) and Docker-build-and-curl (plumbing only — see docs/DEPLOYMENT.md).
Documentation
Read in this order if you're getting started:
# | Doc | For |
1 | New to MCP — what a server/client/tool call actually is | |
2 | Creating the Salesforce org + integration, | |
3 | Both auth flows side by side — Client Credentials vs. "Login with Salesforce" (PKCE) | |
4 | Running it — Claude Desktop, Claude Code, MCP Inspector, example prompts | |
5 | Hosting it in the cloud instead of locally | |
6 | Adding your own tool for a custom API | |
7 | Maintainers only — how a PyPI release actually gets published | |
8 | Optional — how and why it was built this way |
License
Available Tools
15 toolssf_api_usageA
Report current Salesforce REST API usage against the org's daily limit.
Reads the Sforce-Limit-Info header from the most recent API call when
available (no extra request needed); falls back to a /limits call
otherwise (e.g. right after server startup, before any other tool ran).
Inputs: no named parameters.
sf_bulk_loadA
Insert/update/upsert/delete a batch of records via Bulk API 2.0.
Use for record volumes too large for sf_create_record/sf_update_record's
one-record-per-call REST endpoints. operation is one of "insert",
"update", "upsert", "delete". external_id_field is required for
"upsert". For "delete", each record dict needs only an "Id" key.
Inputs: records (required), sobject (required), operation (required), external_id_field.
sf_bulk_queryA
Run a SOQL query via Bulk API 2.0, for result sets too large for sf_query.
Slower (job-based, polls until complete) but not subject to sf_query's interactive per-request limits. Prefer sf_query for everyday lookups; reach for this when you expect a very large result set.
Inputs: soql (required).
sf_call_apex_restA
Call a custom Apex REST endpoint exposed by the org.
For any org-specific capability beyond this server's built-in
standard-API tools: an Apex class annotated @RestResource(urlMapping=...)
with @HttpGet/@HttpPost/etc. methods. path is that class's URL
mapping, e.g. "/MyApi/v1/accounts/001xx0000000001AAA" for a class
registered with @RestResource(urlMapping='/MyApi/v1/accounts/*').
method must match whichever HTTP method the class handles.
This is a thin, generic pass-through — it has no idea what any particular custom endpoint does, expects, or returns; that's between the caller and whatever the org's Apex class implements.
Inputs: path (required), method (required), body, params.
sf_compositeA
Bundle multiple sub-requests into one atomic Salesforce API call.
Each entry in requests is a Salesforce composite sub-request, e.g.:
{"method": "POST", "url": "/services/data/v61.0/sobjects/Account",
"referenceId": "NewAccount", "body": {"Name": "Acme"}}
A later sub-request can reference an earlier one's result with
"@{NewAccount.id}" inside its own body or url. With all_or_none true
(the default), the whole batch rolls back if any sub-request fails.
Inputs: requests (required), all_or_none.
sf_create_recordC
Create a new record of the given object type with the given field values.
Inputs: fields (required), sobject (required).
sf_delete_recordC
Delete a record by ID.
Inputs: sobject (required), record_id (required).
sf_describe_objectB
Return field metadata (names, types, picklist values, etc.) for one object.
Inputs: sobject (required).
sf_get_recordA
Fetch a single record by ID. Pass fields to restrict which fields come back.
Inputs: sobject (required), record_id (required), fields.
sf_list_objectsA
List objects available in the org (global describe), for discoverability.
A Developer Edition org alone has 800+ standard objects, so the
result is trimmed to name/label/custom/queryable/createable/
updateable/deletable per object rather than Salesforce's full raw
payload. Narrow further with name_contains (matches name or label,
case-insensitive) or custom_only=True if you don't need the full
list.
Inputs: custom_only, name_contains.
sf_org_healthA
Report the org's overall health: what kind of org it is, current API/ storage/async limits, and license seat usage (user licenses, permission set licenses, installed package licenses).
A heavier, broader report than sf_api_usage (which only checks the daily API request limit) — use this for "what does this org have and how much of it is used", not for a quick mid-conversation limit check.
Inputs: no named parameters.
sf_queryB
Run a SOQL query and return matching records.
Follows nextRecordsUrl automatically so the full result set is
returned in one call, regardless of Salesforce's per-page row limit.
Inputs: soql (required).
sf_searchA
Run a raw SOSL search and return matching records grouped by object type.
Example: FIND {Acme} IN ALL FIELDS RETURNING Account(Name), Contact(Name, Email)
Complements sf_query: SOSL matches keywords across multiple object types and text fields at once, where SOQL needs an exact object and field match.
Inputs: sosl (required).
sf_update_recordC
Update an existing record's field values.
Inputs: fields (required), sobject (required), record_id (required).
sf_upsert_recordA
Create or update a record identified by an external ID field.
The standard idempotent create-or-update integration pattern: safe to call repeatedly with the same external ID without creating duplicates.
Inputs: fields (required), sobject (required), external_id_field (required), external_id_value (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Each tool targets a clearly distinct capability: CRUD, SOQL query, SOSL search, bulk operations, composite calls, metadata lookup, API usage, and org health. Near-overlapping tools like sf_query vs sf_bulk_query and sf_api_usage vs sf_org_health are explicitly differentiated in their descriptions.
The sf_ prefix and snake_case style are consistent, and core record operations follow a clear verb_noun pattern. Minor deviations exist with noun-style names like sf_composite, sf_api_usage, and sf_org_health, but the overall pattern remains predictable.
At 15 tools, the server sits at the upper end of the ideal range but every tool earns its place given Salesforce's broad API surface. There is no obvious redundancy or bloat; the count feels well-scoped for the domain.
The tool set covers the full standard record lifecycle (create, read, update, upsert, delete), plus query/search, metadata discovery, bulk processing, composite transactions, custom Apex REST calls, and API/org health checks. No critical dead ends exist for typical Salesforce integration workflows.
Related MCP Connectors
Connect AI agents to 1000+ apps with managed authentication and tool-calling.
Run SOQL queries to explore and retrieve Salesforce data. Access accounts, contacts, opportunities…
Discover, compare, route, and execute machine-accessible capabilities for AI agents.
Verified, pay-per-use API tools for AI agents through one authenticated connection.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Salesforce organizations through natural language by exposing Salesforce APIs (REST, Bulk v2, GraphQL, Tooling, Auth) as MCP tools for querying data, managing records, and executing SOQL queries.19MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to securely interact with Salesforce CRM data through SOQL queries, CRUD operations, and metadata exploration. Supports connecting to Salesforce objects like Accounts, Contacts, and Opportunities via OAuth 2.0 authentication.82MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to interact with Salesforce through a secure interface for performing CRUD operations, executing SOQL queries, and managing schema discovery. It features a smart learning system that analyzes custom objects and fields to provide intelligent assistance tailored to specific Salesforce configurations.1423 npm17BSD 2-Clause "Simplified"
- AlicenseBqualityDmaintenanceProvides AI agents with secure access to Salesforce data and operations, enabling natural language interaction with CRM for sales, marketing, and executive teams.65MIT