Skip to main content
Glama
mcp-salesforce

mcp-salesforce

by Oliviergg

MCP Server for salesforce

Features

  • Connects to Salesforce using environment variables for credentials.

  • Authenticates with the OAuth 2.0 client credentials flow (recommended), or with the legacy username/password SOAP login.

  • Re-authenticates automatically when the Salesforce session expires.

  • Provides tools to:

    • Run SOQL queries.

    • Run SOSL searches.

    • Retrieve metadata about Salesforce object fields.

    • Get, create, update, and delete Salesforce records.

    • Execute Salesforce Tooling API requests.

    • Execute Apex REST API requests.

    • Make direct REST API calls to Salesforce.

  • Caches object field metadata for performance.

  • Handles errors and connection issues gracefully.

Related MCP server: Salesforce MCP Server

Salesforce setup (client credentials flow)

  1. In Setup, create (or edit) a Connected App with OAuth enabled.

  2. Selected OAuth scopes: at least Manage user data via APIs (api).

  3. Check Enable Client Credentials Flow.

  4. In Manage → Edit Policies, set the Run As user: every API call is made as this user, so its profile and permission sets define what the MCP server can see and do.

  5. Collect the Consumer Key and Consumer Secret.

The token endpoint for this flow lives on your My Domain: login.salesforce.com and test.salesforce.com do not serve the client_credentials grant.

Configuration

    {
        "mcpServers": {
            "salesforce": {
                "command": "uvx",
                "args": [
                    "mcp-salesforce"
                ],
                "env": {
                    "SALESFORCE_INSTANCE_URL": "acme",
                    "SALESFORCE_CLIENT_ID": "YOUR_CONNECTED_APP_CONSUMER_KEY",
                    "SALESFORCE_CLIENT_SECRET": "YOUR_CONNECTED_APP_CONSUMER_SECRET"
                }
            }
        }
    }

Environment variables

Variable

Description

SALESFORCE_INSTANCE_URL

My Domain of the org. Accepts a prefix (acme, acme--uat.sandbox.my), a full host (acme.my.salesforce.com), a full URL, or login/test (password flow only).

SALESFORCE_CLIENT_ID

Connected app consumer key (client credentials flow).

SALESFORCE_CLIENT_SECRET

Connected app consumer secret (client credentials flow).

SALESFORCE_USERNAME

Username (legacy password flow).

SALESFORCE_PASSWORD

Password (legacy password flow).

SALESFORCE_SECURITY_TOKEN

Security token (legacy password flow).

SALESFORCE_AUTH_FLOW

Optional, forces client_credentials or password.

SALESFORCE_API_VERSION

Optional, e.g. 62.0. Defaults to the simple-salesforce default.

MCP_SALESFORCE_ENV_FILE

Optional, absolute path of the .env file to read.

Without SALESFORCE_AUTH_FLOW, the flow is chosen from what is present: client credentials when SALESFORCE_CLIENT_ID and SALESFORCE_CLIENT_SECRET are set, otherwise the username/password login.

For sandboxes, use the sandbox My Domain, e.g. SALESFORCE_INSTANCE_URL=acme--uat.sandbox.my.

Storing the credentials

Putting the consumer secret in the MCP client config means it sits in clear text in a file that is often synced or shared. The alternative is a .env file readable only by you:

./scripts/set-credentials.sh

It prompts for the My Domain, the consumer key and the consumer secret; the two secrets are read with a hidden prompt, so they never reach the screen, the shell history or the process arguments. The file is written with mode 600.

The server reads MCP_SALESFORCE_ENV_FILE if set, otherwise it looks for a .env file from the working directory upwards, then next to the package. Point the MCP client at an explicit path when installing with uvx:

    "env": { "MCP_SALESFORCE_ENV_FILE": "/Users/you/.config/mcp-salesforce/.env" }

Environment variables always take precedence over the file.

Verify the credentials without printing them:

python scripts/check_auth.py

It reports the flow used, a masked fingerprint of the key, and the connected app's run-as user as Salesforce sees it.

Legacy username/password flow

Still supported, but Salesforce is retiring the SOAP login() call and orgs increasingly block it (MFA requirements, "API access with legacy protocols" disabled). Prefer the client credentials flow.

                "env": {
                    "SALESFORCE_INSTANCE_URL": "login",
                    "SALESFORCE_USERNAME": "YOUR_SALESFORCE_USERNAME",
                    "SALESFORCE_PASSWORD": "YOUR_SALESFORCE_PASSWORD",
                    "SALESFORCE_SECURITY_TOKEN": "YOUR_SALESFORCE_SECURITY_TOKEN"
                }

You can also use it with simonw/llm cli utils.

Available Tools

10 tools
apex_executeB

Executes an Apex REST request. Args: action: The Apex REST endpoint to call (e.g., '/MyApexClass') method: The HTTP method (default: 'GET') data: Data for POST/PATCH requests

Inputs: action (required), method, data.

create_recordC

Creates a new record. Args: object_name: The name of the Salesforce object (e.g., 'Account', 'Contact') data: The data for the new record

Inputs: object_name (required), data (required).

delete_recordA

Deletes a record. Args: object_name: The name of the Salesforce object (e.g., 'Account', 'Contact') record_id: The ID of the record to delete

Inputs: object_name (required), record_id (required).

get_recordA

Retrieves a specific record by ID. Args: object_name: The name of the Salesforce object (e.g., 'Account', 'Contact') record_id: The ID of the record to retrieve

Inputs: object_name (required), record_id (required).

get_sobject_fieldsA

Retrieves field Names, labels and types for a specific Salesforce object. if there is a lookup, the type is reference with the lookup table name and the fields name.

Args:
    object_name: The name of the Salesforce object (e.g., 'Account', 'Contact')

Inputs: object_name (required).

restfulB

Makes a direct REST API call to Salesforce. Args: path: The path of the REST API endpoint (e.g., 'sobjects/Account/describe') method: The HTTP method (default: 'GET') params: Query parameters for the request data: Data for POST/PATCH requests

Inputs: path (required), method, params, data.

run_soql_queryA

Executes a SOQL query against Salesforce. Args: query: The SOQL query to execute

When using this tool, always use a column name in the query. 
It is important when you aggregate or count. 
In this case use the Id column. example:  select count(Id) from Account

Inputs: query (required).

tooling_executeC

Executes a Tooling API request. Args: action: The Tooling API endpoint to call (e.g., 'sobjects/ApexClass') method: The HTTP method (default: 'GET') data: Data for POST/PATCH requests

Inputs: action (required), method, data.

update_recordA

Updates an existing record. Args: object_name: The name of the Salesforce object (e.g., 'Account', 'Contact') record_id: The ID of the record to update data: The updated data for the record

Inputs: object_name (required), record_id (required), data (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 10 tools

    Disambiguation4/5

    Most tools are clearly distinct (CRUD, queries, Apex, Tooling), but apex_execute and tooling_execute could be confused despite different endpoints. Overall clear.

    Naming Consistency3/5

    Most tools follow verb_noun snake_case, but 'restful' breaks the pattern, and there's inconsistency between 'get', 'run', 'execute' verbs.

    Tool Count5/5

    10 tools is well-scoped for a Salesforce MCP, covering essential operations without being excessive.

    Completeness4/5

    Covers CRUD, queries, metadata, and APIs (Apex, Tooling, REST). Minor gaps like bulk operations or file uploads, but core is solid.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables natural language interactions with Salesforce data and metadata, supporting queries, data manipulation, custom object/field management, Apex code operations, and debug logging across multiple authentication methods.
      15
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables natural language interactions with Salesforce, allowing users to query and modify data, manage custom objects and fields, execute Apex code, and perform SOQL/SOSL searches across Salesforce organizations.
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to securely interact with Salesforce CRM data through SOQL queries, CRUD operations, and metadata exploration. Supports connecting to Salesforce objects like Accounts, Contacts, and Opportunities via OAuth 2.0 authentication.
      8
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Integrates Claude with Salesforce to enable natural language querying, modification, and management of Salesforce records and metadata. It supports comprehensive operations including object/field management, SOSL searches, and Apex code execution.
      1
      MIT