This MCP server provides Salesforce CLI functionality to LLM tools like Claude Desktop by wrapping the sf
command-line tool and exposing its commands as MCP tools and resources. This allows AI agents to execute Salesforce CLI commands, view help information, and leverage Salesforce capabilities within AI workflows.
sf
) installed and configured# Clone the repository
git clone <repository-url>
cd sfMcp
# Install dependencies
npm install
# Basic usage
npm start
# With project roots
npm start /path/to/project1 /path/to/project2
# Using the convenience script
npm run with-roots /path/to/project1 /path/to/project2
# As an npx package with roots
npx -y codefriar/sf-mcp /path/to/project1 /path/to/project2
Add this configuration to your .claude.json
file:
{
"tools": {
"salesforce": {
"command": "/path/to/node",
"args": [
"/path/to/sf-mcp/build/index.js",
"/path/to/project1",
"/path/to/project2"
]
}
}
}
Or using the npm package directly:
{
"tools": {
"salesforce": {
"command": "/path/to/npx",
"args": [
"-y",
"codefriar/sf-mcp",
"/path/to/project1",
"/path/to/project2"
]
}
}
}
sf_version
- Get the Salesforce CLI version informationsf_help
- Get help information for Salesforce CLI commandssf_cache_clear
- Clear the command discovery cachesf_cache_refresh
- Refresh the command discovery cacheFor commands that require a Salesforce project context, you must specify the project directory.
Method 1: Via Command Line Arguments
npm start /path/to/project1 /path/to/project2
Roots will be automatically named root1
, root2
, etc., with the first one set as default.
Method 2: Using MCP Tools
# Set project directory with a name
sf_set_project_directory --directory=/path/to/your/sfdx/project --name=project1 --isDefault=true
# List all configured roots
sf_list_roots
Method 3: Claude Desktop Configuration
Configure project roots in .claude.json
as shown in the configuration examples above.
Execute commands in specific project roots:
# Using resource URI
sf://roots/project1/commands/project deploy start --sourcedir=force-app
# Using rootName parameter
sf_project_deploy_start --sourcedir=force-app --rootName=project1
sf_org_list
- List Salesforce orgs
json
, verbose
sf_auth_list_orgs
- List authenticated Salesforce orgs
json
, verbose
sf_org_display
- Display details about an org
targetusername
, json
sf_org_open
- Open an org in the browser
targetusername
, path
, urlonly
sf_apex_run
- Run anonymous Apex code
targetusername
, file
, apexcode
, json
sf_apex_test_run
- Run Apex tests
targetusername
, testnames
, suitenames
, classnames
, json
sf_data_query
- Execute a SOQL query
targetusername
, query
, json
sf_schema_list_objects
- List sObjects in the org
targetusername
, json
sf_schema_describe
- Describe a Salesforce object
targetusername
, sobject
, json
sf_project_deploy_start
- Deploy the source to an org
targetusername
, sourcedir
, json
, wait
The server discovers all available Salesforce CLI commands and registers them as tools with format: sf_<topic>_<command>
. For example:
sf_apex_run
- Run anonymous Apex codesf_data_query
- Execute a SOQL queryFor nested topic commands, the tool name includes the full path with underscores:
sf_apex_log_get
- Get apex logssf_org_login_web
- Login to an org using web flowsf://help
- Main CLI documentationsf://topics/{topic}/help
- Topic help documentationsf://commands/{command}/help
- Command help documentationsf://topics/{topic}/commands/{command}/help
- Topic-command help documentationsf://version
- Version informationsf://roots
- List all configured project rootssf://roots/{root}/commands/{command}
- Execute a command in a specific project rootIf you encounter issues with missing commands or cache problems:
rm ~/.sf-mcp/command-cache.json
For missing commands after installing new SF CLI plugins:
sf_cache_refresh
toolTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "salesforce" '{"command":"npx","args":["-y","codefriar/sf-mcp"]}'
See the official Claude Code MCP documentation for more details.
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 > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": [
"-y",
"codefriar/sf-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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": [
"-y",
"codefriar/sf-mcp"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect