Labsco
MCP SERVER · OFFICIAL PROJECT

Salesforce DX MCP Server

by salesforcecli

Create a scratch org from a snapshot, deploy the local project into it, and run the Apex tests with code coverage without moving to a terminal.

Build Systems & CI/CDOfficial source
Summary
The scratch-org cycle survives being driven by something other than your hands.

Create an org from a snapshot or definition file, deploy the project into it, run Apex tests with coverage, delete it — the whole loop is covered, and a long job can be picked back up by id, which is the step that usually strands an agent halfway through a deploy. Worth knowing before you wire it up: the delete tool is destructive enough that its own instruction is to confirm with the user first.

What it is

Salesforce's own server over the CLI's operations, organised into toolsets you switch on by name: org resolution, scratch orgs and snapshots, metadata deploy and retrieve, SOQL, permission sets and Apex tests, with further sets for LWC and Aura work, code analysis, mobile, DevOps Center and Apex performance.

What you get
  • Org resolution that works out which username or alias an operation should target, separately for the default target org and the default Dev Hub
  • Scratch orgs created from a definition file, edition, duration or an existing snapshot, aliased and set as default, then deleted when the work is done
  • Metadata deployed from and retrieved into your local project, with the file set calculated for you when you do not name one
  • SOQL run against an org, optionally through the Tooling API
  • Apex tests run by class, method or suite at a test level you choose, with code coverage
  • Permission sets assigned to org users, including on another user's behalf, and an org opened in the browser at a named metadata file
  • A long-running job resumed by its id — a metadata deploy, a scratch org creation, a snapshot — instead of started again
  • Only the tools you asked for: --toolsets names the groups, --tools adds individual ones, and a core set is always on
  • Tools that are not yet generally available held back until --allow-non-ga-tools says otherwise, and telemetry switched off with --no-telemetry
Requirements

Node.js, an org you are already authorized to from this machine, and a local Salesforce project directory for the metadata and Apex tools. The --orgs flag is mandatory and decides what the server may touch: name usernames or aliases to pin it, or pass DEFAULT_TARGET_ORG, which resolves per call and follows whatever your default org happens to be at the time. ALLOW_ALL_ORGS exists and hands over everything you are authorized to. Scratch orgs and snapshots additionally need a Dev Hub. Enabling every toolset puts more than sixty tools in front of the model, which is why the toolsets exist. Apache-2.0.

Setup effort

One command — npx -y @salesforce/mcp@latest --orgs DEFAULT_TARGET_ORG --toolsets orgs,metadata,data,users --tools run_apex_test --allow-non-ga-tools