Salesforce MCP Server is a Model Context Protocol (MCP) server that enables AI assistants to interact with Salesforce organizations. It provides a set of tools that allow AI models to execute Apex code, query data, describe objects, and manage Salesforce org connections through the Salesforce CLI.
NPM Package: @advanced-communities/salesforce-mcp-server
- Node.js (v18 or higher)
- Salesforce CLI (
sf
) installed and configured - At least one authenticated Salesforce org
The easiest way to install Salesforce MCP Server is directly from NPM using npx
:
npx @advanced-communities/salesforce-mcp-server
This command will:
- Download the latest version from NPM
- Run the server directly without manual installation
- Automatically handle all dependencies
Benefits of NPM Installation:
- âś… No manual building required
- âś… Always get the latest stable version
- âś… Automatic dependency management
- âś… Easy updates with
npm update
- âś… No need to clone the repository
For a fully managed installation experience:
- Download the latest
salesforce-mcp-server.dxt
file from the releases page - Double-click the
.dxt
file to install - The extension will be automatically configured in your AI client
- All dependencies will be managed automatically
For development or customization:
- Clone the repository:
git clone https://github.com/advancedcommunities/salesforce-mcp-server.git
- Navigate to the directory:
cd salesforce-mcp-server
- Install and build:
npm install && npm run build
- The server will be available at
build/index.js
To be able to run the MCP Server – you need a client. The client can be any AI app which supports the MCP protocol, such as:
-
Install Claude Desktop from Anthropic.
-
Open it up and authenticate to Claude.
-
Edit your config file at:
- Mac:
~/Library/Application\ Support/Claude/claude_desktop_config.json
- Windows:
C:\\Users\\YOUR_USERNAME\\AppData\\Roaming\\Claude\\claude_desktop_config.json
If you can't find the file. Open Claude Desktop, open the Settings menu, go to the Developer section and click Edit Config inside the servers section. Open and edit this file using the instructions below.
- Mac:
-
Add the following to your config file under the
"mcpServers"
key:{ "mcpServers": { "salesforce-mcp-server": { "command": "npx", "args": ["@advanced-communities/salesforce-mcp-server"] } } }
With environment variables (optional):
{ "mcpServers": { "salesforce-mcp-server": { "command": "npx", "args": ["@advanced-communities/salesforce-mcp-server"], "env": { "READ_ONLY": "true", "ALLOWED_ORGS": "dev,qa,staging" } } } }
-
Restart Claude Desktop (quit & re-open the app). Now you are able to use the MCP in the Claude Desktop.
-
Install Claude Code.
-
Open it up and authenticate to Claude by runnung the
claude
command in your terminal. -
Execute one of the following commands in your terminal:
Basic installation (local scope - default):
claude mcp add salesforce-mcp-server npx @advanced-communities/salesforce-mcp-server
User scope installation (recommended for global access):
claude mcp add --scope user salesforce-mcp-server npx @advanced-communities/salesforce-mcp-server
With environment variables:
# Read-only mode (local scope) claude mcp add salesforce-mcp-server npx @advanced-communities/salesforce-mcp-server -e READ_ONLY=true # Read-only mode (user scope) claude mcp add --scope user salesforce-mcp-server npx @advanced-communities/salesforce-mcp-server -e READ_ONLY=true # Restrict to specific orgs (user scope) claude mcp add --scope user salesforce-mcp-server npx @advanced-communities/salesforce-mcp-server -e ALLOWED_ORGS=dev,qa,staging # Both restrictions (user scope) claude mcp add --scope user salesforce-mcp-server npx @advanced-communities/salesforce-mcp-server -e READ_ONLY=true -e ALLOWED_ORGS=production
Note: By default, Claude Code installs MCP servers in local scope (current directory). Use
--scope user
to install globally for all projects.
The Codex CLI can be configured to leverage MCP servers by defining an mcp_servers section in ~/.codex/config.toml
.
It is intended to mirror how tools such as Claude and Cursor define mcpServers in their respective JSON config files,
though the Codex format is slightly different since it uses TOML rather than JSON, e.g.:
[mcp_servers.salesforce-mcp-server]
command = "npx"
args = ["@advanced-communities/salesforce-mcp-server"]
# Optional: Add environment variables
[mcp_servers.salesforce-mcp-server.env]
READ_ONLY = "true"
ALLOWED_ORGS = "dev,qa,staging"
- In VS Code, open the Command Palette by pressing
Command + Shift + P
orCtrl + Shift + P
. - Type "MCP Add", select the
MCP: Add Server
option. - Select
Command(stdio)
option. - Put the
npx @advanced-communities/salesforce-mcp-server
into the command input. - For MCP Server Id put
salesforce-mcp-server
. - Choose either
Global
orWorkspace
installation option. - (Optional) To add environment variables, manually edit the VS Code settings:
- Open settings.json (
Preferences: Open Settings (JSON)
) - Add environment variables to your MCP server configuration:
"mcp.servers": { "salesforce-mcp-server": { "command": "npx", "args": ["@advanced-communities/salesforce-mcp-server"], "env": { "READ_ONLY": "true", "ALLOWED_ORGS": "dev,qa" } } }
- Open settings.json (
-
Install Cursor
-
Open it up and create your account and connect to a model provider
-
Open
Cursor
->Settings
->Cursor Settings
->Mcp
-
Add new global MCP Server
-
This will drop you into an editor of the JSON config. Fill in a value for the key
salesforce-mcp-server
:{ "mcpServers": { "salesforce-mcp-server": { "command": "npx", "args": ["@advanced-communities/salesforce-mcp-server"] } } }
With environment variables (optional):
{ "mcpServers": { "salesforce-mcp-server": { "command": "npx", "args": ["@advanced-communities/salesforce-mcp-server"], "env": { "READ_ONLY": "true", "ALLOWED_ORGS": "production,staging" } } } }
If there are any existing keys under mcpServer, don't delete them. Add salesforce-mcp-server to the end.
-
Save the file. Go back to the
Cursor Settings
tab. You should see salesforce-mcp-server listed and the dot should go green. -
Open
Composer
view and toggle fromnormal
toagent
(small text on bottom of input) -
You can now use tools
The server supports the following environment variables for access control:
READ_ONLY=true
- Prevents execution of Apex code (anonymous execution and tests)ALLOWED_ORGS=ALL
- Allow access to all orgs (default)ALLOWED_ORGS=org1,org2,org3
- Restrict access to specific org aliases
When ALLOWED_ORGS is set, the list_connected_salesforce_orgs
tool will only show orgs that match the allowed list.
Read-only access to all orgs:
{
"mcpServers": {
"salesforce-mcp-server": {
"command": "npx",
"args": ["@advanced-communities/salesforce-mcp-server"],
"env": {
"READ_ONLY": "true"
}
}
}
}
Full access to specific orgs only:
{
"mcpServers": {
"salesforce-mcp-server": {
"command": "npx",
"args": ["@advanced-communities/salesforce-mcp-server"],
"env": {
"ALLOWED_ORGS": "dev,qa,staging"
}
}
}
}
Read-only access to specific orgs:
{
"mcpServers": {
"salesforce-mcp-server": {
"command": "npx",
"args": ["@advanced-communities/salesforce-mcp-server"],
"env": {
"READ_ONLY": "true",
"ALLOWED_ORGS": "production,prod-backup"
}
}
}
}
You can check the current permission settings using the get_server_permissions
tool.
Once the SF MCP Server is configured in your AI client, you can interact with Salesforce using natural language. The AI assistant will have access to 36 powerful tools:
View all Salesforce orgs currently authenticated with the Salesforce CLI.
Example prompts:
- "Show me all connected Salesforce orgs"
- "List my available Salesforce organizations"
- "Which Salesforce orgs can I access?"
Retrieve all standard and custom objects available in a specific Salesforce org.
Example prompts:
- "List all custom objects in my dev org"
- "Show me all objects in the production org"
- "What custom objects exist in sandbox1?"
Get detailed metadata about a specific Salesforce object, including fields, relationships, and properties.
Example prompts:
- "Describe the Account object in my org"
- "Show me all fields on the Custom_Object__c in dev org"
- "What are the relationships on the Contact object?"
Run anonymous Apex code directly in a Salesforce org and see the debug output.
Example prompts:
- "Execute this Apex in my dev org: System.debug('Hello World');"
- "Run a query in Apex to count all Accounts"
- "Execute Apex code to create a test Account record"
Execute SOQL queries and retrieve results in JSON format.
Example prompts:
- "Query the first 10 Accounts from my org"
- "Find all Contacts with email domain '@example.com'"
- "Get Opportunities closed this month with amount over $10,000"
- "Query all Case records created today"
Execute SOQL queries and save results to CSV or JSON files.
Example prompts:
- "Export all Leads to a CSV file"
- "Save all Opportunities from Q4 2024 to a JSON file"
- "Create a CSV export of Accounts with their related Contacts"
Execute Apex test classes with various options including test level and code coverage.
Example prompts:
- "Run all tests in my dev org"
- "Execute the AccountTriggerTest class with code coverage"
- "Run all local tests excluding managed packages"
Retrieve results from a previous asynchronous Apex test run.
Example prompts:
- "Get the results of test run ID 707xx0000000001"
- "Show me the code coverage from the last test run"
Get code coverage information for a Salesforce org.
Example prompts:
- "What's the overall code coverage in my org?"
- "Show code coverage from the latest test run"
Generate metadata source files for a new Apex class.
Example prompts:
- "Generate a new Apex class called AccountHelper"
- "Create an Apex controller class named MyCustomController"
- "Generate a batch class called DataCleanupBatch in the classes directory"
Generate metadata source files for a new Apex trigger.
Example prompts:
- "Generate a trigger called AccountTrigger for the Account object"
- "Create a before insert trigger for the Contact object"
- "Generate an after update trigger for MyCustomObject__c"
Fetch and list Apex debug logs from the org.
Example prompts:
- "Show me all Apex debug logs in my dev org"
- "List the recent debug logs from production"
- "Get the IDs of debug logs in sandbox"
Fetch specific Apex debug logs or recent logs from the org.
Example prompts:
- "Get the debug log with ID 07L...."
- "Show me the last 5 debug logs from my org"
- "Fetch the most recent debug log from production"
Authenticate and login to a Salesforce org via web browser.
Example prompts:
- "Login to a new production org with alias 'prod'"
- "Connect to a sandbox with alias 'dev-sandbox'"
Check current server permission settings.
Example prompts:
- "Show me the current server permissions"
- "What orgs am I allowed to access?"
Analyze your code with configurable rules to ensure good coding practices.
Example prompts:
- "Run code analyzer on all Apex classes"
- "Analyze my Lightning Web Components for security issues"
- "Check PMD rules on the force-app directory"
List available rules for code analysis.
Example prompts:
- "Show me all available code analyzer rules"
- "List security-related code analysis rules"
- "What ESLint rules are available?"
Scan a codebase with various security and quality rules using multiple engines.
Example prompts:
- "Scan all Apex files for security vulnerabilities"
- "Run PMD and ESLint scanners on my codebase"
- "Check for retire-js vulnerabilities in my JavaScript files"
- "Scan with high severity threshold and save results to CSV"
Run Salesforce Graph Engine for data flow analysis to identify complex security issues.
Example prompts:
- "Run data flow analysis on my Apex controllers"
- "Check for SOQL injection vulnerabilities using Graph Engine"
- "Perform path-based security analysis on all Apex classes"
- "Run DFA with pilot rules enabled"
Assign permission sets to one or more org users.
Example prompts:
- "Assign the DreamHouse permission set to the admin user in my dev org"
- "Grant CloudHouse and AppBuilder permission sets to user@example.com"
- "Assign multiple permission sets to a list of users in sandbox"
Assign permission set licenses to org users.
Example prompts:
- "Assign the Sales Cloud license to user@example.com"
- "Grant Service Cloud permission set license to multiple users"
- "Assign Platform Event license to the admin user"
Display information about a Salesforce user including profile, org ID, and access details.
Example prompts:
- "Show me information about the admin user in my org"
- "Display user details for user@example.com"
- "Get the profile and access token for the current user"
List metadata components and properties of a specified type.
Example prompts:
- "List all CustomObject components in my org"
- "Show me all Dashboard components in the Sales folder"
- "Get all EmailTemplate metadata with API version 60.0"
- "List Layout components and save to a file"
Display details about all metadata types enabled for your org.
Example prompts:
- "Show me all available metadata types in my org"
- "List metadata types for package.xml creation"
- "Get all enabled metadata types with API version 60.0"
- "Display metadata types and save to file for reference"
Log out of a Salesforce org, removing stored authentication.
Example prompts:
- "Logout from my dev org"
- "Remove authentication for sandbox1"
- "Logout from all connected orgs"
Open a Salesforce org in your browser.
Example prompts:
- "Open my dev org in Chrome"
- "Open the Lightning Experience page in my sandbox"
- "Open my org in private/incognito mode"
- "Open a Visualforce page /apex/MyPage in production"
- "Open my FlexiPage in Lightning App Builder"
Open a specific Salesforce record in the browser.
Example prompts:
- "Open record 001XX0000XXXXX in my dev org"
- "Navigate to Account record 001... in production"
- "Show me the Contact record 003... in the browser"
Create a new record in a Salesforce org using the REST API.
Example prompts:
- "Create a new Account with Name 'Acme Corp' and Type 'Customer'"
- "Insert a Contact record with FirstName 'John' and LastName 'Doe'"
- "Create a Case with Subject 'Technical Issue' and Priority 'High'"
- "Add a new Lead with Company 'Tech Startup' and Email 'lead@example.com'"
Update an existing record in a Salesforce org using the REST API.
Example prompts:
- "Update Account 001XX... to set BillingCity to 'San Francisco'"
- "Change the Status of Opportunity 006XX... to 'Closed Won'"
- "Update Contact 003XX... with Phone '(555) 123-4567'"
- "Modify Case 500XX... to set Priority to 'Critical'"
Delete a record from a Salesforce org using the REST API.
Example prompts:
- "Delete the Account record 001XX..."
- "Remove Contact 003XX... from the org"
- "Delete Lead record 00QXX..."
- "Remove the test Case record 500XX..."
Install or upgrade a package version in a Salesforce org.
Example prompts:
- "Install package 04tXXXXXXXXXXXXXX in my dev org"
- "Upgrade the package with ID 04t... in production with 10 minute wait time"
- "Install a protected package with key 'mykey123' in sandbox"
- "Install package and compile only package Apex code"
- "Upgrade unlocked package and deprecate removed components"
Uninstall a second-generation package from a Salesforce org.
Example prompts:
- "Uninstall package 04tXXXXXXXXXXXXXX from my dev org"
- "Remove the package with alias 'old_package' from production"
- "Uninstall package and wait 5 minutes for completion"
- "Remove package with spaces in alias from sandbox"
Generate metadata source files for a new custom tab on a custom object.
Example prompts:
- "Create a tab for MyObject__c with icon 54 in the tabs directory"
- "Generate a custom tab for Invoice__c object with icon 25"
- "Add a navigation tab for Customer__c with icon 75 in force-app/main/default/tabs"
- "Create a tab for Product__c custom object with default icon"
Execute SOSL text-based searches across multiple objects. This is the primary tool for finding records that mention or contain specific text across your Salesforce org.
Example prompts:
- "Search for 'Anna Jones' in all Name fields"
- "Find records containing 'Acme' across all objects"
- "Search for phone number '415-555-1234' in Contact and Lead"
- "Find all records mentioning our competitor 'Acme Corp' across Accounts, Opportunities, and Cases"
- "Execute SOSL: FIND {Smith} IN ALL FIELDS RETURNING Contact, Lead"
Generate Lightning Web Components (LWC) or Aura components with configurable templates and output directories.
Example prompts:
- "Generate a Lightning Web Component called AccountList"
- "Create an Aura component named ContactForm in the components directory"
- "Generate an LWC with analyticsDashboard template called SalesMetrics"
- "Create a Lightning component MyCustomView with default template"
Deploy metadata components to a Salesforce org with various configuration options including test execution.
Example prompts:
- "Deploy all metadata from force-app directory to my dev org"
- "Validate deployment to production with all tests but don't save (dry run)"
- "Deploy specific Apex classes matching 'Account*' pattern to sandbox"
- "Deploy using package.xml manifest with RunLocalTests"
- "Deploy metadata and run specific test classes: TestClass1, TestClass2"
User: "I need to analyze our customer data. First, show me what custom objects we have in the production org."
AI: [Lists all custom objects]
User: "Great! Now query all Customer__c records created this year and export them to CSV."
AI: [Executes query and creates CSV file]
User: "I'm having issues with a trigger. Can you execute this Apex to test it:
List<Account> accs = [SELECT Id, Name FROM Account LIMIT 5];
for(Account a : accs) {
System.debug('Account: ' + a.Name);
}"
AI: [Executes the code and shows debug logs]
User: "I need to document our data model. Can you describe the Order__c object including all its fields and relationships?"
AI: [Provides detailed object metadata]
-
Specify the Target Org: Always mention which org you want to work with (e.g., "in my dev org", "using production")
-
Be Specific with Queries: Provide field names and conditions for SOQL queries
- Good: "Query Account records with Type = 'Customer' and show Id, Name, and CreatedDate"
- Less specific: "Get some Accounts"
-
Object Names: You can use either user-friendly names or API names - the AI assistant will use the describe tools to find the correct API names
- Both work: "Query Custom Object records" or "Query Custom_Object__c records"
- The assistant will automatically resolve field names too
-
Apex Code Formatting: When providing Apex code, you can use code blocks or inline code
-
File Exports: Specify the format (CSV or JSON) when exporting query results
"No orgs found": Make sure you have authenticated orgs using sf org login
"Object not found": Verify the object exists and you're using the correct API name
"Query error": Check your SOQL syntax and field names
"Apex execution failed": Review the debug logs for specific error messages
- The server executes commands with the permissions of the authenticated Salesforce user
- Be cautious when executing DML operations in production orgs
- Review Apex code before execution, especially in production environments
- Consider using sandbox orgs for testing and development
If you want to build the Desktop Extension file yourself:
- Clone the repository and navigate to the
salesforce-mcp-server
directory - Install dependencies:
npm install
- Build the DXT file:
npm run build:dxt
- The
.dxt
file will be created in thedist/
directory - Share this file with others for easy one-click installation
For more details about Desktop Extensions, see DXT.md