salesforce-cli-mcp
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

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-mcp

Docker 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-salesforce

Build 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 build

Adding 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/project

With 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 list

Command 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 JWT
  • login_access_token: Authenticate to a Salesforce org using an access token

Org Management

  • list_orgs: List all authenticated Salesforce orgs
  • display_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 directory
  • retrieve_start: Starts an asynchronous retrieve operation

Project Generation

  • project_generate: Generate a new Salesforce project

Apex Execution and Logs

  • 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 Generation

  • 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

Templates Generation

  • 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

Requirements

  • Node.js 18+
  • Salesforce CLI (sf) installed and in your PATH
  • Appropriate Salesforce permissions for the operations you want to perform

Readme

Keywords

none

Package Sidebar

Install

npm i salesforce-cli-mcp

Weekly Downloads

13

Version

0.1.7

License

BSD-3-Clause

Unpacked Size

165 kB

Total Files

39

Last publish

Collaborators

  • winter-08