Open Source·AI Agent Infrastructure

Salesforce. Agent-Native.

Accounts. Contacts. Leads. Opportunities. SOQL. Bulk API. Apex. Full Salesforce CRM control from the terminal.

The official Salesforce CLI (sf/sfdx) is a developer toolchain for deploying Apex and running CI/CD — not for agents that need to query pipeline, create leads, or run bulk imports.
So we built salesforce-crm-cli — 102 commands across 20 groups, every one also registered as an MCP tool, wired for autonomous CRM access from day one.

View on GitHubInstall from npm
102
Commands
20
Command Groups
102
MCP Tools
OpenClaw
OpenClaw
CLI / MCP
Salesforce
102 commands · 20 command groups · 102 MCP tools · zero dashboard

Why salesforce-crm-cli Exists

Not to be confused with the official @salesforce/cli. That tool ships Apex, manages scratch orgs, and powers CI/CD pipelines — built for Salesforce developers. This is built for the rest of us: agents that need to read and write CRM data.

Without salesforce-crm-cli

  • Hand-rolled REST calls — auth, retries, rate-limit, pagination, all bespoke
  • SOQL response parsing is verbose — nested records, attributes envelopes, null fields
  • Bulk imports require multi-step job orchestration agents constantly get wrong
  • Custom objects need code changes — no generic CRUD layer for Custom__c
  • No MCP wrapper — every agent integration starts from scratch

With salesforce-crm-cli

  • 102 commands with flat, JSON-first output — no envelopes, no nested parsing
  • SOQL, SOSL, Bulk API 2.0, Composite, and Apex all live behind the same interface
  • Generic sobjects commands handle any custom object out of the box
  • 102 MCP tools — plug directly into Claude Code, Claude Desktop, or Cursor
  • Zod-validated inputs on every command — agent calls fail loudly, not silently

What Your Agent Can Do

102 commands across 20 groups — every Salesforce CRM operation your agent needs.

Core CRM Object CRUD

Accounts, contacts, leads, opportunities, cases, tasks, events, campaigns, users — each with list/get/create/update/delete/search/describe. Every record type your agent needs to read or write, behind one consistent JSON-first interface.

SOQL Queries with Aggregates

Run any SOQL — GROUP BY, HAVING, subqueries, date literals like THIS_QUARTER, dot-notation relationships. Agents pull pipeline totals, win rates, contact rollups, and analytic reports in one shot. Cursor-paginate huge result sets with `query more`.

SOSL Full-Text Search

Search across every searchable Salesforce object in a single query — find a name across accounts, contacts, leads, and opportunities at once. Get auto-complete suggestions for a partial string. Agents resolve "find Acme" without knowing which object holds it.

Generic & Custom SObject Ops

Work with any SObject type — including custom objects like MyObject__c. List, describe, get, create, update, delete, upsert by external ID. No code changes to support every custom field your org has bolted onto Salesforce over the years.

Bulk API 2.0 — Mass Operations

Upload thousands of records per job, monitor progress, fetch successful/failed results. Insert, update, upsert, or delete via CSV. Run bulk SOQL exports for entire object tables. The right tool for any agent task that crosses the 200-record threshold.

Composite API — Chained Calls

Multiple Salesforce API calls in a single HTTP request — with cross-request references. Create an account and a child contact that references its ID in one round trip. Submit up to 200 records as a collection. Build atomic, multi-object workflows your agent runs in milliseconds.

Apex Execution + Test Runs

Execute anonymous Apex from the terminal. Call custom Apex REST endpoints. Trigger test classes and fetch results by run ID. Your agent debugs production logic, fires custom server-side workflows, or runs the test suite as part of a CI check — without leaving the CLI.

MCP Server Mode

102 MCP tools registered for direct AI agent connectivity. Run salesforce-crm-cli as an MCP server and give Claude, Cursor, or any MCP-compatible agent full Salesforce CRM access with one config entry. Zod-validated inputs on every tool — no malformed payloads slipping through.

Agent Workflows

Real use cases — what your agent can run autonomously today.

Lead-to-Opportunity — Full Pipeline Creation

Jane Doe at Acme just booked a discovery call. Create her as a lead, spin up an opportunity, and set me a follow-up task.

Agent creates the lead, finds (or creates) the parent account, opens the opportunity at Prospecting, and schedules a follow-up task. Three Salesforce objects, one prompt, zero clicks.

01
salesforce leads create --first-name "Jane" --last-name "Doe" --company "Acme" --email "jane@acme.com" --source "Web"

Create the lead with attribution source

02
salesforce opportunities create --name "Acme Corp — Enterprise" --stage "Prospecting" --close-date "2026-06-30" --amount "75000" --account-id "001xx000003GYQIAA4"

Open the opportunity at $75K Prospecting

03
salesforce tasks create --subject "Discovery call with Jane" --due-date "2026-05-28" --priority "High" --what-id "006xx000001TNEAAA4"

Schedule follow-up task on the opp

SOQL Analytics — Pipeline by Stage

Show me total pipeline by stage this quarter, sorted by amount.

Agent runs an aggregate SOQL query with GROUP BY, SUM, and a date literal — returns the full pipeline breakdown as structured JSON. No report builder, no exported CSV, no dashboard refresh.

01
salesforce query run --soql "SELECT StageName, COUNT(Id) Total, SUM(Amount) TotalAmount FROM Opportunity WHERE CloseDate = THIS_QUARTER GROUP BY StageName ORDER BY SUM(Amount) DESC" --pretty

Aggregate pipeline by stage with totals

02
salesforce query run --soql "SELECT Owner.Name, COUNT(Id) Deals, SUM(Amount) Total FROM Opportunity WHERE CloseDate = THIS_QUARTER GROUP BY Owner.Name" --pretty

Same view rolled up by sales rep

03
salesforce query explain --soql "SELECT Id FROM Opportunity WHERE CloseDate = THIS_QUARTER"

Inspect query plan and notes before running heavy reports

Bulk CSV Import — Mass Contact Load

Here's a CSV of 5,000 new contacts from the trade show. Load them all into Salesforce and link them to existing accounts.

Bulk API 2.0 handles record loads above the 200-row REST limit. Agent creates an ingest job, uploads the CSV, closes the job, monitors status, and fetches the success/failure breakdown when finished — all without leaving the terminal.

01
salesforce bulk ingest-create --sobject Contact --operation insert

Open a Bulk API 2.0 insert job

02
salesforce bulk ingest-upload --job-id 7500x000000xxxxAAA --csv "FirstName,LastName,Email,AccountId\nJane,Doe,jane@acme.com,001xx000003GYQ\n..."

Upload the 5K-row CSV payload

03
salesforce bulk ingest-close --job-id 7500x000000xxxxAAA

Mark job ready for processing

04
salesforce bulk ingest-status --job-id 7500x000000xxxxAAA

Poll until status = JobComplete

05
salesforce bulk ingest-results --job-id 7500x000000xxxxAAA --type failed

Pull the rows that failed so the agent can retry

Account Discovery — Find a Company + All Contacts

Find every account with "Acme" in the name and pull all their contacts.

Agent searches accounts by partial name, then queries contacts filtered by account ID — returns the full org chart for every matching company. No exports, no manual joins, no copy-paste between tabs.

01
salesforce accounts search --where "Name LIKE '%Acme%'" --pretty

Find every matching account

02
salesforce contacts list --where "AccountId = '001xx000003GYQIAA4'" --pretty

Pull every contact under the matched account

03
salesforce query run --soql "SELECT Name, (SELECT FirstName, LastName, Email, Title FROM Contacts) FROM Account WHERE Name LIKE '%Acme%'" --pretty

Or do it in one nested SOQL query with a subquery

Composite Workflow — Atomic Multi-Object Create

Create a new account, then a contact under it, in a single API call so neither orphans if the other fails.

Composite API lets agents chain calls with cross-request references — @{newAccount.id} in the second call resolves from the first. One HTTP round trip, all-or-nothing semantics, no rollback logic in your agent code.

01
salesforce composite run --requests '[{"method":"POST","url":"/services/data/v62.0/sobjects/Account","referenceId":"newAccount","body":{"Name":"Acme Corp"}},{"method":"POST","url":"/services/data/v62.0/sobjects/Contact","referenceId":"newContact","body":{"LastName":"Smith","AccountId":"@{newAccount.id}"}}]'

Account + Contact in one atomic request

02
salesforce composite tree --sobject Account --records '[{"attributes":{"type":"Account"},"Name":"Parent Corp","Contacts":{"records":[{"attributes":{"type":"Contact"},"LastName":"Smith"}]}}]'

Or use the tree endpoint for parent + nested children

03
salesforce composite collection --method create --records '[{"attributes":{"type":"Lead"},"LastName":"Jones","Company":"ACME"},{"attributes":{"type":"Lead"},"LastName":"Brown","Company":"Globex"}]'

Or batch up to 200 records in one collections call

Quick Start

1Install

terminal
npm install -g salesforce-crm-cli

# Or run without installing
npx salesforce-crm-cli accounts list --pretty

2Authenticate

Three ways to authenticate — CLI flags, environment variables, or stored config. Token + instance URL is the fastest path.

terminal
# Option A — environment variables (recommended)
export SALESFORCE_ACCESS_TOKEN="your_token"
export SALESFORCE_INSTANCE_URL="https://yourorg.salesforce.com"
salesforce status

# Option B — store config locally
salesforce login \
  --access-token your_token \
  --instance-url https://yourorg.salesforce.com

# Option C — OAuth username/password flow
salesforce login \
  --client-id <connected_app_consumer_key> \
  --username <you@yourorg.com> \
  --password <password+security_token>

3First commands

terminal
# Verify auth and check API limits
salesforce status
salesforce limits get --pretty

# Pull 10 most recent accounts
salesforce accounts list --limit 10 --pretty

# Run a SOQL query
salesforce query run --soql "SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Prospecting'"

# Create a lead
salesforce leads create --first-name "Jane" --last-name "Doe" --company "Acme" --email "jane@acme.com"

Commands Reference

102 commands across 20 groups. The 9 core CRM objects share the same 7-command shape (list, get, create, update, delete, search, describe).

CRM objects (9 groups · 63 commands)63 commands
accounts *Account — Name, Type, Industry, Phone, Website, AnnualRevenue
contacts *Contact — FirstName, LastName, Email, Phone, Title, AccountId
leads *Lead — FirstName, LastName, Company, Email, Status, LeadSource
opportunities *Opportunity — Name, StageName, Amount, CloseDate, AccountId
cases *Case — Subject, Status, Priority, Origin, ContactId, AccountId
tasks *Task — Subject, Status, Priority, ActivityDate, WhoId, WhatId
events *Event — Subject, StartDateTime, EndDateTime, Location, WhoId
campaigns *Campaign — Name, Type, Status, StartDate, EndDate, BudgetedCost
users *User — Username, Name, Email, IsActive, ProfileId
query3 commands
query runExecute any SOQL query — aggregates, joins, subqueries, date literals
query explainGet query plan and feedback notes before running heavy reports
query morePaginate large SOQL result sets via cursor URL
search2 commands
search runExecute SOSL across multiple objects in one query
search suggestAuto-complete suggestions for partial strings
sobjects7 commands
sobjects listList every SObject type in the org
sobjects describeFull metadata — fields, types, picklist values, relationships
sobjects getGet any record by SObject type + ID (including custom objects)
sobjects createCreate any record — raw JSON body
sobjects updateUpdate any record — raw JSON body
sobjects deleteDelete any record
sobjects upsertUpsert by external ID — ideal for idempotent agent writes
bulk8 commands
bulk ingest-createOpen a Bulk API 2.0 ingest job (insert/update/upsert/delete)
bulk ingest-uploadUpload CSV payload to an open job
bulk ingest-closeMark job ready for processing
bulk ingest-statusPoll job status until JobComplete
bulk ingest-resultsFetch successful/failed/unprocessed result rows
bulk query-createStart a bulk SOQL query job for huge result sets
bulk query-statusCheck query job progress
bulk query-resultsDownload query results once complete
composite4 commands
composite runMultiple API calls in one request, with cross-request references
composite batchRun up to 25 independent subrequests in parallel
composite treeCreate a parent + nested children in one atomic call
composite collectionCreate/update/delete up to 200 records in one call
reports5 commands
reports listList all reports in the org
reports getGet report metadata
reports runExecute a report and return results
reports dashboards-listList all dashboards
reports dashboards-getGet dashboard metadata + component values
apex4 commands
apex executeRun anonymous Apex code in the org
apex restCall a custom Apex REST endpoint
apex test-runKick off Apex test classes by ID
apex test-resultsFetch test results by run ID
limits3 commands
limits getAPI limits and current usage for the org
limits versionsAll supported Salesforce API versions
limits resourcesAll available REST resources

* Each CRM object group has 7 commands: list, get, create, update, delete, search, describe.

MCP Server Setup

Add salesforce-crm-cli as an MCP server to give Claude or Cursor full Salesforce access — all 102 commands available as native, zod-validated tools.

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

claude_desktop_config.json
{
  "mcpServers": {
    "salesforce": {
      "command": "npx",
      "args": ["salesforce-crm-cli", "mcp"],
      "env": {
        "SALESFORCE_ACCESS_TOKEN": "your-token-here",
        "SALESFORCE_INSTANCE_URL": "https://yourorg.salesforce.com"
      }
    }
  }
}

Claude Code (CLI)

terminal
claude mcp add salesforce -- npx salesforce-crm-cli mcp

Make sure SALESFORCE_ACCESS_TOKEN and SALESFORCE_INSTANCE_URL are set in your environment before running Claude Code.

Cursor / VS Code

Add to .cursor/mcp.json or .vscode/mcp.json in your project:

.cursor/mcp.json
{
  "mcpServers": {
    "salesforce": {
      "command": "npx",
      "args": ["salesforce-crm-cli", "mcp"],
      "env": {
        "SALESFORCE_ACCESS_TOKEN": "your-token-here",
        "SALESFORCE_INSTANCE_URL": "https://yourorg.salesforce.com"
      }
    }
  }
}
OpenClaw

Want us to build this into your stack?

We set up salesforce-crm-cli as part of your OpenClaw agent infrastructure — wired to your pipeline, lead routing, and GTM motion. Your Salesforce becomes a live, agent-readable system of record.

📊 Pipeline automation — agent-driven lead routing, opp updates, and SOQL analytics
🤖 Agent integration — salesforce-crm-cli wired into your OpenClaw GTM agent as MCP tools
🔄 Full-stack automation — n8n + salesforce-crm-cli + Clay + Instantly in one connected loop
Star on GitHub