salesforce-mcp
An MCP server that provides comprehensive access to Salesforce Tooling API for metadata management, SOQL queries, code analysis, and debugging through Claude and other AI assistants.
README
Salesforce Tooling API MCP Server
A Model Context Protocol (MCP) server that provides comprehensive access to Salesforce Tooling API functionality through Claude and other compatible AI assistants.
Features
🔧 Metadata Management
- Apex Class Tools: CRUD operations for Apex classes
- Apex Trigger Tools: CRUD operations for Apex triggers
- Visualforce Tools: CRUD operations for Visualforce pages
🔍 Query & Search
- SOQL Query Tools: Execute Tooling API queries with SOQL
- Metadata Search: Search across different metadata types
- Object Describe: Get schema information for Tooling API objects
📊 Code Analysis & Quality
- Code Coverage Tools: Analyze test coverage for classes and triggers
- Symbol Table Tools: Analyze code structure, dependencies, and get completion suggestions
- Performance Tools: Analyze SOQL query performance
🐛 Development & Debugging
- Debug Tools: Access debug logs and heap dumps
- Test Execution: Run Apex tests and get results
- Syntax Validation: Validate Apex code syntax
🔒 Security & Governance
- Security Tools: Check Apex sharing declarations and permissions
- Org Management: Get organization information and available objects
Installation
- Clone this repository:
git clone <repository-url>
cd salesforce-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
Configuration
Configure your Salesforce connection using environment variables:
SF CLI Authentication
The MCP server uses Salesforce CLI authentication. Make sure you have authenticated to your org using the Salesforce CLI:
# Use default authenticated org
npm run dev
# Specify a particular org by alias
export SF_TARGET_ORG="myorg"
npm run dev
# Or specify by username
export SF_TARGET_ORG="user@example.com"
npm run dev
Prerequisites:
- Install Salesforce CLI: https://developer.salesforce.com/tools/cli
- Authenticate to your org:
sf org login web - Verify authentication:
sf org list
Usage
Running the MCP Server
# Development mode
npm run dev
# Production mode (after build)
./build/index.js
Claude Code CLI Configuration
claude mcp add salesforce-mcp -s project \
-e SF_TARGET_ORG=myorg \
-- npx salesforce-mcp-server@latest
Available Tools
REST API Tools
search_async_apex_jobs- Search AsyncApexJob records with filtering by status, job type, Apex class name, date rangeget_async_apex_job- Get detailed information about a specific AsyncApexJob by IDcall_rest_api- Make generic REST API calls to Salesforceget_org_limits- Get organization limits informationget_sobjects_list- Get list of all available SObjectsdescribe_sobject- Describe a specific SObject schema
Apex Class Management
list_apex_classes- List all Apex classes with optional filteringget_apex_class- Get detailed information about a specific Apex classcreate_apex_class- Create a new Apex classupdate_apex_class- Update an existing Apex classdelete_apex_class- Delete an Apex class
Apex Trigger Management
list_apex_triggers- List all Apex triggersget_apex_trigger- Get detailed information about a specific triggercreate_apex_trigger- Create a new Apex triggerupdate_apex_trigger- Update an existing triggerdelete_apex_trigger- Delete a trigger
Visualforce Page Management
list_apex_pages- List all Visualforce pagesget_apex_page- Get detailed information about a specific pagecreate_apex_page- Create a new Visualforce pageupdate_apex_page- Update an existing pagedelete_apex_page- Delete a page
Query & Analysis Tools
execute_tooling_query- Execute SOQL queries against Tooling APIdescribe_tooling_object- Get schema information for Tooling objectssearch_metadata- Search for metadata across different typesget_code_coverage- Get code coverage informationget_org_coverage- Get organization-wide coverage statisticsget_symbol_table- Analyze code structure and symbolsanalyze_dependencies- Analyze code dependenciesget_completion_suggestions- Get code completion suggestions
Development Tools
run_tests- Execute Apex testsget_test_results- Get test execution resultsget_debug_logs- Retrieve debug logsget_debug_log_body- Get full debug log contentvalidate_syntax- Validate Apex code syntaxcheck_apex_sharing- Check Apex sharing declarationsanalyze_soql_performance- Analyze SOQL query performanceget_org_info- Get organization informationlist_sobjects- List available SObjects
Example Usage with Claude
Once the MCP server is running and connected to Claude, you can use natural language commands like:
- "Search for completed AsyncApexJob records for BatchProcessor class"
- "Get details of AsyncApexJob with ID 707XXXXXXXXXXXXXXX"
- "Find all failed batch jobs from the last week"
- "List all Apex classes that contain 'Account' in their name"
- "Show me the code coverage for all classes below 75%"
- "Get the symbol table for the AccountTriggerHandler class"
- "Create a new Apex class called TestUtils with basic utility methods"
- "Run all tests and show me the results"
Development
Project Structure
src/
├── auth/ # Salesforce authentication
├── client/ # Tooling API HTTP client
├── tools/ # MCP tool implementations
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
└── index.ts # Main server entry point
Available Scripts
npm run build- Build the TypeScript projectnpm run dev- Run in development mode with hot reloadnpm run watch- Watch mode for TypeScript compilationnpm run lint- Run ESLintnpm run format- Format code with Prettiernpm test- Run tests
Requirements
- Node.js 18+
- Valid Salesforce org with API access
- Salesforce CLI installed and authenticated
License
MIT License - see LICENSE file for details
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。