salesforce-cli-mcp
v0.1.7
Published
Salesforce MCP Server wrapping CLI commands
Readme
Salesforce CLI MCP
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.
Features
- 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
Installation
Prerequisites
- Node.js 18.0.0 or later
- Salesforce CLI installed and available in your PATH
Installation Options
NPM Package
npm install -g salesforce-cli-mcpDocker Image
# 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-salesforceBuild from Source
# 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 buildAdding to Claude
With Claude CLI
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/projectWith Claude Desktop
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",
]
}
}
}Verifying Installation
To verify that the Salesforce MCP server is properly registered:
# List all registered MCP servers
claude mcp listCommand Line Options
| Option | Short | Description |
|--------|-------|-------------|
| --working-dir | -w | Sets the working directory for Salesforce CLI command execution |
Available Tools
Authentication
login_jwt: Authenticate to a Salesforce org using JWTlogin_access_token: Authenticate to a Salesforce org using an access token
Org Management
list_orgs: List all authenticated Salesforce orgsdisplay_org: Display information about an authenticated Salesforce org
Metadata Deployment
deploy_command: Unified command for deploying or validating metadata (recommended)deploy_validate: Validates a deployment without actually deploying components (legacy)
Metadata Retrieval
retrieve_metadata: Retrieves metadata from an org to local directoryretrieve_start: Starts an asynchronous retrieve operation
Project Generation
project_generate: Generate a new Salesforce project
Apex Execution and Logs
apex_run: Execute anonymous Apex codeapex_get_log: Get Apex debug logsapex_list_log: List Apex debug logsapex_run_test: Invoke Apex tests in an orgapex_get_test: Display test results for a specific asynchronous test run
Schema Generation
schema_generate_sobject: Generate metadata source files for a new custom objectschema_generate_platformevent: Generate metadata source files for a new platform eventschema_generate_field: Generate metadata source files for a new custom fieldschema_generate_picklist_field: Generate metadata source files for a new custom picklist fieldschema_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
Templates Generation
apex_generate_class: Generate a new Apex classapex_generate_trigger: Generate a new Apex triggerlightning_generate_component: Generate a new Lightning component (Aura or LWC)lightning_generate_app: Generate a new Lightning applicationlightning_generate_event: Generate a new Lightning eventlightning_generate_interface: Generate a new Lightning interfacelightning_generate_test: Generate a new Lightning test
Requirements
- Node.js 18+
- Salesforce CLI (
sf) installed and in your PATH - Appropriate Salesforce permissions for the operations you want to perform
