This MCP server provides Claude with the ability to interact with Salesforce orgs using the Salesforce CLI. The server wraps the sf
CLI commands and exposes them through the Model Context Protocol (MCP).
Because it wraps the sf
CLI it will have access to your orgs. Models may require some guidance to not provide target orgs if you intend to use the default org of your sf CLI.
- Authentication: Log in to Salesforce orgs using JWT or access token
- Org Management: List and display authenticated orgs
- Metadata Deployment: Validate and deploy metadata to orgs
- Metadata Retrieval: Retrieve metadata from orgs
- Project Generation: Create new Salesforce projects and components
- Apex Execution: Run anonymous Apex code and manage debug logs
- Schema Generation: Generate metadata for custom objects, fields, platform events, and tabs
- Node.js 18.0.0 or later
- Salesforce CLI installed and available in your PATH
npm install -g salesforce-cli-mcp
# Build the Docker image
docker build -t mcp/server-salesforce .
# Run the Docker container
docker run -i --rm -v ${HOME}/.sf:/root/.sf mcp/server-salesforce
# Clone the repository
git clone https://github.com/winter-08/salesforce-cli-mcp.git
cd salesforce-cli-mcp
# Install dependencies
npm install
# Build the TypeScript code
npm run build
You can add the Salesforce MCP server to Claude using the CLI:
# With default working directory
claude mcp add salesforce -- npx -y salesforce-cli-mcp
# With custom working directory
claude mcp add salesforce -- npx -y salesforce-cli-mcp --working-dir /path/to/salesforce/project
Add the following configuration to your claude_desktop_config.json
:
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": [
"-y",
"salesforce-cli-mcp",
"--working-dir",
"/path/to/salesforce/project",
]
}
}
}
To verify that the Salesforce MCP server is properly registered:
# List all registered MCP servers
claude mcp list
Option | Short | Description |
---|---|---|
--working-dir |
-w |
Sets the working directory for Salesforce CLI command execution |
-
login_jwt
: Authenticate to a Salesforce org using JWT -
login_access_token
: Authenticate to a Salesforce org using an access token
-
list_orgs
: List all authenticated Salesforce orgs -
display_org
: Display information about an authenticated Salesforce org
-
deploy_command
: Unified command for deploying or validating metadata (recommended) -
deploy_validate
: Validates a deployment without actually deploying components (legacy)
-
retrieve_metadata
: Retrieves metadata from an org to local directory -
retrieve_start
: Starts an asynchronous retrieve operation
-
project_generate
: Generate a new Salesforce project
-
apex_run
: Execute anonymous Apex code -
apex_get_log
: Get Apex debug logs -
apex_list_log
: List Apex debug logs -
apex_run_test
: Invoke Apex tests in an org -
apex_get_test
: Display test results for a specific asynchronous test run
-
schema_generate_sobject
: Generate metadata source files for a new custom object -
schema_generate_platformevent
: Generate metadata source files for a new platform event -
schema_generate_field
: Generate metadata source files for a new custom field -
schema_generate_picklist_field
: Generate metadata source files for a new custom picklist field -
schema_generate_relationship_field
: Generate metadata source files for a new relationship field (lookup or master-detail) -
schema_generate_tab
: Generate metadata source files for a new custom tab
-
apex_generate_class
: Generate a new Apex class -
apex_generate_trigger
: Generate a new Apex trigger -
lightning_generate_component
: Generate a new Lightning component (Aura or LWC) -
lightning_generate_app
: Generate a new Lightning application -
lightning_generate_event
: Generate a new Lightning event -
lightning_generate_interface
: Generate a new Lightning interface -
lightning_generate_test
: Generate a new Lightning test
- Node.js 18+
- Salesforce CLI (
sf
) installed and in your PATH - Appropriate Salesforce permissions for the operations you want to perform