
Salesforce
STDIOSalesforce MCP server enabling AI tools to interact with Salesforce data and functionality.
Salesforce MCP server enabling AI tools to interact with Salesforce data and functionality.
A comprehensive Model Context Protocol (MCP) server that provides seamless Salesforce integration for AI development tools like Claude Desktop, Cline, and other MCP-compatible clients.
This server is currently in a testing and development phase.
While it offers a comprehensive set of tools for Salesforce integration, please be cautious when using it, especially with production Salesforce orgs. Thorough testing has been conducted, but unexpected issues may still arise.
Feedback & Issue Reporting: Your feedback is highly valuable! If you encounter any issues or have suggestions for improvement:
Thank you for helping improve this tool!
execute-soql
- Execute SOQL queries with auto-bulk switching and paginationexecute-sosl
- Multi-object search with result aggregationdescribe-sobject
- SObject metadata with intelligent cachingexecute-apex
- Anonymous Apex execution with debug log capturerun-apex-tests
- Apex test execution with coverage reportingget-apex-logs
- Debug log retrieval with filteringcreate-record
- Single/bulk record creation with auto-bulk switchingget-record
- Record retrieval with field selectionupdate-record
- Single/bulk record updates with validationdelete-record
- Single/bulk record deletionupsert-record
- External ID-based upsert operations⚠️ Beta Status: These tools are currently in beta and may not work for all metadata types.
list-metadata-types
- Discover metadata typesdeploy-metadata
- Deploy individual metadata components (e.g., ApexClass, CustomObject)retrieve-metadata
- Retrieve individual metadata componentstest-connection
- Connection validation and health monitoringBefore you begin, ensure you have the following installed:
# Clone the repository git clone https://github.com/jaworjar95/salesforce-mcp-server.git cd salesforce-mcp-server # Install dependencies npm install # Build the project npm run build
Create a .env
file with your Salesforce credentials:
# Option 1: Username/Password Authentication (Recommended for development) SF_USERNAME=[email protected] SF_PASSWORD=your-password SF_SECURITY_TOKEN=your-security-token SF_LOGIN_URL=https://login.salesforce.com # Option 2: OAuth2 Authentication (Recommended for production) SF_CLIENT_ID=your-oauth2-client-id SF_CLIENT_SECRET=your-oauth2-client-secret SF_REFRESH_TOKEN=your-refresh-token SF_INSTANCE_URL=https://yourorg.my.salesforce.com # Optional Configuration SF_API_VERSION=63.0
This server supports multiple MCP clients. Choose the configuration that matches your preferred client:
Add the following to your Claude Desktop MCP settings file:
Location: %APPDATA%\Claude\claude_desktop_config.json
Location: ~/Library/Application Support/Claude/claude_desktop_config.json
{ "mcpServers": { "salesforce": { "command": "node", "args": ["path/to/salesforce-mcp-server/build/index.js"], "env": { "SF_USERNAME": "[email protected]", "SF_PASSWORD": "your-password", "SF_SECURITY_TOKEN": "your-security-token", "SF_LOGIN_URL": "https://login.salesforce.com", "SF_API_VERSION": "63.0" }, "disabled": false, "alwaysAllow": [ "test-connection", "execute-soql", "describe-sobject" ] } } }
{ "mcpServers": { "salesforce": { "command": "node", "args": ["path/to/salesforce-mcp-server/build/index.js"], "env": { "SF_CLIENT_ID": "your-oauth2-client-id", "SF_CLIENT_SECRET": "your-oauth2-client-secret", "SF_REFRESH_TOKEN": "your-refresh-token", "SF_INSTANCE_URL": "https://yourorg.my.salesforce.com" } } } }
Cline (VS Code extension) provides advanced MCP server management capabilities.
Cline stores MCP server configurations in:
%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{ "mcpServers": { "salesforce": { "command": "node", "args": ["path/to/salesforce-mcp-server/build/index.js"], "env": { "SF_USERNAME": "[email protected]", "SF_PASSWORD": "your-password", "SF_SECURITY_TOKEN": "your-security-token", "SF_LOGIN_URL": "https://login.salesforce.com", "SF_API_VERSION": "63.0" }, "disabled": false, "alwaysAllow": [ "test-connection", "execute-soql", "describe-sobject", "get-record", "get-apex-logs", "list-metadata-types" ] } } }
{ "mcpServers": { "salesforce": { "command": "node", "args": ["path/to/salesforce-mcp-server/build/index.js"], "env": { "SF_USERNAME": "[email protected]", "SF_PASSWORD": "your-password", "SF_SECURITY_TOKEN": "your-security-token", "SF_LOGIN_URL": "https://login.salesforce.com", "SF_API_VERSION": "63.0" }, "disabled": false, "alwaysAllow": [ "test-connection", "execute-soql", "describe-sobject", "get-record", "get-apex-logs", "list-metadata-types" ], "networkTimeout": 60 } } }
{ "mcpServers": { "salesforce": { "command": "node", "args": ["path/to/salesforce-mcp-server/build/index.js"], "env": { "SF_CLIENT_ID": "your-oauth2-client-id", "SF_CLIENT_SECRET": "your-oauth2-client-secret", "SF_REFRESH_TOKEN": "your-refresh-token", "SF_INSTANCE_URL": "https://yourorg.my.salesforce.com" }, "disabled": false, "alwaysAllow": [ "test-connection", "execute-soql", "describe-sobject", "get-record", "get-apex-logs", "list-metadata-types" ], "networkTimeout": 60 } } }
✅ Safe for Auto-Approval (alwaysAllow
)
test-connection
- Connection validation (read-only)execute-soql
- SOQL queries (read-only)describe-sobject
- Metadata inspection (read-only)get-record
- Single record retrieval (read-only)get-apex-logs
- Debug log access (read-only)list-metadata-types
- Metadata type discovery (read-only)⚠️ Requires Manual Approval
create-record
, update-record
, delete-record
, upsert-record
- Data modificationdeploy-metadata
- Metadata deploymentexecute-apex
, run-apex-tests
- Code executionexecute-sosl
- Search operations (can be resource-intensive)retrieve-metadata
- Metadata retrieval (can be large)Common Issues:
https://test.salesforce.com
for sandboxes) and your sf credentialsnpm run build
to ensure the server is properly compiledExecute SOQL queries with automatic bulk switching for large datasets.
// Example: Query all accounts created today { "query": "SELECT Id, Name, CreatedDate FROM Account WHERE CreatedDate = TODAY", "tooling": false, "bulkThreshold": 2000 }
Perform multi-object searches across your Salesforce org.
// Example: Search for contacts and leads { "searchString": "FIND {John} IN NAME FIELDS RETURNING Contact(Id, Name), Lead(Id, Name)", "searchScope": "NAME" }
Execute anonymous Apex code with debug log capture.
// Example: Create and insert an account { "apexCode": "Account acc = new Account(Name='Test Account'); insert acc; System.debug('Created: ' + acc.Id);", "logLevel": "DEBUG" }
Run Apex tests with detailed coverage reporting.
// Example: Run specific test classes { "testClasses": ["AccountTest", "ContactTest"], "maxFailedTests": 5 }
Create single or multiple records with auto-bulk switching.
// Example: Create multiple accounts { "sobjectType": "Account", "records": [ {"Name": "Company A", "Type": "Customer"}, {"Name": "Company B", "Type": "Prospect"} ], "allOrNone": false }
Deploy individual metadata components or arrays of components.
// Example: Deploy a single ApexClass { "components": { "type": "ApexClass", "fullName": "MyExampleClass", "metadata": { "body": "public class MyExampleClass {\n public static void sayHello() {\n System.debug('Hello from component deployment!');\n }\n}" } }, "options": { "checkOnly": true, // Optional: validate without saving "runTests": ["MyExampleClass_Test"] // Optional: specify tests to run } }
Retrieve individual metadata components or arrays of components.
// Example: Retrieve an ApexClass component { "components": { "type": "ApexClass", "fullName": "MyExistingClass" }, "options": { "includeBody": true // Optional: include source code } }
https://login.salesforce.com
for production or https://test.salesforce.com
for sandboxes# Test individual tools node tests/test-query-tools.js node tests/test-data-tools.js node tests/test-apex-tools.js node tests/test-metadata-tools.js
The test files are organized by functionality:
Each test file creates its own server instance, sends requests to test specific tools, and validates the responses.
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)Jarosław Jaworski
Part of this implementation was developed with assistance from Claude Sonnet 4 using the Cline VS Code extension, demonstrating the power of AI-assisted development in creating comprehensive developer tools.
This project is licensed under the MIT License - see the LICENSE file for details.