Salesforce Integration
This skill enables you to interact with Salesforce using natural language. You can query records, manage objects and fields, execute SOQL queries, create Apex code, manage debug logs, and perform data operations across your Salesforce org.
What This Skill Does
**Search and describe** Salesforce objects and their schemas**Query records** with SOQL, including relationships and aggregate queries**Manage data** with insert, update, delete, and upsert operations**Create and modify** custom objects and fields**Manage field permissions** (Field Level Security)**Search across objects** using SOSL**Read, create, and update** Apex classes and triggers**Execute anonymous Apex** code for complex operations**Manage debug logs** for Salesforce usersSetup Instructions
Authentication Methods
Choose one of three authentication methods:
**Option 1: Salesforce CLI (Recommended for development)**
1. Install Salesforce CLI (`sf`)
2. Authenticate your org: `sf org login web`
3. Verify access: `sf org display --json`
4. Set environment variable: `SALESFORCE_CONNECTION_TYPE=Salesforce_CLI`
**Option 2: Username/Password**
1. Get your Salesforce username and password
2. Reset your security token from Salesforce Settings
3. Set environment variables:
- `SALESFORCE_CONNECTION_TYPE=User_Password`
- `SALESFORCE_USERNAME=your_username`
- `SALESFORCE_PASSWORD=your_password`
- `SALESFORCE_TOKEN=your_security_token`
- `SALESFORCE_INSTANCE_URL=https://login.salesforce.com` (optional)
**Option 3: OAuth 2.0 Client Credentials**
1. Create a Connected App in Salesforce
2. Enable OAuth settings with "Client Credentials Flow"
3. Set scopes (typically "api")
4. Save Client ID and Client Secret
5. Set environment variables:
- `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` (required)
Installation
The MCP server package is: `@tsmztech/mcp-server-salesforce`
Available Operations
1. Object Discovery
**Search for objects:**
Use `salesforce_search_objects` to find objects by partial nameExample: "Find all objects related to Account"Example: "Show me objects for customer service"**Describe object schema:**
Use `salesforce_describe_object` to get field definitions, relationships, and picklist valuesExample: "What fields are available in the Account object?"Example: "Show me picklist values for Case Status"2. Data Queries
**Standard queries:**
Use `salesforce_query_records` for SELECT queries with relationshipsSupports parent-to-child and child-to-parent relationshipsExample: "Get all Accounts created this month"Example: "Show me high-priority Cases with their related Contacts"**Aggregate queries:**
Use `salesforce_aggregate_query` for GROUP BY and aggregate functionsSupports: COUNT, COUNT_DISTINCT, SUM, AVG, MIN, MAXExample: "Count opportunities by stage"Example: "Calculate average deal size by sales rep"3. Data Manipulation
**DML operations:**
Use `salesforce_dml_records` for insert, update, delete, and upsertSupports bulk operationsExample: "Update status of multiple accounts"Example: "Delete closed opportunities from last year"4. Object and Field Management
**Create/modify custom objects:**
Use `salesforce_manage_object` to create or update custom objectsConfigure sharing settingsExample: "Create a Customer Feedback object"**Manage fields:**
Use `salesforce_manage_field` to add or modify fieldsAutomatically grants Field Level Security to System AdministratorUse `grantAccessTo` parameter for specific profilesExample: "Add a Rating picklist field to Account"Example: "Create a Revenue currency field and grant access to Sales User profile"**Manage field permissions:**
Use `salesforce_manage_field_permissions` to grant/revoke field accessView current permissions for specific fieldsExample: "Grant System Administrator access to Custom_Field__c on Account"Example: "Give read-only access to Rating__c field for Sales User profile"5. Cross-Object Search
**SOSL search:**
Use `salesforce_search_all` to search across multiple objectsReturns field snippetsExample: "Search for 'cloud' in Accounts and Opportunities"Example: "Find mentions of 'network issue' in Cases"6. Apex Code Management
**Read Apex classes:**
Use `salesforce_read_apex` to view class source codeSupports wildcard patterns (* and ?)Example: "Show me the AccountController class"Example: "Find all classes matching Account*Cont*"**Write Apex classes:**
Use `salesforce_write_apex` to create or update classesSpecify API versionsExample: "Create a new Apex class for handling account operations"**Read Apex triggers:**
Use `salesforce_read_apex_trigger` to view trigger source codeSupports wildcard patternsExample: "Show me the AccountTrigger"Example: "Find all triggers for Contact object"**Write Apex triggers:**
Use `salesforce_write_apex_trigger` to create or update triggersSpecify object and event operationsExample: "Create a new trigger for the Opportunity object"7. Execute Anonymous Apex
**Run Apex code:**
Use `salesforce_execute_anonymous` to execute code without creating a permanent classView debug logs and execution resultsExample: "Execute Apex code to calculate account metrics"Example: "Run a script to update related records"8. Debug Log Management
**Manage debug logs:**
Use `salesforce_manage_debug_logs` to enable/disable loggingRetrieve and view debug logsConfigure log levels: NONE, ERROR, WARN, INFO, DEBUG, FINE, FINER, FINESTExample: "Enable debug logs for [email protected]"Example: "Retrieve recent logs for an admin user"Best Practices
1. **Start with object discovery** before querying unfamiliar objects
2. **Use aggregate queries** for GROUP BY operations instead of standard queries
3. **Check field permissions** after creating custom fields
4. **Test Apex code** with execute_anonymous before creating permanent classes
5. **Enable debug logs** when troubleshooting complex operations
6. **Use SOSL search** when you need to search across multiple object types
7. **Leverage relationships** in queries to minimize round trips
Constraints
Respects Salesforce API limits and governor limitsField Level Security automatically granted to System Administrator by defaultOAuth 2.0 requires exact instance URL (e.g., `https://your-domain.my.salesforce.com`)Aggregate queries require using `salesforce_aggregate_query` (not `salesforce_query_records`)Salesforce CLI authentication requires `sf` CLI installed and org authenticatedExample Usage Patterns
**Data exploration:**
```
"Find all objects related to Accounts"
→ "What fields are available in the Account object?"
→ "Get all Accounts created this month with their Contacts"
```
**Custom object creation:**
```
"Create a Customer Feedback object"
→ "Add a Rating picklist field to Feedback"
→ "Grant Sales User profile access to the Rating field"
```
**Analytics and reporting:**
```
"Count opportunities by stage"
→ "Calculate average deal size by sales rep and quarter"
→ "Find accounts with more than 10 opportunities"
```
**Code management:**
```
"Show me all Apex classes with 'Controller' in the name"
→ "Get the full code for AccountController"
→ "Create a new utility class for date operations"
```