This MCP server provides tools to interact with the Salesforce Agentforce API, allowing authentication, session creation, and message exchange with Salesforce agents.
This MCP server provides tools to interact with the Salesforce Agentforce API. It allows authentication, session creation, and message exchange with Agentforce agents.
If you've just cloned this repository, you can use the interactive setup script to quickly configure and run the server:
chmod +x setup.sh ./setup.sh
The setup script will:
Alternatively, you can follow these manual steps:
Install dependencies:
pip install -r requirements.txt
Set up your environment variables:
cp .env.example .env
Collect your Salesforce credentials:
Edit your .env file with the collected credentials:
SALESFORCE_ORG_ID="00D5f000000J2PKEA0"
SALESFORCE_AGENT_ID="0XxHn000000x9F1KAI"
SALESFORCE_CLIENT_ID="3MVG9OGq41FnYVsFgnaG0AzJDWnoy37Bb18e0R.GgDJu2qB9sqppVl7ehWmJhGvPSLrrA0cBNhDJdsbZXnv52"
SALESFORCE_CLIENT_SECRET="210117AC36E9E4C8AFCA02FF062B8A677BACBFFB71D2BB1162D60D316382FADE"
SALESFORCE_SERVER_URL="example.my.salesforce.com"
(Note: These are fictional example values. Replace with your actual credentials.)
Make the server script executable:
chmod +x agentforce_mcp_server.py
Run the server:
python agentforce_mcp_server.py
For detailed instructions on finding your Salesforce credentials, see the Setting Up Salesforce section below.
Ensure you have Python 3.10 or higher installed.
Install the required dependencies:
pip install -r requirements.txt
Make the server script executable:
chmod +x agentforce_mcp_server.py
The server uses environment variables for configuration. These are loaded from the .env
file.
Copy the example environment file to create your own:
cp .env.example .env
Edit the .env
file and fill in your values:
SALESFORCE_ORG_ID="your_org_id_here"
SALESFORCE_AGENT_ID="your_agent_id_here" # The 18-character Agent ID you found in Salesforce
SALESFORCE_CLIENT_ID="your_client_id_here" # The Consumer Key from your Connected App
SALESFORCE_CLIENT_SECRET="your_client_secret_here" # The Consumer Secret from your Connected App
SALESFORCE_SERVER_URL="your_server_url_here" # Your My Domain URL (e.g., example.my.salesforce.com)
To use the Agentforce API, you need to:
For detailed instructions on these steps, see the Setting Up Salesforce section below.
Run the server using:
python agentforce_mcp_server.py
The MCP server exposes the following tools:
authenticate
Authenticates with the Agentforce API using a client email.
Parameters:
client_email
: Email of the client for authenticationcreate_agent_session
Creates a session with the configured Agentforce agent.
Parameters:
client_email
: Email of the authenticated clientsend_message_to_agent
Sends a message to the Agentforce agent and returns the response.
Parameters:
client_email
: Email of the authenticated clientmessage
: Message to send to the agentget_session_status
Gets the status of the current session, including authentication status, session ID, and sequence ID.
Parameters:
client_email
: Email of the authenticated clientcomplete_agentforce_conversation
Convenience method that handles the complete flow - authentication, session creation, and message sending.
Parameters:
client_email
: Email of the client for authenticationuser_query
: Message to send to the agentTo use this server with Claude for Desktop, update your claude_desktop_config.json
file:
{ "mcpServers": { "agentforce": { "command": "python", "args": [ "/path/to/your/agentforce_mcp_server.py" ] } } }
Replace the path with the absolute path to the server script on your machine.
~/Library/Application Support/Claude/claude_desktop_config.json
/Users/yourusername/Projects/agentforce-mcp-server/agentforce_mcp_server.py
%APPDATA%\Claude\claude_desktop_config.json
C:\Users\yourusername\Projects\agentforce-mcp-server\agentforce_mcp_server.py
To use the Agentforce API, you need to create a Connected App in your Salesforce org:
https://localhost/oauth/callback
(this is not used but required)To find your Agentforce Agent ID:
https://your-salesforce-instance.lightning.force.com/lightning/r/Agent__c/0XxXXXXXXXXXXXXX/view
0XxXXXXXXXXXXXXX
) in the URLTo find your Salesforce My Domain URL:
DOMAIN-NAME.my.salesforce.com
To find your Salesforce Org ID:
If you encounter issues:
You can test your setup using the included test script:
python test_agentforce.py
This will attempt to authenticate, create a session, and exchange messages with your Agentforce agent.
This repository includes a helpful script that simplifies the process of pushing your changes to GitHub:
chmod +x github_push.sh ./github_push.sh
The github_push.sh
script will:
.env
won't be pushed (they're in .gitignore
)This makes it easy to share your customizations or contribute back to the project while ensuring that sensitive information stays secure.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!