home / mcp / salesforce mcp server
Provides Salesforce CLI capabilities as MCP tools and resources for AI workflows.
Configuration
View docs{
"mcpServers": {
"codefriar-sf-mcp": {
"command": "npx",
"args": [
"-y",
"codefriar/sf-mcp",
"/path/to/project1",
"/path/to/project2"
]
}
}
}You run a Salesforce CLI MCP Server to expose Salesforce CLI functionality as MCP tools and resources for AI agents. This enables you to view help topics, execute Salesforce CLI commands, and integrate Salesforce capabilities into your workflows with minimal setup.
Start by launching the MCP server from your project workspace. You can run it with default project roots or specify one or more root directories to provide project context for commands that require a sfdx project.
Then interact with the server using an MCP client. The server exposes Salesforce CLI commands as MCP tools such as sf_version, sf_help, and deployment-related commands. You can call a tool to execute the corresponding Salesforce CLI command and receive structured results.
Prerequisites: you need Node.js 18 or newer and npm installed. You also need Salesforce CLI (sf) installed and configured with your Salesforce org credentials.
Install locally by cloning the project, installing dependencies, and starting the server.
git clone <repository-url>
cd sfMcp
npm install
npm startProject roots let you run commands against multiple Salesforce project directories. You can specify roots on startup or configure them via dedicated tools. When multiple roots exist, the first is treated as default unless you specify another root.
If you install new Salesforce CLI plugins, you may need to refresh the command cache and restart the MCP server to ensure all commands are discoverable.
You can also run the server via a convenient npm script or with npx for quick ad-hoc use in your environment.
npm start
# Start with explicit roots
npm start /path/to/project1 /path/to/project2
# Or use the convenience script if available
npm run with-roots /path/to/project1 /path/to/project2
# Or run via npx
npx -y codefriar/sf-mcp /path/to/project1 /path/to/project2Configure the MCP server as a tool in Claude Desktop or your MCP client by pointing to the command runner and providing the roots. The server exposes commands as tools in the form sf_<topic>_<command>, with aliases where applicable.
If you encounter missing commands after initial startup, clear the cache and rediscover commands. Stop the MCP server, delete the cache file, and start again.
If you add new Salesforce CLI plugins, refresh the cache using the provided tool and restart the MCP server to ensure new commands are registered.
Commands that require a Salesforce project context (deployments, retrievals, etc.) must run within a configured root. If you have multiple roots, you can specify the target root when invoking a tool or rely on the default root.
Get the Salesforce CLI version information.
Get help information for Salesforce CLI topics and commands.
Clear the command discovery cache for faster startup.
Refresh the command discovery cache to include newly installed plugins.
List Salesforce orgs configured in the CLI.
List authenticated Salesforce orgs.
Display details about a specific Salesforce org.
Open a Salesforce org in the browser.
Execute anonymous Apex code in a target org.
Run Apex tests in a target org.
Execute a SOQL query against a Salesforce org.
List sObjects in the target org.
Describe a Salesforce object in detail.
Deploy source code to a Salesforce org.