Salesforce Fastmcp
FastMCP server for Salesforce integration - 17 tools for CRUD, analytics, and business intelligence
Ask AI about Salesforce Fastmcp
Powered by Claude Β· Grounded in docs
I know everything about Salesforce Fastmcp. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Salesforce FastMCP Connector
A FastMCP server providing 23 tools for interacting with Salesforce. This is a Python port of the Node.js Salesforce MCP connector, designed for deployment to FastMCP Cloud.
Features
Basic CRUD (8 tools)
salesforce_query- Execute SOQL queriessalesforce_sobjects- List available objectssalesforce_recent- Fetch recent recordssalesforce_search- Execute SOSL searchessalesforce_describe- Get object metadatasalesforce_create- Create recordssalesforce_update- Update recordssalesforce_delete- Delete records
Navigation & Relationships (3 tools)
salesforce_relationships- Get related recordssalesforce_lookup- Search records by fieldsalesforce_hierarchy- Navigate parent/child relationships
Analytics (3 tools)
salesforce_aggregate- Statistical analysis (COUNT, SUM, AVG, etc.)salesforce_reports- Access Salesforce reportssalesforce_trend_analysis- Time-based trend analysis
Business Intelligence (4 tools)
salesforce_pipeline- Sales pipeline analysissalesforce_case_insights- Support case metricssalesforce_lead_funnel- Lead conversion funnelsalesforce_opportunities_by_partner- Find opportunities by partner name (handles lookup syntax automatically)
Setup
Prerequisites
- Python 3.10+
- A Salesforce org with API access
- Salesforce Session ID (SID) or Access Token
Installation
-
Clone or download this directory
-
Create a virtual environment:
cd salesforce-fastmcp python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Configure environment variables:
cp .env.example .env # Edit .env with your Salesforce credentials
Getting Salesforce Credentials
Option 1: Session ID from Browser
- Log into Salesforce in your browser
- Open Developer Tools > Application > Cookies
- Find the
sidcookie value - Your base URL is:
https://your-instance.my.salesforce.com/services/data/v59.0
Option 2: Salesforce CLI
sf org display --target-org your-org
# Use the "Access Token" and "Instance URL" values
Option 3: OAuth 2.0 (Recommended for Production)
Use a Salesforce Connected App with OAuth 2.0 flow to obtain refresh tokens for automatic token renewal.
Running the Server
Local stdio Mode (for Claude Desktop)
python server.py
Local HTTP Mode (for testing)
fastmcp run server.py:mcp --transport http --port 8000
Claude Desktop Configuration
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"salesforce": {
"command": "python",
"args": ["/path/to/salesforce-fastmcp/server.py"],
"env": {
"SALESFORCE_BASE_URL": "https://your-instance.my.salesforce.com/services/data/v59.0",
"SALESFORCE_SID": "your-session-id"
}
}
}
}
Deploying to FastMCP Cloud
-
Push this project to a GitHub repository
-
Visit fastmcp.cloud and sign in
-
Connect your GitHub repository
-
Set environment variables in the FastMCP Cloud dashboard:
SALESFORCE_BASE_URLSALESFORCE_SID(orSALESFORCE_ACCESS_TOKEN)
-
Deploy and get your cloud URL
Using the Cloud-Hosted Server
Once deployed, you can connect to your server via the cloud URL provided by FastMCP.
Example Usage
Query Accounts
Use the salesforce_query tool with:
q: "SELECT Id, Name, Industry FROM Account LIMIT 10"
Search for Contacts
Use the salesforce_lookup tool with:
object_name: "Contact"
search_term: "John"
search_fields: ["Name", "Email"]
Get Pipeline Analysis
Use the salesforce_pipeline tool with:
timeframe: "THIS_QUARTER"
include_forecasting: true
Aggregate Opportunity Data
Use the salesforce_aggregate tool with:
object_name: "Opportunity"
aggregates: [{"function": "SUM", "field": "Amount", "alias": "TotalValue"}]
group_by: "StageName"
Find Opportunities by Partner
Use the salesforce_opportunities_by_partner tool with:
partner_name: "Inetum - Spain (Partner)"
is_closed: false
start_date: "2026-01-01"
Working with Lookup Fields (IMPORTANT)
Salesforce lookup fields (like Partner__c, Account__c) store record IDs, not names. When querying by name, you must use the relationship syntax with __r:
β WRONG - This will fail with "invalid ID field" error:
SELECT Id, Name FROM Opportunity WHERE Partner__c = 'Inetum - Spain (Partner)'
β CORRECT - Use the relationship syntax:
SELECT Id, Name FROM Opportunity WHERE Partner__r.Name = 'Inetum - Spain (Partner)'
Common Lookup Fields in Opportunity:
Partner__cβ usePartner__r.Namefor partner nameAccount__cβ useAccount.NameorAccount__r.NameOwner__cβ useOwner.Name
Helper Tool: salesforce_opportunities_by_partner
Instead of manually constructing SOQL queries with relationship syntax, use the dedicated helper tool:
Use the salesforce_opportunities_by_partner tool with:
partner_name: "Inetum - Spain (Partner)"
is_closed: false
stage_name: "Negotiation"
min_amount: 50000
start_date: "2026-01-01"
end_date: "2026-12-31"
limit: 50
This tool automatically handles the lookup relationship syntax and provides additional filtering options.
Authentication Notes
- Session IDs expire after ~24 hours of inactivity
- For production use, consider implementing OAuth 2.0 with refresh tokens
- Never commit your
.envfile to version control
Troubleshooting
"INVALID_SESSION_ID" Error
Your session has expired. Obtain a new session ID and update your .env file.
"Missing required environment variables"
Ensure both SALESFORCE_BASE_URL and SALESFORCE_SID (or SALESFORCE_ACCESS_TOKEN) are set.
API Version Errors
Update the API version in your base URL (e.g., v59.0 to v60.0) to match your Salesforce org.
License
MIT
