Claude Code Salesforce MCP Setup: Installation and Configuration Guide (2026)
By Kushal Magar · April 26, 2026 · 16 min read
Key Takeaway
The Salesforce MCP server connects Claude Code to your org in under 30 minutes. Install Node.js 18+, run sf org login web, drop a .mcp.json in your project root, and Claude can run SOQL queries, update records, and deploy metadata — all from natural language. For enrichment workflows, pair it with SyncGTM.
This guide covers the complete Claude Code Salesforce MCP setup — from installing the CLI to running your first SOQL query. The Salesforce MCP server gives you natural language access to your entire org: SOQL queries, bulk record updates, metadata deployment, Apex tests, and more. Setup takes under 30 minutes.
Most tutorials jump straight to the .mcp.json file and skip the parts that cause 80% of failures: Node version mismatches, org authorization edge cases, token expiry, and Windows PATH issues. This guide covers all of them, step by step.
It also covers connected app creation for teams using the Hosted MCP server, token management patterns for shared environments, and five starter SOQL queries you can paste straight into Claude Code to confirm everything is working.
TL;DR
- What it is: Model Context Protocol server published by Salesforce as
@salesforce/mcp— connects Claude Code directly to your org - Setup time: 20–30 minutes for a clean install; under 15 minutes if Salesforce CLI is already installed
- Two server options: DX MCP (local, via npx, free) and Hosted MCP (cloud OAuth, beta as of April 2026)
- No Connected App needed for the DX server — Salesforce CLI handles OAuth automatically
- Key file:
.mcp.jsonin your project root tells Claude Code which MCP servers to load - For enrichment: SyncGTM handles what MCP cannot — adding emails, phone numbers, and firmographics to your Salesforce records
What Is the Salesforce MCP Setup?
The Claude Code Salesforce MCP setup is the process of connecting Claude Code to a live Salesforce org using Model Context Protocol — Anthropic's open standard for giving AI models access to external tools and data sources.
Salesforce published its own MCP implementation as @salesforce/mcp — an open-source npm package maintained by the Salesforce CLI team. Once configured, Claude Code can interact with your org using natural language: query records, deploy metadata, run tests, and manage users.
The setup has three components: authenticating your Salesforce org with the CLI, configuring Claude Code via .mcp.json, and optionally creating a Connected App for teams using the cloud-hosted OAuth server. This guide covers all three.
What Claude Code can do after Salesforce MCP setup
- Run SOQL queries and return formatted pipeline data
- Create, update, and delete Salesforce records in bulk
- Retrieve and deploy metadata (Flows, custom fields, page layouts)
- Run Apex tests and return detailed pass/fail output
- List org users, check permissions, manage permission sets
- Analyze Apex code for security vulnerabilities and best practices
- Inspect org limits and feature flags
According to Salesforce's April 2026 developer announcement, every Developer Edition org now includes access to Salesforce-Hosted MCP Servers at no additional cost. The @salesforce/mcp package exposes 60+ tools across 15 toolsets — covering data operations, metadata, users, Apex testing, code analysis, and DevOps Center pipelines.
Prerequisites
Confirm you have the following before starting. Missing any one of these is the cause of most setup failures.
- Node.js 18+ — required by the
@salesforce/mcppackage. Check:node --version. If below 18, install Node.js LTS or use nvm:nvm install 20 && nvm use 20 - Salesforce CLI (@salesforce/cli) — the unified SF CLI (not the legacy sfdx). Install:
npm install -g @salesforce/cli. Check:sf --version - Claude Code — install:
npm install -g @anthropic-ai/claude-code - Salesforce org access — Developer Edition, sandbox, or production. You need a user with API access and permission to run CLI commands
- npx — ships with Node.js. Verify:
npx --version
Important: SF CLI vs SFDX CLI
The MCP server requires the unified sf CLI (@salesforce/cli), not the legacy sfdx CLI. If sf --version shows an older sfdx-based version, uninstall it and reinstall with npm install -g @salesforce/cli.
Step 1: Install Salesforce CLI and Node.js
If you already have Node.js 18+ and the unified Salesforce CLI installed, skip this step and go to Step 2.
Install or upgrade Node.js
# Check current Node version node --version # Using nvm (recommended — lets you switch versions per project) nvm install 20 nvm use 20 nvm alias default 20 # Verify node --version # Should show v20.x.x
Install the Salesforce CLI
# Install the unified SF CLI npm install -g @salesforce/cli # Verify installation sf --version # Expected output (version numbers will vary): # @salesforce/cli/2.x.x ...
Verify the MCP package is accessible
Test that npx can resolve the @salesforce/mcp package before configuring Claude Code. This catches network or proxy issues early.
npx -y @salesforce/mcp --help # Expected output includes flags: # --orgs Comma-separated list of org aliases # --toolsets Comma-separated list of toolsets to enable # --tools Specific tools to load # --dynamic-tools Load tools on-demand # --debug Enable debug logging
If this command returns an error, confirm that your npm registry is accessible and that Node.js 18+ is active. On corporate networks with proxy settings, you may need to configure npm config set proxy before proceeding.
Step 2: Create a Connected App (Optional for DX)
For the DX MCP server (local npx), you do not need to create a Connected App. The Salesforce CLI ships with its own registered connected app, and sf org login web uses it automatically. Skip to Step 3.
You need a custom Connected App only if you are configuring the Hosted MCP server for team-wide access, or if your org's admin has restricted the default CLI app.
Create a Connected App in Salesforce Setup
- Go to Setup → search for App Manager → click New Connected App
- Set a name (e.g., Claude Code MCP) and enter your email as the contact
- Check Enable OAuth Settings
- Set Callback URL to
http://localhost:1717/OauthRedirect(standard Salesforce CLI callback) - Add OAuth scopes:
api,refresh_token,offline_access. For Hosted MCP, also addsfap_api - Save. Salesforce will take 2–10 minutes to activate the app after creation
After the app activates, copy the Consumer Key (Client ID) and Consumer Secret. Store them securely — you'll need them when running sf org login web --client-id <consumer-key> to authorize with your custom app.
# Authorize using your custom Connected App sf org login web --client-id YOUR_CONSUMER_KEY --alias my-org-custom-app # Confirm sf org list
When you do need a custom Connected App
- Setting up Hosted MCP with sfap_api scope for Agentforce access
- Your org admin has blocked the default Salesforce CLI connected app
- You need IP restriction policies beyond what the CLI app supports
- CI/CD pipelines requiring a dedicated app per environment
Step 4: Configure .mcp.json for Claude Code
The .mcp.json file is Claude Code's address book for MCP servers. Place it in your project root. Claude reads it on startup and launches the configured servers automatically.
Minimal configuration
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": [
"-y",
"@salesforce/mcp",
"--orgs",
"DEFAULT_TARGET_ORG"
]
}
}
}DEFAULT_TARGET_ORG is resolved at runtime from whichever org you set with sf config set target-org.
With toolsets and dynamic loading (recommended)
The full MCP server exposes 60+ tools. Loading all of them at once consumes Claude's context window. Use --toolsets to limit scope, and --dynamic-tools to load tools on-demand.
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": [
"-y",
"@salesforce/mcp",
"--orgs",
"my-sandbox",
"--toolsets",
"data,metadata,users",
"--dynamic-tools"
]
}
}
}For GTM and RevOps use cases, data,metadata,users covers everything you need: SOQL queries, record operations, field creation, and user management. Avoid enabling testing or devops-center unless your workflow specifically requires them.
Available toolsets reference
| Toolset | Flag | Use case |
|---|---|---|
| Data Operations | data | SOQL queries, CRUD operations, bulk updates |
| Metadata | metadata | Retrieve and deploy Flows, fields, layouts |
| Users | users | List users, manage permission sets |
| Orgs | orgs | Org limits, scratch orgs, feature flags |
| Testing | testing | Run Apex tests, return results |
| Code Analysis | code-analyzer | Apex security scanning, best practices |
| DevOps Center | devops-center | Pipeline management, work item promotions |
Multi-org configuration
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": [
"-y",
"@salesforce/mcp",
"--orgs",
"my-sandbox,my-prod-org",
"--toolsets",
"data,metadata",
"--dynamic-tools"
]
}
}
}With multiple orgs, Claude can compare records between sandbox and production, or verify that a metadata deployment matches what is live. Separate aliases with commas — no spaces.
Step 5: Token Management and Session Refresh
Salesforce OAuth tokens expire. The MCP server does not handle token refresh on its own — it relies on the CLI's credential store. When a session expires, Claude will return an authentication error on the next MCP call.
Refresh an expired token
# Re-authorize the specific org that expired sf org login web --alias my-sandbox # Check org status after refresh sf org display --target-org my-sandbox
After re-authorizing, restart Claude Code from your project directory. The MCP server picks up the refreshed credentials automatically on next launch.
Extend session timeout in Salesforce Setup
If sessions expire more frequently than expected, check the session timeout setting in Salesforce. Go to Setup → Security → Session Settings and increase the Timeout Value to 8 or 24 hours.
For developer orgs and sandboxes, a longer timeout reduces friction during active development. For production orgs connected to sensitive data, maintain a shorter timeout and re-authorize before each work session.
Token storage location
The Salesforce CLI stores OAuth tokens in your operating system credential store — not in any file Claude Code can read. On macOS: Keychain. On Windows: Windows Credential Manager. On Linux: the ~/.config/@salesforce directory (encrypted).
Never store Salesforce credentials in .mcp.json, CLAUDE.md, or environment variables. The CLI credential store is the secure pattern — use it.
Check token validity without starting Claude Code
# Display org details including token expiry sf org display --target-org my-sandbox --json # Output includes: # "expirationDate": "2026-05-26T10:00:00.000Z" # "connectedStatus": "Connected"
Step 6: Test Your First Queries
Start Claude Code from the directory containing your .mcp.json file. Claude reads the config on launch and connects to the MCP server automatically.
# Launch Claude Code from your project root claude
Use these five starter prompts to confirm end-to-end connectivity. Each tests a different part of the MCP setup.
Test 1: Verify org connection
Prompt
“List all Salesforce orgs you have access to and show their alias, username, and org type.”
A successful response shows your authorized orgs. This confirms the CLI connection works before you run any data queries.
Test 2: Run a basic SOQL query
Prompt
“Run this SOQL query and return the results as a table: SELECT Id, Name, StageName, Amount, CloseDate FROM Opportunity WHERE IsClosed = false ORDER BY CloseDate ASC LIMIT 10”
Test 3: Query account data
Prompt
“Query the 5 most recently modified Accounts. Show Name, Industry, AnnualRevenue, and LastModifiedDate.”
Test 4: Check org limits
Prompt
“Show me this org's API usage limits and what percentage of the daily limit has been consumed.”
Test 5: List custom fields on Opportunity
Prompt
“List all custom fields on the Opportunity object. Show the field API name, label, data type, and whether it is required.”
If all five prompts return structured data, your claude code salesforce mcp setup is complete and working. If any return errors, jump to the troubleshooting section below.
For more complex automation workflows using Claude Code with Salesforce, see our guide on Claude Code Salesforce MCP workflows and how GTM teams use Claude Code for revenue operations.
Advanced Configuration Options
Hosted MCP server via mcp-remote (Beta)
The Hosted MCP server lets teams share Salesforce access without per-machine CLI setup. It requires the mcp-remote package as an OAuth proxy.
{
"mcpServers": {
"salesforce-hosted": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://mcp.salesforce.com/sse"
]
}
}
}On first connection, a browser opens for OAuth. Approve scopes api, refresh_token, and sfap_api. The DX server remains more stable for individual developers — prefer the Hosted server once it reaches GA.
Debug logging
Add the --debug flag to your MCP args to log all server activity. Copy the output when filing issues on the salesforcecli/mcp GitHub repository.
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": [
"-y",
"@salesforce/mcp",
"--orgs",
"DEFAULT_TARGET_ORG",
"--toolsets",
"data,metadata",
"--dynamic-tools",
"--debug"
]
}
}
}Scoping specific tools (not toolsets)
If you want even finer control, use --tools instead of --toolsets to load only specific named tools. Run npx -y @salesforce/mcp --help to see the full list of available tool names.
Windows-Specific Setup Notes
The Salesforce MCP setup works on Windows, but two issues come up consistently: PATH configuration and shell compatibility.
Issue 1: 'sf' not recognized after install
After running npm install -g @salesforce/cli on Windows, the sf command may not be recognized in PowerShell or Command Prompt. Fix: close all terminal windows, then open a new one. If the issue persists, add the npm global bin directory to your PATH manually.
# Find npm global bin directory npm config get prefix # Add <prefix>in to Windows PATH via System Properties # > Environment Variables > Path > New > paste the path
Issue 2: npx path resolution in .mcp.json
On Windows, Claude Code may fail to resolve npx if it is not in the system PATH. Use the absolute path to npx in your .mcp.json as a fallback.
{
"mcpServers": {
"salesforce": {
"command": "C:\\Users\\YourName\\AppData\\Roaming\\npm\\npx.cmd",
"args": [
"-y",
"@salesforce/mcp",
"--orgs",
"DEFAULT_TARGET_ORG",
"--toolsets",
"data,metadata"
]
}
}
}Find your npx path by running where npx in PowerShell. Replace backslashes with double backslashes in the JSON value.
Issue 3: nvm-windows vs nvm (Unix)
The nvm command on Windows uses nvm-windows (different from the Unix version). Commands are the same: nvm install 20 and nvm use 20. After switching versions, restart your terminal before running any npm commands.
Pair With SyncGTM for Enrichment Workflows
The Salesforce MCP server is a query and modification tool. It reads and writes data that already exists in your org. It does not source new data from external providers.
If your Salesforce contacts are missing emails, phone numbers, or firmographic fields — that is an enrichment problem, not an MCP problem. SyncGTM connects to Salesforce and auto-enriches every contact and account with data from 50+ providers — waterfall enrichment, ICP scoring, and direct sync. See SyncGTM pricing for plans starting at $99/mo.
| Workflow | Salesforce MCP | SyncGTM |
|---|---|---|
| Pipeline SOQL queries | Yes | No |
| Bulk record updates | Yes | Partial |
| Metadata deployment | Yes | No |
| Email enrichment from 50+ providers | No | Yes |
| Phone number waterfall enrichment | No | Yes |
| ICP scoring and firmographic data | No | Yes |
| Buying signal detection | No | Yes |
A common pattern: use Claude Code with the MCP server to create custom fields (e.g., ICP_Score__c), then use SyncGTM to populate those fields with enrichment data automatically. See the sign-up enrichment workflow and the best Salesforce enrichment tools in 2026 for the full picture.
For GTM engineers building broader automation stacks, the top GTM MCPs for Claude Code lists the other MCP servers worth adding alongside the Salesforce one.
MCP Queries Your Salesforce Data. SyncGTM Fills What's Missing.
The MCP setup connects Claude to the records you already have. SyncGTM enriches those records with verified emails, phone numbers, and firmographics from 50+ providers — automatic Salesforce sync at $99/mo.
Try SyncGTM Free — No Credit Card