Salesforce CLI MCP Server

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.

Category
访问服务器

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:

  1. Salesforce CLI installed: Install Salesforce CLI
  2. Node.js (version 18 or higher)
  3. 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 interface
  • GET /health - Health check
  • GET /api/status - Detailed server status
  • GET /api/tools - Available tools list
  • POST /api/execute - Execute Salesforce CLI commands
  • POST /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

  1. Open http://localhost:3000
  2. Select a tool from the sidebar
  3. Fill out the form parameters
  4. 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:

  1. You trust the AI assistant you're using
  2. You have proper backup procedures in place
  3. You understand the implications of the commands being executed
  4. You review any destructive operations before confirming
  5. The HTTP server (if used) is only accessible from trusted networks

Troubleshooting

Common Issues

  1. "Command not found: sf"

    • Ensure Salesforce CLI is installed and in your PATH
  2. "No orgs found"

    • Make sure you have authorized at least one Salesforce org using sf org login web
  3. "Permission denied"

    • Ensure the build files have execute permissions: chmod +x build/*.js
  4. "Module not found"

    • Run npm install to install dependencies
    • Run npm run build to compile TypeScript
  5. "Port already in use"

    • Change the port: MCP_PORT=3001 npm run web
  6. Web UI not loading

    • Ensure you've run npm run build first
    • Check that public/index.html exists
    • Verify server is running: curl http://localhost:3000/health

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选