Enables interaction with Salesforce CRM through its REST API, allowing for the execution of SOQL queries to retrieve data and the management of Salesforce Lead objects via create, read, update, and delete operations.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Salesforce MCP Serverfind all open leads from the technology industry"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Salesforce MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with Salesforce CRM through its REST API. This server enables AI assistants to query data using SOQL and perform CRUD operations on Salesforce objects like Leads.
Features
SOQL Query Execution: Run Salesforce Object Query Language (SOQL) queries to fetch data from your Salesforce org
Lead Management: Complete CRUD operations (Create, Read, Update, Delete) for Salesforce Lead objects
OAuth Authentication: Secure authentication using OAuth 2.0 password grant flow
Custom Field Support: Handle both standard and custom Salesforce fields
Prerequisites
Python >= 3.14
Salesforce account with API access
OAuth credentials (Client ID and Client Secret)
Installation
Clone the repository:
Install dependencies using uv (recommended) or pip:
Create a
.envfile in the root directory with your Salesforce credentials:
Configuration
To use this MCP server with Claude Desktop or Cursor, you need to configure it in your MCP settings file.
Claude Desktop
Add the following to your Claude Desktop configuration file:
MacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Cursor
Add the following to your Cursor MCP settings file (~/.cursor/mcp.json or similar):
Important: Replace /absolute/path/to/salesforceMCP with the actual absolute path to your project directory, and fill in your Salesforce credentials.
After adding the configuration, restart Claude Desktop or Cursor for the changes to take effect.
Available Tools
1. run_soql
Execute SOQL queries to fetch data from Salesforce.
Parameters:
query(str): The SOQL query to execute
Example:
Note: Custom objects and fields in Salesforce end with __c
2. run_lead_operation
Perform CRUD operations on Salesforce Lead objects.
Operations:
create: Create a new Lead (requiresLastNameandCompany)update: Update an existing Lead (requireslead_id)delete: Delete a Lead (requireslead_id)get: Fetch a Lead by ID (requireslead_id)
Standard Fields:
lead_id: Salesforce Lead ID (required for update, delete, get)last_name: Lead's last name (required for create)company: Lead's company (required for create)first_name: Lead's first namesalutation: Salutation (e.g., 'Mr.', 'Ms.', 'Dr.')title: Job titleemail: Email addressphone: Phone numbermobile_phone: Mobile phone numberfax: Fax numberwebsite: Website URLlead_source: Lead source (e.g., 'Web', 'Phone Inquiry')status: Lead status (e.g., 'Open', 'Contacted', 'Qualified')rating: Lead rating (e.g., 'Hot', 'Warm', 'Cold')industry: Industryannual_revenue: Annual revenue (float)number_of_employees: Number of employees (int)street: Street addresscity: Citystate: State/Provincepostal_code: Postal/ZIP codecountry: Countrydescription: Notes about the leadowner_id: Salesforce User ID of lead owneris_converted: Whether the lead has been converted (bool)custom_fields: Dictionary of custom fields (e.g.,{"My_Field__c": "value"})
Project Structure
Development
Running Tests
Test Coverage
Authentication
This server uses OAuth 2.0 password grant flow for authentication. Each request to Salesforce will:
Authenticate using the credentials from your
.envfileObtain an access token
Use the token for API requests
Error Handling
The server includes comprehensive error logging. Errors are logged to stderr with timestamps and severity levels.
Dependencies
fastmcp>=2.14.1- FastMCP framework for building MCP serversmcp[cli]>=1.25.0- Model Context Protocol implementationrequests>=2.32.5- HTTP library for API requestspytest>=9.0.2- Testing frameworkpytest-cov>=7.0.0- Test coverage pluginpytest-mock>=3.15.1- Mocking plugin for pytest
Security Notes
Never commit your
.envfile to version controlKeep your OAuth credentials secure
Use environment variables for sensitive configuration
Validate domain names before making requests
License
[Add your license information here]
Contributing
[Add contribution guidelines here]