Salesforce Basic MCP Server
Salesforce Basic MCP Server
A simple Model Context Protocol (MCP) server that provides AI assistants with tools to query Salesforce data.
Features
✅ Get Account by ID
✅ Search Accounts by name
✅ Get recent Opportunities
✅ Schedule events in Google Calendar
Setup
1. Install Dependencies
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install. sh | sh
# Create and activate virtual environment
uv venv
source .venv/bin/activate # Mac/Linux
# OR
. venv\Scripts\activate # Windows
# Install dependencies
uv add "mcp[cli]" simple-salesforce python-dotenv2. Configure Salesforce Credentials
Create a .env file in the project root:
SF_USERNAME=your@salesforce.email.com
SF_PASSWORD=yourpassword
SF_SECURITY_TOKEN=yoursecuritytoken
SF_DOMAIN=login # or 'test' for sandboxHow to get your Security Token:
Log into Salesforce
Click your profile icon → Settings
On the left sidebar: Personal → Reset My Security Token
Check your email for the token
3. Run the Server
python main.py4. Test with MCP Inspector
npx @modelcontextprotocol/inspector python main.pyAvailable Tools
get_account
Get a Salesforce Account by ID.
Parameters:
account_id(string): The Salesforce Account ID
Example:
{
"account_id": "001XXXXXXXXXXXXXXX"
}search_accounts
Search for Accounts by name.
Parameters:
name(string): The account name to search for
Example:
{
"name": "Acme"
}get_recent_opportunities
Get the most recent Opportunities.
Parameters:
limit(integer, optional): Number to return (default: 5, max: 20)
Example:
{
"limit": 10
}Connect to Claude Desktop
Add to your Claude Desktop config file:
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config. json
{
"mcpServers": {
"salesforce-basic": {
"command": "python",
"args": ["/absolute/path/to/salesforce-mcp-basic/server.py"],
"env": {
"SF_USERNAME": "your@email.com",
"SF_PASSWORD": "yourpassword",
"SF_SECURITY_TOKEN": "yourtoken",
"SF_DOMAIN": "login"
}
}
}
}Security Notes
⚠️ Never commit .env to git!
The
.gitignorefile is configured to exclude itUse environment variables in production
Troubleshooting
"Authentication Failed"
Double-check username, password, and security token
Verify your IP is not blocked in Salesforce
For sandboxes, use
SF_DOMAIN=test
"Module not found"
Make sure virtual environment is activated
Run
uv add "mcp[cli]" simple-salesforce python-dotenv
Next Steps
Add more Salesforce objects (Contacts, Cases, etc.)
Implement create/update operations
Add error logging
Add data validation