by lciesielski
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.
mcp-salesforce-example is a sample project demonstrating how to integrate with Salesforce using the Model Context Protocol (MCP). It enables programmatic interaction with Salesforce functionalities, such as sending emails and deploying Apex code, through MCP tools.
To use mcp-salesforce-example, you need Node.js and npm (or yarn) installed. First, install dependencies using npm install
or yarn install
. Then, configure your Salesforce credentials by creating a credentials.js
file in a utils
folder. This file should export a getSalesforceCredentials()
function that returns your Salesforce connection details for JWT Bearer Flow authentication. Ensure you have a Connected App configured in Salesforce for JWT authentication with appropriate scopes and pre-authorized user profiles. Finally, configure the claude_desktop_config.json
file with your environment setup and run the server using node server.js
.
Q: What are the prerequisites for running this project? A: You need Node.js and npm (or yarn) installed, and a Salesforce org where you can create a Connected App.
Q: How do I configure Salesforce credentials?
A: You must create a credentials.js
file inside a utils
folder. This file needs to export a function getSalesforceCredentials()
which returns your Salesforce connection details necessary for JWT Bearer Flow authentication. Ensure you have a Connected App configured in Salesforce for JWT authentication.
Q: Can I load credentials from environment variables?
A: Yes, the example credentials.js
shows comments indicating that you might load credentials from environment variables, a config file, etc.
Q: Is there a demo available? A: Yes, there is a demo video available on GitHub and a higher quality version on YouTube.
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.
Install Dependencies:
npm install
# or
yarn install
Configure Salesforce Credentials:
credentials.js
file inside a utils
folder (./utils/credentials.js
).getSalesforceCredentials()
which returns your Salesforce connection details necessary for JWT Bearer Flow authentication.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
};
}
Configuration File:
claude_desktop_config.json
file that can be used as a template for configuring your MCP server.node server.js
https://github.com/user-attachments/assets/08c8015a-bc57-4c5e-9f3d-4a9d9d310f4c
Reviews feature coming soon
Stay tuned for community discussions and feedback