MCP Salesforce Revenue Cloud
Overview
This is a Model Context Protocol (MCP) server that provides AI assistants like Claude with direct access to Salesforce Revenue Cloud data and operations. Built with FastMCP, it exposes Salesforce functionality through standardized MCP tools that can be invoked by any MCP-compatible client.
Features
- MCP Server: Standards-compliant Model Context Protocol server using FastMCP
- Salesforce Revenue Cloud Integration: Direct access to Products, Price Books, Quotes, and Orders
- Custom SOQL Queries: Execute arbitrary SOQL queries through the MCP protocol
- AI Assistant Ready: Works seamlessly with Claude Desktop and other MCP clients
- Secure Authentication: Uses Salesforce Session ID for authentication
Available MCP Tools
get_products(product_family)- Fetch products, optionally filtered by family/categoryget_price_books()- Retrieve price books from Salesforceget_quotes(limit)- Get quotes with configurable result limitget_orders(limit)- Fetch orders with configurable result limitquery_salesforce(soql)- Execute custom SOQL queries
Prerequisites
Before you begin, ensure you have the following:
- Python 3.8 or higher
- Access to a Salesforce instance with API enabled
- A valid Salesforce Session ID (see Configuration section for how to obtain)
- Claude Desktop or another MCP-compatible client (optional, for testing)
pipfor installing Python packages
Setup and Installation
-
Clone the repository:
git clone https://github.com/Bittersea1803/mcp_salesforce_revenue_cloud.git cd mcp_salesforce_revenue_cloud -
Create and activate a virtual environment:
python -m venv .venv # On Windows .\.venv\Scripts\activate # On macOS/Linux source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt -
Set up environment variables: Copy the example environment file and configure your credentials:
cp .env.example .env # Edit .env and add your Salesforce Session ID and Domain URL -
Test the installation:
# Test MCP server structure (no Salesforce connection required) python test_mcp_server.py # Test Salesforce authentication (requires valid credentials) python salesforce_auth.py
Quick Start
Once you have configured your .env file with valid Salesforce credentials:
# Run the MCP server
python server.py
The server will start and listen for MCP protocol connections. To use it with Claude Desktop, see the "Using with Claude Desktop" section below.
Configuration
Environment Variables
Create a .env file in the project root with the following content:
# .env - Environment variables
# Salesforce Session ID (see below for how to obtain)
SALESFORCE_SESSION_ID="your_session_id_here"
# Salesforce Domain URL
SALESFORCE_DOMAIN_URL="https://your-instance.my.salesforce.com"
How to obtain a Salesforce Session ID:
- Log into your Salesforce org in a web browser
- Open Developer Console (Setup → Developer Console)
- Execute this Anonymous Apex code:
System.debug('Session ID: ' + UserInfo.getSessionId()); - Copy the Session ID from the debug log
- Paste it into your
.envfile
Important Notes:
- Session IDs expire after a period of inactivity (typically 2-8 hours depending on your org settings)
- For
SALESFORCE_DOMAIN_URL, use your actual Salesforce instance URL (e.g.,https://mycompany.my.salesforce.com) - Ensure the
.envfile is added to your.gitignoreto prevent committing credentials
Usage
Running the MCP Server
To run the MCP server directly:
python server.py
Or using the FastMCP CLI:
fastmcp run server.py
The server will start and listen for MCP protocol connections.
Using with Claude Desktop
To use this MCP server with Claude Desktop, add the following configuration to your Claude Desktop config file:
Location of config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Configuration:
{
"mcpServers": {
"salesforce-revenue-cloud": {
"command": "python",
"args": [
"/absolute/path/to/mcp_salesforce_revenue_cloud/server.py"
],
"env": {
"SALESFORCE_SESSION_ID": "your_session_id_here",
"SALESFORCE_DOMAIN_URL": "https://your-instance.my.salesforce.com"
}
}
}
}
Replace:
/absolute/path/to/mcp_salesforce_revenue_cloud/server.pywith the actual path to server.pyyour_session_id_herewith your Salesforce Session IDhttps://your-instance.my.salesforce.comwith your Salesforce instance URL
After saving the config, restart Claude Desktop. The Salesforce Revenue Cloud tools will be available for Claude to use.
Example Queries
Once connected, you can ask Claude:
- "Show me all products in Salesforce"
- "Get products in the Solar Panels family"
- "What price books are available?"
- "Show me the latest quotes"
- "Query Salesforce for SELECT Id, Name FROM Account LIMIT 5"
Project Structure
mcp_salesforce_revenue_cloud/
├── server.py # Main MCP server (FastMCP)
├── salesforce_auth.py # Salesforce authentication module
├── requirements.txt # Python package dependencies
├── .env # Environment variables (DO NOT COMMIT)
├── .gitignore # Specifies intentionally untracked files
├── README.md # This file
│
# Legacy Flask application (for reference)
├── app.py # Old Flask web application
├── handlers.py # Old handler functions
├── intents_config.yaml # Old intent definitions
└── templates/ # Old HTML templates
Development
Testing Salesforce Connection
You can test the Salesforce authentication separately:
python salesforce_auth.py
This will verify your Session ID and display your API usage.
Adding New Tools
To add a new MCP tool, add a function decorated with @mcp.tool() in server.py:
@mcp.tool()
def my_new_tool(param: str) -> str:
"""
Description of what this tool does.
Args:
param: Description of the parameter
Returns:
JSON string with results
"""
client = get_sf_client()
# Your implementation here
return json.dumps({"status": "success", "data": result})
Contributing
Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/your-feature-name). - Open a Pull Request.
Please ensure your code adheres to any existing coding standards and includes tests where appropriate.
License
This project is licensed under the [e.g., MIT License, Apache 2.0 License, etc.]. See the LICENSE file for details (if you add one).
This README is a template. Please update it with specific details about your project's functionality, setup, and usage as it evolves.
