salesforce-mcp

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.

Category
Visit Server

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

  1. Clone this repository:
git clone <repository-url>
cd salesforce-mcp
  1. Install dependencies:
npm install
  1. 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 range
  • get_async_apex_job - Get detailed information about a specific AsyncApexJob by ID
  • call_rest_api - Make generic REST API calls to Salesforce
  • get_org_limits - Get organization limits information
  • get_sobjects_list - Get list of all available SObjects
  • describe_sobject - Describe a specific SObject schema

Apex Class Management

  • list_apex_classes - List all Apex classes with optional filtering
  • get_apex_class - Get detailed information about a specific Apex class
  • create_apex_class - Create a new Apex class
  • update_apex_class - Update an existing Apex class
  • delete_apex_class - Delete an Apex class

Apex Trigger Management

  • list_apex_triggers - List all Apex triggers
  • get_apex_trigger - Get detailed information about a specific trigger
  • create_apex_trigger - Create a new Apex trigger
  • update_apex_trigger - Update an existing trigger
  • delete_apex_trigger - Delete a trigger

Visualforce Page Management

  • list_apex_pages - List all Visualforce pages
  • get_apex_page - Get detailed information about a specific page
  • create_apex_page - Create a new Visualforce page
  • update_apex_page - Update an existing page
  • delete_apex_page - Delete a page

Query & Analysis Tools

  • execute_tooling_query - Execute SOQL queries against Tooling API
  • describe_tooling_object - Get schema information for Tooling objects
  • search_metadata - Search for metadata across different types
  • get_code_coverage - Get code coverage information
  • get_org_coverage - Get organization-wide coverage statistics
  • get_symbol_table - Analyze code structure and symbols
  • analyze_dependencies - Analyze code dependencies
  • get_completion_suggestions - Get code completion suggestions

Development Tools

  • run_tests - Execute Apex tests
  • get_test_results - Get test execution results
  • get_debug_logs - Retrieve debug logs
  • get_debug_log_body - Get full debug log content
  • validate_syntax - Validate Apex code syntax
  • check_apex_sharing - Check Apex sharing declarations
  • analyze_soql_performance - Analyze SOQL query performance
  • get_org_info - Get organization information
  • list_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 project
  • npm run dev - Run in development mode with hot reload
  • npm run watch - Watch mode for TypeScript compilation
  • npm run lint - Run ESLint
  • npm run format - Format code with Prettier
  • npm 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

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured