The Agentforce MCP Server enables interaction with the Salesforce Agentforce API, allowing you to authenticate, create sessions, and exchange messages with Salesforce agents through a Model Context Protocol interface.
The easiest way to get started is using the interactive setup script:
chmod +x setup.sh
./setup.sh
This script will check your Python version, install dependencies, guide you through credential setup, test your connection, and offer to start the server.
Install dependencies:
pip install -r requirements.txt
Create environment file:
cp .env.example .env
Edit the .env file with your Salesforce credentials:
SALESFORCE_ORG_ID="your_org_id_here"
SALESFORCE_AGENT_ID="your_agent_id_here"
SALESFORCE_CLIENT_ID="your_client_id_here"
SALESFORCE_CLIENT_SECRET="your_client_secret_here"
SALESFORCE_SERVER_URL="example.my.salesforce.com"
Make the server script executable:
chmod +x agentforce_mcp_server.py
Start the MCP server with:
python agentforce_mcp_server.py
https://localhost/oauth/callback
https://your-salesforce-instance.lightning.force.com/lightning/r/Agent__c/0XxXXXXXXXXXXXXX/view
DOMAIN-NAME.my.salesforce.com
Update your Claude Desktop configuration file to use this MCP server:
{
"mcpServers": {
"agentforce": {
"command": "python",
"args": [
"/path/to/your/agentforce_mcp_server.py"
]
}
}
}
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
The server provides the following tools:
Authenticates with the Agentforce API.
client_email
- Email for authenticationCreates a session with the configured agent.
client_email
- Email of the authenticated clientSends a message to the agent and returns the response.
client_email
- Email of the authenticated clientmessage
- Message to send to the agentGets the status of the current session.
client_email
- Email of the authenticated clientHandles the entire workflow in one call.
client_email
- Email for authenticationuser_query
- Message to send to the agentIf you encounter issues:
To test your setup, run:
python test_agentforce.py
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.