Salesforce CLI MCP Server
Enables AI assistants to interact with Salesforce orgs through natural language commands, supporting org management, SOQL queries, metadata operations, testing, and more.
README
Salesforce CLI MCP Server
A Model Context Protocol (MCP) server that integrates with the Salesforce CLI, allowing AI assistants to interact with Salesforce orgs through natural language commands. Now with Web UI!
🆕 New Features
- 🌐 Web UI: Interactive web interface for easy Salesforce CLI operations
- 🔗 HTTP Server: RESTful API endpoints alongside MCP protocol
- 📊 Real-time Status: Live server health monitoring
- 🎯 Quick Actions: One-click shortcuts for common operations
- 📋 Copy Results: Easy result copying and formatting
Features
- Org Management: List and manage authorized Salesforce orgs
- Data Operations: Execute SOQL queries and import data
- Metadata Operations: Deploy and retrieve metadata
- Testing: Run Apex tests
- Package Management: Create and manage Salesforce packages
- Custom Commands: Execute any Salesforce CLI command
- Web Interface: User-friendly web UI for all operations
- HTTP API: RESTful endpoints for programmatic access
Prerequisites
Before using this MCP server, ensure you have:
- Salesforce CLI installed: Install Salesforce CLI
- Node.js (version 18 or higher)
- At least one authorized Salesforce org
Quick Start
1. Clone the repository
git clone https://github.com/timaw513-emergenit/salesforce-cli-mcp-server.git
cd salesforce-cli-mcp-server
2. Install dependencies
npm install
3. Build the project
npm run build
4. Choose your mode
Option A: Web UI Mode (Recommended)
Start the server with web interface:
npm run web
Then open your browser to: http://localhost:3000
Option B: STDIO Mode (for MCP clients)
Configure your MCP client as shown below.
🌐 Web UI Usage
The web interface provides an intuitive way to interact with your Salesforce orgs:
Features:
- 🚀 Interactive Forms: Fill out forms for each Salesforce CLI command
- 📊 Quick Actions: One-click shortcuts for common tasks
- 📋 Live Results: Real-time command execution with formatted output
- 📱 Responsive Design: Works on desktop, tablet, and mobile
- 🔄 Status Monitoring: Real-time server health indicators
Available Operations:
- List Orgs: View all authorized Salesforce orgs
- Execute SOQL: Run queries with syntax highlighting
- Custom Commands: Execute any Salesforce CLI command
- Deploy/Retrieve: Metadata operations with progress tracking
- Run Tests: Execute Apex tests with detailed results
Quick Actions:
- List Orgs: Instantly view all authorized orgs
- Query Accounts: Pre-filled SOQL query for Account records
- Org Info: Display current org details
API Endpoints
When running in HTTP mode, the server provides these endpoints:
Core Endpoints:
GET /- Web UI interfaceGET /health- Health checkGET /api/status- Detailed server statusGET /api/tools- Available tools listPOST /api/execute- Execute Salesforce CLI commandsPOST /mcp- MCP protocol endpoint
Example API Usage:
# Execute a SOQL query
curl -X POST http://localhost:3000/api/execute \
-H "Content-Type: application/json" \
-d '{"command": "data query --json --query \"SELECT Id, Name FROM Account LIMIT 5\""}'
# List all orgs
curl -X POST http://localhost:3000/api/execute \
-H "Content-Type: application/json" \
-d '{"command": "org list --json"}'
# Check server health
curl http://localhost:3000/health
MCP Client Configuration
For Claude Desktop
Add this configuration to your Claude Desktop MCP settings file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
STDIO Mode:
{
"mcpServers": {
"salesforce-cli": {
"command": "node",
"args": ["/absolute/path/to/salesforce-cli-mcp-server/build/index.js"]
}
}
}
HTTP Mode:
{
"mcpServers": {
"salesforce-cli-http": {
"command": "curl",
"args": ["-X", "POST", "http://localhost:3000/mcp"]
}
}
}
For VS Code with MCP Extension
Create a .vscode/mcp.json file in your project root:
{
"servers": {
"Salesforce CLI": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/salesforce-cli-mcp-server/build/index.js"]
}
}
}
Available Commands
NPM Scripts
# Development
npm run build # Build TypeScript
npm run dev # Watch mode for development
npm run clean # Clean build directory
# Running
npm run start # Start in STDIO mode
npm run http # Start HTTP server (with Web UI)
npm run web # Alias for http mode
npm run ui # Alias for http mode
# Testing
npm run inspector # Run MCP Inspector
npm run test # Build and run inspector
Available Tools
1. sf_org_list
List all authorized Salesforce orgs.
2. sf_data_query
Execute a SOQL query against a Salesforce org.
3. sf_project_deploy
Deploy metadata to a Salesforce org.
4. sf_project_retrieve
Retrieve metadata from a Salesforce org.
5. sf_apex_test_run
Run Apex tests in a Salesforce org.
6. sf_data_import
Import data from a CSV file into a Salesforce org.
7. sf_package_create
Create a new Salesforce package.
8. sf_custom_command
Execute any Salesforce CLI command.
Usage Examples
Via Web UI
- Open http://localhost:3000
- Select a tool from the sidebar
- Fill out the form parameters
- Click "Execute" and view results
Via Natural Language (MCP clients)
Once configured, you can use natural language with your AI assistant:
Org Management
- "List all my Salesforce orgs"
- "Show me the connection status of all orgs"
Data Queries
- "Query all accounts in my org"
- "Get all contacts where the email contains 'example.com'"
- "Run this SOQL query: SELECT Id, Name FROM Account LIMIT 10"
Metadata Operations
- "Deploy all metadata to my sandbox"
- "Retrieve the Account object metadata"
- "Deploy only the AccountController class"
Testing
- "Run all Apex tests in my org"
- "Run tests for the AccountTest class"
Data Import
- "Import the accounts.csv file as Account records"
Custom Commands
- "Run the command: org display --target-org myorg"
Development
Testing
Use the MCP Inspector to test your server:
npm run inspector
Development Mode
Run in development mode with auto-rebuild:
npm run dev
Web UI Development
For web UI development, start the HTTP server and make changes to files in the public/ directory:
npm run web
The server will serve static files from the public/ directory automatically.
Security Considerations
This MCP server executes Salesforce CLI commands directly on your system. Ensure that:
- You trust the AI assistant you're using
- You have proper backup procedures in place
- You understand the implications of the commands being executed
- You review any destructive operations before confirming
- The HTTP server (if used) is only accessible from trusted networks
Troubleshooting
Common Issues
-
"Command not found: sf"
- Ensure Salesforce CLI is installed and in your PATH
-
"No orgs found"
- Make sure you have authorized at least one Salesforce org using
sf org login web
- Make sure you have authorized at least one Salesforce org using
-
"Permission denied"
- Ensure the build files have execute permissions:
chmod +x build/*.js
- Ensure the build files have execute permissions:
-
"Module not found"
- Run
npm installto install dependencies - Run
npm run buildto compile TypeScript
- Run
-
"Port already in use"
- Change the port:
MCP_PORT=3001 npm run web
- Change the port:
-
Web UI not loading
- Ensure you've run
npm run buildfirst - Check that
public/index.htmlexists - Verify server is running:
curl http://localhost:3000/health
- Ensure you've run
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
🌟 Now with Web UI! Access your Salesforce CLI through a beautiful, intuitive web interface at http://localhost:3000
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.