You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Install Dependencies:
npm install
# or
yarn install
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:
importfsfrom'fs';importpathfrom'path';// You might load these from environment variables, a config file, etc.exportfunctiongetSalesforceCredentials(){// --- IMPLEMENT YOUR LOGIC HERE to securely load credentials ---constloginUrl="YOUR_SALESFORCE_LOGIN_URL";// e.g., https://login.salesforce.com or https://yourdomain.my.salesforce.comconstusername="YOUR_SALESFORCE_USERNAME";constclientId="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.constprivateKey=fs.readFileSync(path.resolve(__dirname,'path/to/your/server.key'),'utf8');// Example: const privateKey = process.env.SF_PRIVATE_KEY;if(!loginUrl||!username||!clientId||!privateKey){thrownewError("Missing required Salesforce credentials in utils/credentials.js");}return{
loginUrl,
username,
clientId,
privateKey
};}
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.