sfdc_mcp
Provides tools for querying, searching, describing, and writing Salesforce data, including SOQL queries, SOSL searches, record creation/update, and opportunity history retrieval.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sfdc_mcpList all open opportunities with their amounts and close dates."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sfdc_mcp
A Salesforce data exporter and MCP server for Claude. Query, search, and write Salesforce data using your browser session cookie — no connected app or OAuth setup required.
Requirements
Python 3.10+
A Salesforce org you can log into in a browser
Related MCP server: Web Auth MCP Server
Installation
1. Clone the repo
git clone https://github.com/khensler/sfdc_mcp.git
cd sfdc_mcpTwo files do the work, and they must stay in the same directory:
sfdc_export.py— Salesforce client + CLIsfdc_mcp_server.py— MCP server for Claude
2. Create a virtual environment
python -m venv venv
# macOS / Linux
source venv/bin/activate
# Windows (PowerShell)
venv\Scripts\Activate.ps1
pip install -r requirements.txt3. Get your Salesforce session cookie
Log into Salesforce in Chrome or Firefox.
Open DevTools (
F12) → Application tab → Cookies → select your Salesforce domain.Find the cookie named
sidand copy its Value. There may be several cookies namedsid; you may need to try more than one before you find the one that works.Copy your instance URL from the address bar (e.g.
https://myorg.my.salesforce.com).
4. Save your credentials
python sfdc_export.py --setupThis writes your session to .sfdc_config.json in the repo directory. That file is gitignored — do not commit it. See .sfdc_config.example.json for the shape.
Alternatively, set environment variables, which take precedence over the file:
# macOS / Linux
export SFDC_SESSION_ID=your_sid_value
export SFDC_INSTANCE_URL=https://yourorg.my.salesforce.com
# Windows (PowerShell)
$env:SFDC_SESSION_ID = "your_sid_value"
$env:SFDC_INSTANCE_URL = "https://yourorg.my.salesforce.com"5. Test the connection
python sfdc_export.py --testMCP Server Setup (Claude Code)
Register the server with Claude Code, using the Python interpreter from your venv:
# macOS / Linux
claude mcp add sfdc "$PWD/venv/bin/python" "$PWD/sfdc_mcp_server.py"
# Windows (PowerShell)
claude mcp add sfdc "$PWD\venv\Scripts\python.exe" "$PWD\sfdc_mcp_server.py"Or add it manually to your Claude Code MCP config (.claude.json), substituting absolute paths:
{
"mcpServers": {
"sfdc": {
"command": "/path/to/sfdc_mcp/venv/bin/python",
"args": ["/path/to/sfdc_mcp/sfdc_mcp_server.py"]
}
}
}To pass credentials directly instead of using the saved config file, add an env block:
{
"mcpServers": {
"sfdc": {
"command": "/path/to/sfdc_mcp/venv/bin/python",
"args": ["/path/to/sfdc_mcp/sfdc_mcp_server.py"],
"env": {
"SFDC_SESSION_ID": "your_sid_value",
"SFDC_INSTANCE_URL": "https://yourorg.my.salesforce.com"
}
}
}
}Verify the server starts correctly — it should hang, waiting for stdio input, which means it's working:
python sfdc_mcp_server.pyPress Ctrl+C to exit.
MCP Tools Reference
Once connected, Claude has access to these tools:
Read
Tool | Description |
| Verify the session is valid |
| List all queryable SObjects; optional |
| Show all fields on an object |
| Run a SOQL query, return results inline as CSV or JSON |
| Run a SOQL query, write full results to a file |
| Run a SOSL full-text search across multiple objects |
| Run a SOSL search, write results to a file |
| Show who changed which Opportunity fields and when |
Write
Tool | Description |
| Create a new record on any SObject |
| Update one or more fields on an existing record by Id |
CLI Reference
sfdc_export.py can also be used directly from the terminal.
# Test connection
python sfdc_export.py --test
# List queryable objects
python sfdc_export.py --objects
# Show fields on an object
python sfdc_export.py --describe Opportunity
# Run a SOQL query (stdout, CSV)
python sfdc_export.py --query "SELECT Id, Name, StageName, Amount FROM Opportunity WHERE IsClosed = false"
# Run a SOQL query and save to file
python sfdc_export.py --query "SELECT Id, Name FROM Account" --output accounts.csv
# Run a SOQL query and export as JSON
python sfdc_export.py --query "SELECT Id, Name FROM Contact" --format json --output contacts.json
# Run a SOSL search
python sfdc_export.py --search "FIND {Jane Smith} IN NAME FIELDS RETURNING Contact(Id, Name, Email)"Session Expiry
Salesforce session cookies expire after your org's session timeout, typically 2–8 hours of inactivity. When you see a 401 or INVALID_SESSION_ID error, grab a fresh sid cookie from your browser and re-run:
python sfdc_export.py --setupSecurity Notes
.sfdc_config.jsonholds a live Salesforce session token. It is gitignored; keep it that way. On POSIX systems it is written with0600permissions. On Windows, file mode bits are not enforced, so the file is only as protected as your user profile directory.A
sidcookie carries your full user permissions. Anyone who obtains it can read and write everything you can, until the session expires. Treat it like a password, and never paste it into an issue, log, or commit.Exported data is your org's data. Query results routinely contain customer names, contact details, and commercial terms.
.gitignoreexcludes*.csvand*.jsonby default for exactly this reason — review anything you add before committing.sfdc_delete_recordis intentionally not exposed as an MCP tool. The underlyingSalesforceClient.delete_recordmethod still exists for CLI or library use.SOQL and SOSL strings are passed to Salesforce as given. Do not interpolate untrusted input into them.
License
MIT — see LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Run SOQL queries to explore and retrieve Salesforce data. Access accounts, contacts, opportunities…
Run SOQL queries to explore and retrieve Salesforce data. Inspect records, fields, and relationshi…
Run SOQL queries against your Salesforce org to explore and retrieve data. Quickly iterate on filt…
Run SOQL queries against your Salesforce org to retrieve records and insights. Explore objects, fi…
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables authenticated interaction with Salesforce through OAuth Bearer token forwarding. Allows users to make API calls to Salesforce instances while maintaining secure session-based authentication throughout the MCP lifecycle.13 npm-
- AlicenseNot gradedqualityDmaintenanceEnables executing HTTP requests with automatic browser-based authentication, supporting OAuth, form login, and cookie/session management.1MIT
- AlicenseAqualityAmaintenanceEnables SOQL queries, SOSL search, and record CRUD operations on a single Salesforce org via MCP, with optional read-only mode.962 npmMIT
- FlicenseAqualityDmaintenanceEnables AI assistants to interact with Salesforce data by listing objects, describing fields, and executing SOQL queries.4-