home / mcp / salesforce mcp server
Provides SOQL querying and Lead CRUD operations against Salesforce via an MCP server with OAuth authentication.
Configuration
View docs{
"mcpServers": {
"tweiss777-salesforce-mcp": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/salesforceMCP",
"run",
"main.py"
],
"env": {
"URL": "your-instance.my.salesforce.com",
"PASSWORD": "your_password",
"USERNAME": "your_username",
"CLIENT_ID": "your_client_id",
"CLIENT_SECRET": "your_client_secret"
}
}
}
}This MCP server enables you to query Salesforce data using SOQL and manage Lead objects through a secure, OAuth 2.0 authenticated interface. It runs as a local MCP service that you can connect to from your MCP clients to perform read and write operations against Salesforce, making it easier to empower AI assistants with real-time CRM data.
You interact with this Salesforce MCP server by starting it as a local process and then configuring your MCP client to connect to it. The server exposes tools to run SOQL queries and to perform CRUD operations on Leads. You will authenticate with Salesforce using the OAuth 2.0 password grant flow, obtain an access token, and then issue requests through the provided endpoints.
Typical usage patterns include: 1) Running a SOQL query to fetch contact or lead data, 2) Creating a new Lead with required fields, 3) Reading, updating, or deleting an existing Lead by its Salesforce ID. Ensure you provide the required fields for create and update operations and supply the Lead ID for get, update, or delete actions.
Prerequisites you need before installation: Python 3.14 or newer, a Salesforce account with API access, and OAuth credentials (Client ID and Client Secret). You will also use a local runtime tool to start the MCP server.
Step 1: Clone the project repository.
git clone <repository-url>
cd salesforceMCPStep 2: Install dependencies using the recommended runtime. You will start the server in development mode with the provided runtime tool.
uv syncStep 3: Create a .env file in the project root with your Salesforce credentials.
URL=your-instance.my.salesforce.com
CLIENT_ID=your_client_id
CLIENT_SECRET=your_client_secret
USERNAME=your_username
PASSWORD=your_passwordConfigure your MCP client to connect to the local Salesforce MCP server. The following examples show how to wire the server into Claude Desktop and Cursor using the runtime runner. Replace the absolute path to the project directory and fill in your Salesforce credentials.
{
"mcpServers": {
"salesforce": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/salesforceMCP",
"run",
"main.py"
],
"env": {
"URL": "your-instance.my.salesforce.com",
"CLIENT_ID": "your_client_id",
"CLIENT_SECRET": "your_client_secret",
"USERNAME": "your_username",
"PASSWORD": "your_password"
}
}
}
}For Cursor, use the same configuration shape and place it in your MCP settings file.
{
"mcpServers": {
"salesforce": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/salesforceMCP",
"run",
"main.py"
],
"env": {
"URL": "your-instance.my.salesforce.com",
"CLIENT_ID": "your_client_id",
"CLIENT_SECRET": "your_client_secret",
"USERNAME": "your_username",
"PASSWORD": "your_password"
}
}
}
}Important considerations: do not commit the .env file to version control and protect OAuth credentials. Use environment variables for sensitive configuration and validate domain names before making requests.
Error handling is built into the server with logging to stderr, including timestamps and severity levels, to help you diagnose issues with authentication or API requests.
The server uses OAuth 2.0 password grant flow for authentication. Each request to Salesforce goes through the following steps: 1) Authenticate with credentials from your .env file, 2) Obtain an access token, 3) Use the token for API requests.
Run tests with the following command to ensure the MCP server behaves as expected.
pytestView test coverage by running this command.
pytest --cov=src --cov-report=htmlThis MCP server depends on the FastMCP framework, the Model Context Protocol, and common HTTP and testing libraries. Ensure you have Python installed and access to the Salesforce API.
Execute SOQL queries to fetch data from Salesforce within the MCP server.
Perform CRUD operations on Salesforce Lead objects, including create, read, update, delete, and get by ID.