MCP Connector

Integrate Salesforce with MCP Tools

mcp-salesforce is a sample MCP integration for sending emails and deploying Apex code to Salesforce via JWT auth.

Works with salesforce

86
Spark score
out of 100
Updated Mar 2025
Source checked Sep 10, 2026
Version 1.0.0
Models
universal

Add to Favorites

Why it matters

Connect your MCP environment to Salesforce to automate tasks like sending emails and deploying Apex code, streamlining your development and communication processes.

Outcomes

What it gets done

01

Send emails via Salesforce

02

Deploy Apex code to Salesforce

03

Authenticate using JWT Bearer Flow

04

Manage Salesforce credentials securely

Source

Get it from source

Spark does not host a copy of it.

Open source

Reports

Agent outcome reports

No reports yet

Capabilities

Tools your agent gets

email

Send emails through Salesforce

apex_deployment

Deploy Apex code to Salesforce organization

Overview

mcp-salesforce MCP Server

Salesforce MCP Sample Integration demonstrates sending emails and deploying Apex code to Salesforce via MCP tools, authenticated with JWT Bearer Flow. Use it as a reference for building your own Salesforce MCP integration, not as a ready-to-install connector.

What it does

Salesforce MCP Sample Integration is a basic example project showing how to connect Salesforce to an AI assistant via the Model Context Protocol, exposing tools to send emails and deploy Apex code through a Salesforce org, authenticated with the JWT Bearer Flow.

When to use - and when NOT to

Use it as a starting point or reference if you want to build your own Salesforce MCP integration and need a working example of sending emails or deploying Apex code from an AI assistant. It is explicitly a sample project, not a polished, production-ready package: you have to write your own credentials.js file implementing getSalesforceCredentials() to load your Salesforce connection details, and you need a Connected App configured in your Salesforce org for JWT authentication with the right scopes and a pre-authorized user profile. It is not a fit if you want a ready-to-install Salesforce connector; it's meant to be read, adapted, and extended.

Capabilities

The example demonstrates two Salesforce operations reachable as MCP tools: sending emails through Salesforce, and deploying Apex code to a Salesforce org. Authentication uses the JWT Bearer Flow, requiring a login URL, username, Connected App consumer key (client ID), and a private key used to sign the JWT assertion, all supplied through your own credentials.js implementation rather than hardcoded in the repository.

How to install

Requires Node.js and npm or yarn. Install dependencies:

npm install

Create utils/credentials.js exporting a getSalesforceCredentials() function that returns your loginUrl, username, clientId, and privateKey, sourced securely, for example from environment variables, and set up a Connected App in Salesforce for JWT authentication first. The repository includes a sample claude_desktop_config.json to adapt to your own paths and credentials. Run the server directly:

node server.js

Who it's for

Developers who want a working, minimal reference for integrating Salesforce with an MCP-based AI assistant - sending emails and deploying Apex code via JWT auth - as a starting point to build and extend rather than a finished, drop-in connector.

Source README

Salesforce MCP Sample Integration

This project provides a basic example of integrating with Salesforce using the Model Context Protocol (MCP). It allows interaction with Salesforce features like sending emails and deploying Apex code through MCP tools.

Prerequisites

  • Node.js and npm (or yarn) installed.
  • A Salesforce org where you can create a Connected App.

Setup

  1. Install Dependencies:

    npm install
    # or
    yarn install
    
  2. Configure Salesforce Credentials:

    • You MUST create a credentials.js file inside a utils folder (./utils/credentials.js).
    • This file needs to export a function getSalesforceCredentials() which returns your Salesforce connection details necessary for JWT Bearer Flow authentication.
    • Important: Ensure you have a Connected App configured in Salesforce for JWT authentication, allowing the appropriate scopes and pre-authorizing the relevant user profile.

    utils/credentials.js Example:

    import fs from 'fs';
    import path from 'path';
    // You might load these from environment variables, a config file, etc.
    
    export function getSalesforceCredentials() {
        // --- IMPLEMENT YOUR LOGIC HERE to securely load credentials ---
        const loginUrl = "YOUR_SALESFORCE_LOGIN_URL"; // e.g., https://login.salesforce.com or https://yourdomain.my.salesforce.com
        const username = "YOUR_SALESFORCE_USERNAME";
        const clientId = "YOUR_CONNECTED_APP_CONSUMER_KEY";
        // Load your private key used to sign the JWT assertion
        // Ensure the key is formatted correctly, including BEGIN/END lines.
        const privateKey = fs.readFileSync(path.resolve(__dirname, 'path/to/your/server.key'), 'utf8'); 
        // Example: const privateKey = process.env.SF_PRIVATE_KEY;
    
        if (!loginUrl || !username || !clientId || !privateKey) {
             throw new Error("Missing required Salesforce credentials in utils/credentials.js");
        }
    
        return {
            loginUrl,
            username,
            clientId,
            privateKey
        };
    }
    
  3. Configuration File:

    • The repository includes a sample claude_desktop_config.json file that can be used as a template for configuring your MCP server.
    • Update the paths and credentials in this file according to your environment setup.

Running the Server

node server.js

Demo

https://github.com/user-attachments/assets/08c8015a-bc57-4c5e-9f3d-4a9d9d310f4c

Video in higher quality.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.