Salesforce CLI for AI Agents

Framework Integration Gradient
Salesforce Logo
CLI Logo
divider

Introduction

CLIs are eating MCPs. The industry is converging on the very same idea. MCPs for all their merit can be token hungry, slow, and unreliable for complex tool chaining. However, coding agents have become incredibly good at working with CLIs, and in fact they are far more comfortable working with CLI tools than MCP.

With Composio's Universal CLI, your coding agents can talk to over 850+ SaaS applications. With Salesforce, agents can add new contact to spring campaign, clone opportunity with all associated products, complete follow-up task for lead smith, and more — all without worrying about authentication.

This guide walks you through Composio Universal CLI and explains how you can connect it with coding agents like Claude Code, Codex, OpenCode, etc, for end-to-end Salesforce automation.

Also integrate Salesforce with

What is Universal CLI and why use it?

The idea behind building the universal CLI is to give agents a single command interface to interact with all your external applications. Here's what you'll get with it:

  • Agent-friendly: Coding agents like Claude Code, Codex, and OpenCode can use CLI tools natively — no MCP setup required.
  • Authentication handled: Connect once via OAuth or API Key, and all CLI commands work with your credentials automatically.
  • Tool discovery: Search, inspect, and execute 20,000+ tools across 850+ apps from one interface.
  • Trigger support: Use triggers to listen for events across your apps, powered by real-time webhooks or polling under the hood.
  • Type generation: Generate typed schemas for autocomplete and type safety in your projects.

Prerequisites

Install the Composio CLI, authenticate, and initialize your project:

bash
# Install the Composio CLI
curl -fsSL https://composio.dev/install | bash

# Authenticate with Composio
composio login

During login you'll be redirected to sign in page, finish the complete flow and you're all set.

Composio CLI authentication flow

Connecting Salesforce to Coding Agents via Universal CLI

Once it is installed, it's essentially done. Claude Code, Codex, OpenCode, OpenClaw, or any other agent will be able to access the CLI. A few steps to give agents access to your apps.

  1. Launch your Coding Agent — Claude Code, Codex, OpenCode, anything you prefer.
  2. Prompt it to "Authenticate with Salesforce"
  3. Complete the authentication and authorization flow and your Salesforce integration is all set.
  4. Start asking anything you want.

Supported Tools & Triggers

Tools
Triggers
Add contact to campaignAdds a contact to a campaign by creating a campaignmember record, allowing you to track campaign engagement.
Add lead to campaignAdds a lead to a campaign by creating a campaignmember record, allowing you to track campaign engagement.
Add product to opportunityAdds a product (line item) to an opportunity.
Apply lead assignment rulesApplies configured lead assignment rules to a specific lead, automatically routing it to the appropriate owner based on your organization's rules.
Associate contact to accountAssociates a contact with an account by updating the contact's accountid field.
Clone opportunity with productsClones an opportunity and optionally its products (line items).
Clone recordCreates a copy of an existing salesforce record by reading its data, removing system fields, and creating a new record.
Complete taskMarks a task as completed with optional completion notes.
Create accountCreates a new account in salesforce with the specified information.
Create campaignCreates a new campaign in salesforce with the specified information.
Create contactCreates a new contact in salesforce with the specified information.
Create leadCreates a new lead in salesforce with the specified information.
Create noteCreates a new note attached to a salesforce record with the specified title and content.
Create opportunityCreates a new opportunity in salesforce with the specified information.
Create taskCreates a new task in salesforce to track activities, to-dos, and follow-ups related to contacts, leads, or other records.
Delete accountPermanently deletes an account from salesforce.
Delete campaignPermanently deletes a campaign from salesforce.
Delete contactPermanently deletes a contact from salesforce.
Delete leadPermanently deletes a lead from salesforce.
Delete notePermanently deletes a note from salesforce.
Delete opportunityPermanently deletes an opportunity from salesforce.
Get accountRetrieves a specific account by id from salesforce, returning all available fields.
Get campaignRetrieves a specific campaign by id from salesforce, returning all available fields.
Get contactRetrieves a specific contact by id from salesforce, returning all available fields.
Get dashboardGets detailed metadata for a specific dashboard including its components, layout, and filters.
Get leadRetrieves a specific lead by id from salesforce, returning all available fields.
Get noteRetrieves a specific note by id from salesforce, returning all available fields.
Get opportunityRetrieves a specific opportunity by id from salesforce, returning all available fields.
Get report metadataGets detailed metadata for a specific report including its structure, columns, filters, and groupings.
Get report instance resultsGets the results of a report instance created by running a report.
Get user infoRetrieves information about the current user or a specific user in salesforce.
List accountsLists accounts from salesforce using soql query, allowing flexible filtering, sorting, and field selection.
List campaignsLists campaigns from salesforce using soql query, allowing flexible filtering, sorting, and field selection.
List contactsLists contacts from salesforce using soql query, allowing flexible filtering, sorting, and field selection.
List dashboardsLists all dashboards available in salesforce with basic metadata including name, id, and urls.
List email templatesLists available email templates in salesforce with filtering and search capabilities.
List leadsLists leads from salesforce using soql query, allowing flexible filtering, sorting, and field selection.
List notesLists notes from salesforce using soql query, allowing flexible filtering, sorting, and field selection.
List opportunitiesLists opportunities from salesforce using soql query, allowing flexible filtering, sorting, and field selection.
List reportsLists all reports available in salesforce with basic metadata including name, id, and urls.
Log callLogs a completed phone call as a task in salesforce with call-specific details like duration, type, and disposition.
Log email activityCreates an emailmessage record to log email activity in salesforce, associating it with related records.
Mass transfer ownershipTransfers ownership of multiple records to a new owner in a single operation using salesforce's composite api for better performance.
Remove from campaignRemoves a lead or contact from a campaign by deleting the campaignmember record.
Run reportRuns a report and returns the results.
Run SOQL queryExecutes a soql query against salesforce data.
Search accountsSearch for salesforce accounts using multiple criteria like name, industry, type, location, or contact information.
Search campaignsSearch for salesforce campaigns using multiple criteria like name, type, status, date range, or active status.
Search contactsSearch for salesforce contacts using multiple criteria like name, email, phone, account, or title.
Search leadsSearch for salesforce leads using multiple criteria like name, email, phone, company, title, status, or lead source.
Search notesSearch for salesforce notes using multiple criteria like title, body content, parent record, owner, or creation date.
Search opportunitiesSearch for salesforce opportunities using multiple criteria like name, account, stage, amount, close date, or status.
Search tasksSearch for salesforce tasks using multiple criteria like subject, status, priority, assigned user, related records, or dates.
Send emailSends an email through salesforce with options for recipients, attachments, and activity logging.
Send email from templateSends an email using a predefined salesforce email template with merge field support.
Send mass emailSends bulk emails to multiple recipients, either using a template or custom content.
Update accountUpdates an existing account in salesforce with the specified changes.
Update campaignUpdates an existing campaign in salesforce with the specified changes.
Update contactUpdates an existing contact in salesforce with the specified changes.
Update leadUpdates an existing lead in salesforce with the specified changes.
Update noteUpdates an existing note in salesforce with the specified changes.
Update opportunityUpdates an existing opportunity in salesforce with the specified changes.
Update taskUpdates an existing task in salesforce with new information.

Universal CLI Commands for Salesforce

You can also manually execute CLI commands to interact with your Salesforce.

Connect your Salesforce account

Link your Salesforce account and verify the connection:

bash
# Connect your Salesforce account (opens OAuth flow)
composio connected-accounts link salesforce

# Verify the connection
composio connected-accounts list --toolkits salesforce

Discover Salesforce tools

Search and inspect available Salesforce tools:

bash
# List all available Salesforce tools
composio tools list --toolkit salesforce

# Search for Salesforce tools by action
composio tools search "salesforce"

# Inspect a tool's input schema
composio tools info SALESFORCE_ADD_CONTACT_TO_CAMPAIGN

Common Salesforce Actions

Add contact to campaignAdds a contact to a campaign by creating a campaignmember record, allowing you to track campaign engagement

bash
composio tools execute SALESFORCE_ADD_CONTACT_TO_CAMPAIGN \
  --contact_id "003XXXXXXXXXXXXXXX" \
  --campaign_id "701XXXXXXXXXXXXXXX"

Add lead to campaignAdds a lead to a campaign by creating a campaignmember record, allowing you to track campaign engagement

bash
composio tools execute SALESFORCE_ADD_LEAD_TO_CAMPAIGN \
  --lead_id "00QXXXXXXXXXXXXXXX" \
  --campaign_id "701XXXXXXXXXXXXXXX"

Add product to opportunityAdds a product (line item) to an opportunity

bash
composio tools execute SALESFORCE_ADD_OPPORTUNITY_LINE_ITEM \
  --quantity "1" \
  --opportunity_id "006XXXXXXXXXXXXXXX" \
  --pricebook_entry_id "01uXXXXXXXXXXXXXXX"

Apply lead assignment rulesApplies configured lead assignment rules to a specific lead, automatically routing it to the appropriate owner based on your organization's rules

bash
composio tools execute SALESFORCE_APPLY_LEAD_ASSIGNMENT_RULES \
  --lead_id "00QWd000005V3RmMAK"

Set up Salesforce Triggers

Listen for events in real time using triggers:

Account Created or UpdatedTriggers when an Account is created or updated in Salesforce

bash
# Find your connected account ID
composio connected-accounts list --toolkits salesforce

# Create a trigger
composio triggers create SALESFORCE_ACCOUNT_CREATED_OR_UPDATED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "fields": "<array>",
  "interval": 2,
  "additional_filter": "<string>"
}'

# Listen for trigger events in real time
composio triggers listen --toolkits salesforce --table

Contact UpdatedTriggers when an existing Salesforce Contact record is modified

bash
# Find your connected account ID
composio connected-accounts list --toolkits salesforce

# Create a trigger
composio triggers create SALESFORCE_CONTACT_UPDATED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "interval": 2,
  "max_batch_size": 100,
  "fields_to_watch": [
    "FirstName",
    "LastName",
    "Name",
    "Email",
    "Phone",
    "Title",
    "Department",
    "AccountId",
    "MailingStreet",
    "MailingCity",
    "MailingState",
    "MailingPostalCode",
    "MailingCountry"
  ]
}'

# Listen for trigger events in real time
composio triggers listen --toolkits salesforce --table

Record Updated (Generic SObject)Triggers when monitored fields change on any Salesforce SObject

bash
# Find your connected account ID
composio connected-accounts list --toolkits salesforce

# Create a trigger
composio triggers create SALESFORCE_GENERIC_S_OBJECT_RECORD_UPDATED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "filter": "<string>",
  "interval": 2,
  "fields_to_monitor": "<array>"
}'

# Listen for trigger events in real time
composio triggers listen --toolkits salesforce --table

Generate Type Definitions

Generate typed schemas for Salesforce tools to get autocomplete and type safety in your project:

bash
# Auto-detect language
composio generate --toolkits salesforce

# TypeScript
composio ts generate --toolkits salesforce

# Python
composio py generate --toolkits salesforce

Tips & Tricks

  • Always inspect a tool's input schema before executing: composio tools info <TOOL_NAME>
  • Pipe output with jq for better readability: composio tools execute TOOL_NAME -d '{}' | jq
  • Set COMPOSIO_API_KEY as an environment variable for CI/CD pipelines
  • Use composio dev logs tools to inspect execution logs and debug issues

Next Steps

  • Try asking your coding agent to perform various Salesforce operations
  • Explore cross-app workflows by connecting more toolkits
  • Set up triggers for real-time automation
  • Use composio generate for typed schemas in your projects

How to build Salesforce MCP Agent with another framework

FAQ

What is the Composio Universal CLI?

The Composio Universal CLI is a single command-line interface that lets coding agents and developers interact with 850+ SaaS applications. It handles authentication, tool discovery, action execution, and trigger setup — all from the terminal, without needing to configure MCP servers.

Which coding agents work with the Composio CLI?

Any coding agent that can run shell commands works with the Composio CLI — including Claude Code, Codex, OpenCode, OpenClaw, and others. Once the CLI is installed, agents automatically discover and use the composio commands to interact with Salesforce and other connected apps.

How is the CLI different from using an MCP server for Salesforce?

MCP servers require configuration and can be token-heavy for complex workflows. The CLI gives agents a direct, lightweight interface — no server setup needed. Agents simply call composio commands like any other shell tool. It's faster to set up, more reliable for multi-step tool chaining, and works natively with how coding agents already operate.

How safe is my Salesforce data when using the Composio CLI?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Salesforce data and credentials are handled as safely as possible. You can also bring your own OAuth credentials for full control.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.