Back to MCP Servers

Salesforce CLI MCP Server

Official Salesforce MCP server for org management, metadata deploy/retrieve, SOQL queries, Apex testing, LWC development, and DevOps Center workflows.

CRM by Salesforce OAuth2 (delegated via Salesforce CLI org auth) active
Overview

The Salesforce DX MCP Server is the official Model Context Protocol implementation from the Salesforce CLI team, exposing the Salesforce developer toolchain to LLM clients like VS Code Copilot, Claude Code, Cursor, and Cline. It builds on the local Salesforce CLI auth state, so agents act on orgs you have already authorized rather than handling credentials themselves.

The server ships with 60+ tools grouped into toolsets: core, orgs, metadata, data, users, testing, code-analysis, lwc-experts, aura-experts, mobile, mobile-core, devops, enrichment, scale-products, and experts-validation. This covers running SOQL queries, deploying and retrieving metadata, running Apex and agent tests, scanning code with Code Analyzer, scaffolding and reviewing Lightning Web Components, migrating Aura to LWC, generating mobile LWC integrations, and driving DevOps Center work items and pull requests.

Because enabling all tools at once can overwhelm an LLM context window, the server requires you to scope access via the --orgs, --toolsets, and --tools flags, with an experimental --dynamic-tools mode that loads tools on demand. It is currently distributed as a pilot/beta service under Salesforce Beta Services Terms.

Tools

Tool Description
get_username Resolve the appropriate username or alias for org-targeted operations.
resume_tool_operation Resume an incomplete or long-running tool operation.
run_soql_query Execute a SOQL query against an authorized org.
deploy_metadata Deploy metadata source to a Salesforce org.
retrieve_metadata Retrieve metadata from a Salesforce org into the local project.
run_apex_test Run Apex tests in an org and return results.
run_agent_test Execute Agentforce agent tests.
run_code_analyzer Run Salesforce Code Analyzer for security and performance checks.
list_code_analyzer_rules List available Code Analyzer rules.
describe_code_analyzer_rule Show details for a specific Code Analyzer rule.
query_code_analyzer_results Filter and query previously generated Code Analyzer results.
list_all_orgs List configured Salesforce orgs and their status.
create_scratch_org Create a new scratch org (non-GA).
delete_org Delete an authorized org (non-GA).
open_org Open an org in the browser (non-GA).
assign_permission_set Assign a permission set to one or more users.
create_lwc_component_from_prd Generate a Lightning Web Component from a product requirements doc.
create_lwc_jest_tests Generate Jest tests for an LWC component.
review_lwc_jest_tests Review existing LWC Jest tests for correctness.
create_lds_graphql_read_query Build a Lightning Data Service GraphQL read query.
test_lds_graphql_query Execute an LDS GraphQL query against an org.
verify_aura_migration_completeness Validate that an Aura-to-LWC migration is complete.
orchestrate_aura_migration Drive an end-to-end Aura-to-LWC migration workflow.
list_devops_center_projects List DevOps Center projects.
create_devops_center_work_item Create a DevOps Center work item.
commit_devops_center_work_item Commit changes for a DevOps Center work item.
create_devops_center_pull_request Open a pull request for a DevOps Center work item.
promote_devops_center_work_item Promote a work item to the next pipeline stage.
resolve_devops_center_deployment_failure Diagnose and resolve a DevOps Center deployment failure.
get_mobile_lwc_offline_analysis Analyze an LWC for mobile offline compatibility violations.
get_mobile_lwc_offline_guidance Return remediation guidance for mobile offline violations.
scan_apex_class_for_antipatterns Scan an Apex class for performance antipatterns.
validate_and_optimize Run the LWC validation and optimization suite.
score_issues Compute a production readiness score (0-100) from validation issues.
Setup Guide

Prerequisites

  • Node.js with npx available
  • Salesforce CLI installed locally
  • At least one authorized org. Run one of:
    • sf org login web from the Salesforce CLI
    • SFDX: Authorize an Org from the VS Code command palette

Install

The server is distributed as the npm package @salesforce/mcp and is typically run via npx:

npx -y @salesforce/mcp --orgs DEFAULT_TARGET_ORG --toolsets orgs,metadata,data,users

MCP client configuration

VS Code (.vscode/mcp.json):

{
  "servers": {
    "Salesforce DX": {
      "command": "npx",
      "args": [
        "-y", "@salesforce/mcp",
        "--orgs", "DEFAULT_TARGET_ORG",
        "--toolsets", "orgs,metadata,data,users",
        "--tools", "run_apex_test",
        "--allow-non-ga-tools"
      ]
    }
  }
}

Claude Code / Cursor / Cline use the same command and args under their respective mcpServers (Claude Code) or servers (Cursor, Cline) keys in .mcp.json, mcp.json, or cline_mcp_settings.json.

Flags

  • --orgs (required): one or more of DEFAULT_TARGET_ORG, DEFAULT_TARGET_DEV_HUB, ALLOW_ALL_ORGS, or an org username/alias
  • --toolsets: comma-separated list of toolset names to enable (core is always on)
  • --tools: enable specific individual tool names
  • --allow-non-ga-tools: opt in to experimental, non-GA tools
  • --dynamic-tools: load tools on demand (experimental, VS Code and Cline only)
  • --no-telemetry: disable telemetry
  • --debug: enable debug logging
Use Cases
  • Query production and sandbox orgs with natural language that compiles to SOQL, returning records via run_soql_query.
  • Deploy and retrieve metadata between local source and orgs during feature work, using deploy_metadata and retrieve_metadata.
  • Run Apex tests and Code Analyzer scans on a branch before opening a pull request, using run_apex_test and run_code_analyzer.
  • Scaffold and review Lightning Web Components, including Jest tests and LDS GraphQL queries, from PRDs or Figma designs.
  • Drive DevOps Center work items end to end: create the item, commit, open a PR, promote stages, and resolve deployment failures.
Example Prompts
  • "Run a SOQL query against my default org to list the 20 most recently modified Accounts with their Owner."
  • "Deploy the force-app/main/default/classes folder to my staging org and run all local Apex tests."
  • "Retrieve the Account and Contact custom fields from production into this project."
  • "Generate an LWC called caseTriagePanel from this PRD and create Jest tests for it."
  • "Create a DevOps Center work item titled Fix Opportunity rollup, commit my changes, and open a pull request."
Pros
  • Official server maintained by the Salesforce CLI team under salesforcecli/mcp.
  • Very broad surface area: 60+ tools across metadata, data, testing, code analysis, LWC, Aura migration, mobile, and DevOps Center.
  • Reuses existing Salesforce CLI org auth, so the LLM never sees credentials.
  • Granular scoping via --orgs, --toolsets, and --tools to keep context manageable.
Limitations
  • Pilot/beta status with Beta Services Terms; some tools are explicitly non-GA and require --allow-non-ga-tools.
  • Enabling all toolsets can overwhelm an LLM's context window, so users must hand-pick toolsets.
  • Requires a local Salesforce CLI install plus pre-authorized orgs; not a zero-setup remote server.
  • Experimental --dynamic-tools mode currently only works in VS Code and Cline.
Alternatives
  • smn2gnt/MCP-Salesforce and other community Salesforce MCP servers focused on SOQL and basic CRUD.
  • Direct use of the Salesforce CLI (sf) from an agent shell, without MCP.
  • HubSpot or Zoho MCP servers if the underlying need is general CRM access rather than Salesforce-specific dev tooling.