mcp-server-salesforce
by: tsmztech
Salesforce MCP Server
📌Overview
Purpose: To facilitate natural language interactions with Salesforce data and metadata through an MCP server implementation, enabling users to easily query and manage Salesforce objects.
Overview: The Salesforce MCP Server enables users to interact with their Salesforce data using everyday language, allowing for seamless querying and modifications of Salesforce records and objects. Through its integration with Claude, it simplifies complex database interactions, making it accessible to non-technical users.
Key Features:
-
Object and Field Management: Users can create and modify custom objects and fields naturally, streamlining object management processes.
-
Smart Object Search: Leverage partial name matches to quickly locate both standard and custom Salesforce objects, enhancing searchability.
-
Detailed Schema Information: Retrieve comprehensive details about object fields and relationships, aiding in informed decision-making and object understanding.
-
Flexible Data Queries: Perform sophisticated queries with support for relationships and complex filters, providing flexibility in data retrieval.
-
Data Manipulation: Simplified insertion, updating, deletion, and upserting of records allows for efficient data management tasks.
-
Cross-Object Search: Execute SOSL-based searches across multiple objects to gather relevant data in one go, improving efficiency.
-
Intuitive Error Handling: Receive clear feedback with specific Salesforce error details, facilitating easier troubleshooting.
Salesforce MCP Server
An MCP (Model Context Protocol) server implementation that integrates Claude with Salesforce, enabling natural language interactions with your Salesforce data and metadata. This server allows Claude to query, modify, and manage your Salesforce objects and records using everyday language.
Features
- Object and Field Management: Create and modify custom objects and fields using natural language
- Smart Object Search: Find Salesforce objects using partial name matches
- Detailed Schema Information: Get comprehensive field and relationship details for any object
- Flexible Data Queries: Query records with relationship support and complex filters
- Data Manipulation: Insert, update, delete, and upsert records with ease
- Cross-Object Search: Search across multiple objects using SOSL
- Apex Code Management: Read, create, and update Apex classes and triggers
- Intuitive Error Handling: Clear feedback with Salesforce-specific error details
Installation
npm install -g @tsmztech/mcp-server-salesforce
Tools
salesforce_search_objects
Search for standard and custom objects by partial name matches.
Example: "Find objects related to Account" finds Account, AccountHistory, etc.
salesforce_describe_object
Get detailed object schema information including fields, relationships, and picklist values.
Example: "Show me all fields in the Account object"
salesforce_query_records
Query records with relationship support and complex conditions.
Example: "Get all Accounts with their related Contacts"
salesforce_dml_records
Perform data operations: insert, update, delete, upsert.
Example: "Update status of multiple accounts"
salesforce_manage_object
Create and modify custom objects and configure sharing settings.
Example: "Create a Customer Feedback object"
salesforce_manage_field
Manage object fields, including adding custom fields and creating relationships.
Example: "Add a Rating picklist field to Account"
salesforce_search_all
Search across multiple objects with SOSL and get field snippets.
Example: "Search for 'cloud' across Accounts and Opportunities"
salesforce_read_apex
Read Apex classes and view metadata, supporting wildcards.
Example: "Show me the AccountController class"
salesforce_write_apex
Create and update Apex classes specifying API versions.
Example: "Create a new Apex class for handling account operations"
salesforce_read_apex_trigger
Read Apex triggers and their metadata with wildcard support.
Example: "Show me the AccountTrigger"
salesforce_write_apex_trigger
Create and update Apex triggers, specifying API versions and events.
Example: "Create a new trigger for the Account object"
salesforce_execute_anonymous
Execute anonymous Apex code to run scripts or data operations.
Example: "Execute Apex code to calculate account metrics"
salesforce_manage_debug_logs
Manage debug logs including enabling/disabling logs and setting log levels.
Example: "Enable debug logs for user@example.com"
Setup
Salesforce Authentication
You can connect to Salesforce using one of two methods:
1. Username/Password Authentication (Default)
- Set up Salesforce credentials
- Get your security token (reset from Salesforce settings)
2. OAuth 2.0 Client Credentials Flow
- Create a Connected App in Salesforce
- Enable OAuth settings and select "Client Credentials Flow"
- Set scopes (usually "api")
- Save Client ID, Client Secret, and note your instance URL (e.g.,
https://your-domain.my.salesforce.com
)
Usage with Claude Desktop
Add to your claude_desktop_config.json
:
For Username/Password Authentication:
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": ["-y", "@tsmztech/mcp-server-salesforce"],
"env": {
"SALESFORCE_CONNECTION_TYPE": "User_Password",
"SALESFORCE_USERNAME": "your_username",
"SALESFORCE_PASSWORD": "your_password",
"SALESFORCE_TOKEN": "your_security_token",
"SALESFORCE_INSTANCE_URL": "org_url" // Optional. Default: https://login.salesforce.com
}
}
}
}
For OAuth 2.0 Client Credentials Flow:
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": ["-y", "@tsmztech/mcp-server-salesforce"],
"env": {
"SALESFORCE_CONNECTION_TYPE": "OAuth_2.0_Client_Credentials",
"SALESFORCE_CLIENT_ID": "your_client_id",
"SALESFORCE_CLIENT_SECRET": "your_client_secret",
"SALESFORCE_INSTANCE_URL": "https://your-domain.my.salesforce.com" // Must be your exact Salesforce instance URL
}
}
}
}
Note: For OAuth,
SALESFORCE_INSTANCE_URL
must be your exact Salesforce instance URL (e.g.,https://your-domain.my.salesforce.com
). The token endpoint is<instance_url>/services/oauth2/token
.
Example Usage
Searching Objects
Find all objects related to Accounts
Show me objects that handle customer service
What objects are available for order management?
Getting Schema Information
What fields are available in the Account object?
Show me the picklist values for Case Status
Describe the relationship fields in Opportunity
Querying Records
Get all Accounts created this month
Show me high-priority Cases with their related Contacts
Find all Opportunities over $100k
Managing Custom Objects
Create a Customer Feedback object
Add a Rating field to the Feedback object
Update sharing settings for the Service Request object
Searching Across Objects
Search for 'cloud' in Accounts and Opportunities
Find mentions of 'network issue' in Cases and Knowledge Articles
Search for customer name across all relevant objects
Managing Apex Code
Show me all Apex classes with 'Controller' in the name
Get the full code for the AccountService class
Create a new Apex utility class for handling date operations
Update the LeadConverter class to add a new method
Managing Apex Triggers
List all triggers for the Account object
Show me the code for the ContactTrigger
Create a new trigger for the Opportunity object
Update the Case trigger to handle after delete events
Executing Anonymous Apex Code
Execute Apex code to calculate account metrics
Run a script to update related records
Execute a batch job to process large datasets
Managing Debug Logs
Enable debug logs for user@example.com
Retrieve recent logs for an admin user
Disable debug logs for a specific user
Configure log level to DEBUG for a user
Development
Building from source
git clone https://github.com/tsmztech/mcp-server-salesforce.git
cd mcp-server-salesforce
npm install
npm run build
Contributing
Contributions are welcome! Feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
Issues and Support
If you encounter issues or need support, please file an issue on the GitHub repository:
https://github.com/tsmztech/mcp-server-salesforce/issues