Salesforce MCP Server
Enables AI assistants to interact with Salesforce data by listing objects, describing fields, and executing SOQL queries.
README
Salesforce MCP Server
An MCP (Model Context Protocol) server implementation for Salesforce integration, enabling AI assistants to interact with Salesforce data through standardized tools.
Features
This MCP server provides three powerful tools for Salesforce integration:
- list_objects: List all available Salesforce objects with their metadata
- describe_object: Get detailed field information for a specific Salesforce object
- execute_soql_query: Execute SOQL queries against your Salesforce instance
Prerequisites
- Python 3.13+
- A Salesforce account with API access
- Salesforce security token (see setup instructions below)
Installation
- Clone this repository:
git clone <repository-url>
cd mcp-salesforce
- Create and activate a virtual environment using uv:
uv venv
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
- Install dependencies:
uv pip install -e .
Configuration
- Copy the example environment file:
cp .env.example .env
- Edit
.envand add your Salesforce credentials:
SALESFORCE_USERNAME=your_username@example.com
SALESFORCE_PASSWORD=your_password
SALESFORCE_SECURITY_TOKEN=your_security_token
Getting Your Salesforce Security Token
- Log in to Salesforce
- Go to Setup > Personal Setup > My Personal Information > Reset My Security Token
- Click Reset Security Token
- Check your email for the new security token
Usage
Running the Server
Start the MCP server using one of the following methods:
# Method 1: Run directly with Python
python main.py
# Method 2: Use the installed command
mcp-salesforce
# Method 3: Run with uv (recommended)
uv run mcp-salesforce
Testing with MCP Inspector
The MCP Inspector is a powerful tool for testing and debugging your MCP server. It provides an interactive interface to explore available tools and test them with different parameters.
Method 1: Using uv run with mcp-salesforce command (recommended)
npx @modelcontextprotocol/inspector uv run mcp-salesforce
Method 2: Using uv run with Python directly
npx @modelcontextprotocol/inspector uv run python main.py
This will:
- Start the MCP Inspector web interface
- Launch your Salesforce MCP server
- Open a browser window where you can:
- View all available tools
- Test each tool with custom parameters
- See the JSON responses
- Debug any issues
Note: Make sure your .env file is configured with valid Salesforce credentials before running the inspector.
Available Tools
1. list_objects
Lists all available Salesforce objects in your org.
Returns:
- Dictionary containing:
objects: Array of object metadata, each with:name: API name of the objectlabel: Display labelcustom: Whether it's a custom objectqueryable: Whether it can be queried via SOQLsearchable: Whether it's searchablecreateable: Whether new records can be createdupdateable: Whether records can be updateddeletable: Whether records can be deleted
2. describe_object
Get all fields for a specific Salesforce object.
Parameters:
object_name(string): The API name of the Salesforce object (e.g., 'Account', 'Contact', 'CustomObject__c')
Returns:
- Dictionary containing:
name: Object API namefields: Array of field definitions with:name: Field API namelabel: Field display labeltype: Data type (string, number, date, picklist, etc.)length,precision,scale: Size constraintsrequired: Whether the field is requiredunique: Whether values must be uniquecreateable,updateable: Field permissionscalculated: Whether it's a formula fielddefaultValue: Default value for the fieldpicklistValues: Available values (for picklist fields)referenceTo: Referenced object (for lookup/master-detail fields)
3. execute_soql_query
Execute SOQL (Salesforce Object Query Language) queries.
Parameters:
query(string): The SOQL query string (e.g., 'SELECT Id, Name FROM Account LIMIT 10')
Returns:
- Dictionary containing:
query: The executed SOQL query stringrows: Array of records with queried fieldsrow_count: Total number of records returnedcolumns: Array of column names in the result set
Important SOQL Rules:
- CANNOT use SELECT * - You MUST specify column names explicitly
- Aggregate queries CANNOT use LIMIT - Queries using COUNT, SUM, AVG, MIN, MAX cannot have LIMIT clause
Example Queries:
-- Get first 10 accounts
SELECT Id, Name, Industry FROM Account LIMIT 10
-- Get contacts with filters
SELECT Id, FirstName, LastName, Email FROM Contact WHERE Email != null LIMIT 20
-- Join query (using relationship)
SELECT Id, Name, Owner.Name FROM Account WHERE CreatedDate = TODAY
Development
Project Structure
mcp-salesforce/
├── main.py # Main MCP server implementation
├── pyproject.toml # Project configuration and dependencies
├── .env.example # Example environment variables
├── .env # Your actual credentials (git-ignored)
└── README.md # This file
Dependencies
- fastmcp: Framework for building MCP servers
- simple-salesforce: Python client for Salesforce REST API
- python-dotenv: Load environment variables from .env files
Adding to Claude Desktop
To use this MCP server with Claude Desktop, add the following to your Claude Desktop configuration:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"salesforce": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-salesforce",
"run",
"mcp-salesforce"
]
}
}
}
Replace /absolute/path/to/mcp-salesforce with the actual path to your project directory.
Alternative configuration using Python directly:
{
"mcpServers": {
"salesforce": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-salesforce",
"run",
"python",
"main.py"
]
}
}
}
Error Handling
The server includes comprehensive error handling:
- Missing Credentials: Clear error message if environment variables are not set
- Authentication Errors: Salesforce API authentication failures are reported
- Invalid Queries: SOQL syntax errors are returned with helpful messages
- API Limits: Respects Salesforce API rate limits
Security Notes
- Never commit your
.envfile to version control - Keep your Salesforce security token secure
- Consider using OAuth 2.0 for production deployments
- Regularly rotate your security token
License
[Add your license here]
Contributing
[Add contribution guidelines here]
Support
For issues and questions:
- Check the simple-salesforce documentation
- Review Salesforce API documentation
- Open an issue in this repository
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。