mcp-salesforce-example
mcp-salesforce-example
: An MCP tool for integrating AI models with Salesforce, enabling email sending and Apex code deployment.

mcp-salesforce-example Solution Overview
The mcp-salesforce-example is a valuable MCP resource, providing a bridge between AI models and the Salesforce platform. This tool empowers developers to integrate AI workflows with Salesforce functionalities, such as sending emails and deploying Apex code. It addresses the challenge of securely connecting AI models to external CRM data and processes.
This example leverages the MCP framework to establish a client-server architecture, enabling AI models to trigger actions within Salesforce. By utilizing JWT Bearer Flow authentication, it ensures secure access to Salesforce resources. Developers can configure the integration using a claude_desktop_config.json
file and the provided server.js
to run the MCP server. The core value lies in streamlining the integration process, allowing AI models to seamlessly interact with Salesforce data and workflows, enhancing automation and decision-making capabilities. This solution simplifies the complexities of Salesforce integration, making it accessible to a wider range of AI applications.
mcp-salesforce-example Key Capabilities
Salesforce Email Integration
This feature enables AI models to send emails through Salesforce. It leverages the Salesforce API to create and send email messages, allowing AI to automate communication workflows. The AI model provides the content, recipients, and other relevant details, while the MCP client securely transmits this information to the Salesforce server. The server then uses the Salesforce API to send the email. This integration allows AI models to engage with users directly through personalized email campaigns, automated notifications, and other communication strategies. For example, an AI model could automatically send a welcome email to new users or provide personalized product recommendations based on user behavior. This feature streamlines communication processes and enhances user engagement. The implementation involves using the Salesforce Tooling API to create and deploy Apex code that handles email sending.
Apex Code Deployment
This feature allows AI models to deploy Apex code to a Salesforce org. Apex is Salesforce's proprietary programming language, and deploying code allows for custom logic and functionality to be added to a Salesforce instance. The AI model can generate or modify Apex code, and the MCP client securely transmits this code to the Salesforce server. The server then uses the Salesforce API to deploy the code to the Salesforce org. This feature enables AI models to customize and extend Salesforce functionality, automate complex business processes, and integrate Salesforce with other systems. For example, an AI model could automatically deploy Apex code to create a new custom object or update an existing workflow rule. This feature empowers AI models to drive innovation and efficiency within Salesforce environments. The implementation relies on the Salesforce Tooling API for deploying and managing Apex code.
JWT Bearer Authentication
This feature implements JWT (JSON Web Token) Bearer Flow authentication for secure access to Salesforce. Instead of traditional username/password authentication, the MCP client uses a private key to sign a JWT, which is then presented to Salesforce for authentication. This method is more secure and suitable for automated processes. The getSalesforceCredentials()
function in utils/credentials.js
is responsible for securely loading the necessary credentials, including the private key, client ID (consumer key of the Connected App), and Salesforce login URL. This ensures that the AI model can securely interact with Salesforce without exposing sensitive credentials directly in the code. This approach enhances security and is crucial for production environments. The implementation requires a properly configured Connected App in Salesforce with the necessary scopes and pre-authorization for the relevant user profile.