Skip to main content

Salesforce Platform Tooling MCP server

An AI agent connected to Salesforce Platform Tooling can manage development artifacts—creating and updating Apex classes, Lightning Web Components, and metadata; executing anonymous Apex code; retrieving debug logs; and automating deployments. Developers, platform engineers, and release managers use this integration to streamline CI/CD pipelines and reduce manual code management.

Setting up an MCP server

This article covers the standard steps for creating an MCP server in AI Gateway and connecting it to an AI client. The steps are the same for every integration — application-specific details (API credentials, OAuth endpoints, and scopes) are covered in the Authentication section on this page.

Before you begin

You'll need:

  • Access to AI Gateway with permission to create MCP servers.
  • API credentials for the application you're connecting (see the Authentication section on this page for what to collect).

Create an MCP server

Find the app in the catalog

  1. Sign in to AI Gateway and select App Catalog from the left navigation.
  2. Search for the application you want to connect, then select it from the catalog.
  3. Select Create MCP Server to start the wizard.

App Configuration

Confirm the Base URL for the API, then, under Tools, select the endpoints you want to expose. Select Next.

MCP Server Setup

  1. Enter a Name for your server — something descriptive that identifies both the application and its purpose.
  2. Enter a Description so your team knows what the server is for.
  3. Set the log level: choose Production Mode for terser logs, or Non-Production Mode for more verbose logs that can help with debugging.
  4. Select Next.

Authentication

Enter the authentication details for the application. This varies by service — see the Authentication section on this page for the specific credentials, OAuth URLs, and scopes to use.

Review

Look over the summary of your MCP server configuration, then select Create & Deploy. AI Gateway provisions the server and provides a server URL you'll use when configuring your AI client.


Connect to an AI client

Once your server is deployed, you'll need to add it to the AI client your team uses. Select your client for setup instructions:

Tips

  • You can create multiple MCP servers for the same application — for example, a read-only server for reporting agents and a read-write server for automation workflows.
  • If you're unsure which OAuth scopes to request, start with the minimum read-only set and add write scopes only when needed. Most application pages include scope recommendations.

Authentication

Salesforce Tooling API uses OAuth 2.0 through a Connected App for API access. Your Connected App provides Client ID and Client Secret. Use https://test.salesforce.com for sandboxes. In Salesforce, go to Setup > App Manager and create a new Connected App with OAuth enabled to obtain your credentials.

ValueSetting
Auth endpointhttps://login.salesforce.com/services/oauth2/authorize
Token endpointhttps://login.salesforce.com/services/oauth2/token
Scopesapi, refresh_token, full, custom_permissions, visualforce

Available tools

The MCP server provides Apex development, metadata management, debug logging, and deployment capabilities for development workflow automation.

Code & component management

ToolDescription
createApexClassCreate new Apex class with source code
updateApexClassUpdate Apex class body and metadata
getApexClassRetrieve Apex class definition and test coverage
createTriggerCreate database trigger with event and logic
updateTriggerModify trigger code and target object
createLwcComponentCreate Lightning Web Component with HTML, CSS, JS
updateLwcComponentUpdate LWC files and properties

Testing & analysis

ToolDescription
runTestsExecute Apex test class and retrieve results
getCodeCoverageCheck code coverage percentage per class
executeAnonymousRun anonymous Apex code for quick operations
getDebugLogRetrieve and analyze debug logs for execution trace

Metadata & configuration

ToolDescription
describeMetadataGet all available metadata types
retrieveMetadataRetrieve metadata files (CustomObject, ValidationRule, etc.)
deployMetadataDeploy code and configuration to target org
createMetadataItemCreate custom object, field, or configuration
updateMetadataUpdate field definitions, validation rules, workflows

Deployment & CI/CD

ToolDescription
createDeployRequestStart metadata deployment with change set
getDeployStatusCheck deployment progress and error details
checkDeployValidityValidate deployment before executing
listDeployRequestsGet recent deployments and status

Tips

Require full scope for any deployment operationsapi alone won't authorize code deployments to prevent accidental overwrites.

Use Apex classes with proper error handling for production workflows to ensure graceful degradation and clear error messages.

Avoid relying on Anonymous Apex (executeAnonymous) for production workflows — it's useful for one-off data fixes or quick testing, but not for long-term automation.

Batch test runs with runTests during off-peak hours as test execution consumes significant org resources and can slow other operations.

Retrieve metadata and validate with checkDeployValidity before deployMetadata to catch conflicts and missing dependencies early.

Store debug logs securely if they contain sensitive data — never store them in plain text systems.

Monitor log size and archive older logs regularly to avoid hitting org storage limits.