Apex SDK

v1.0.0Developer Toolsstable

Apex SDK for building Model Context Protocol (MCP) servers natively in Salesforce

mcp-apex-sdkmcpai-integration
Share:
18
Stars
0
Downloads
0
Weekly
0/5

What is Apex SDK?

Apex SDK is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to apex sdk for building model context protocol (mcp) servers natively in salesforce

Apex SDK for building Model Context Protocol (MCP) servers natively in Salesforce

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Apex SDK for building Model Context Protocol (MCP) servers n

Use Cases

Build MCP servers natively within Salesforce using Apex. Create Salesforce integrations with MCP protocol support.
bfmvsa

Maintainer

LicenseMIT
Languageapex
Versionv1.0.0
UpdatedSep 18, 2025
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-apex-sdk

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Apex SDK

The MCP Apex SDK lets Salesforce developers build Model Context Protocol servers natively in Apex, Salesforce's platform language, without any external infrastructure. The SDK provides base classes (ctx.Tool, ctx.Resource, ctx.Prompt, ctx.Server) that map directly to MCP primitives, so teams can expose Salesforce data and business logic as AI-callable tools hosted entirely within their Salesforce org via a REST endpoint. It is designed for organisations that must keep AI integrations inside the Salesforce trust boundary.

Prerequisites

  • A Salesforce org with permission to install managed packages (Developer, Sandbox, or Enterprise edition)
  • Salesforce CLI (sf) for deploying example Apex classes
  • Access to Salesforce Setup to create a Site and configure guest user access
  • Basic Apex development knowledge
  • An MCP-compatible AI client or the MCP Inspector tool for testing
1

Install the SDK package into your Salesforce org

Install the managed package using the provided Salesforce packaging link for your environment type (production or sandbox). This deploys the SDK base classes to your org.

# Install via Salesforce CLI (replace PACKAGE_VERSION_ID with the actual ID from the repo)
sf package install --package PACKAGE_VERSION_ID --target-org myorg --wait 10
2

Deploy the demo Apex classes

Clone the repository and deploy the example server implementation from force-app/main/example/ to see a working MCP server before writing your own.

git clone https://github.com/bfmvsa/mcp-apex-sdk.git
cd mcp-apex-sdk
sf project deploy start --source-dir force-app/main/example --target-org myorg
3

Create a Salesforce Site and expose the endpoint

In Salesforce Setup, navigate to Sites, create a new site, and set DemoServer as the active page. Then go to Public Access Settings and add DemoServer to Enabled Apex Class Access.

4

Note your MCP endpoint URL

Your MCP server endpoint is constructed from your Site URL. For orgs without a namespace it is {site_url}/services/apexrest/mcp. For orgs with a namespace use {site_url}/services/apexrest/{namespace}/mcp.

5

Test connectivity with MCP Inspector

Use the MCP Inspector browser tool to connect to your Salesforce-hosted endpoint and verify that tools, resources, and prompts are listed correctly.

npx @modelcontextprotocol/inspector
6

Build your own MCP server in Apex

Extend the SDK classes to expose your own Salesforce data and business logic. Create Tool, Resource, and Prompt implementations, then register them with ctx.Server.

// Example Apex tool definition
public class MyTool extends ctx.Tool {
    public MyTool() {
        this.name = 'get_account';
        this.description = 'Retrieve a Salesforce Account by name';
    }
    public override Object call(Map<String, Object> args) {
        String name = (String) args.get('name');
        Account acc = [SELECT Id, Name, Industry FROM Account WHERE Name = :name LIMIT 1];
        return acc;
    }
}

Apex SDK Examples

Client configuration

MCP client configuration pointing to a Salesforce-hosted MCP endpoint. Replace the URL with your actual Salesforce Site URL.

{
  "mcpServers": {
    "salesforce-mcp": {
      "url": "https://yoursite.my.salesforce-sites.com/services/apexrest/mcp"
    }
  }
}

Prompts to try

Example prompts for an MCP server exposing Salesforce data once the SDK is deployed.

- "List all open opportunities in Salesforce over $50,000"
- "Find the Account record for Acme Corp and show their industry and revenue"
- "Create a new lead in Salesforce with the contact details I'll provide"
- "Run the monthly sales report prompt and summarise the results"
- "What tools are available in this Salesforce MCP server?"

Troubleshooting Apex SDK

MCP endpoint returns 404 or 'Page Not Found'

Confirm the Salesforce Site is active (not in Preview mode) and that DemoServer is listed under the site's Active Pages. Also check whether your org uses a namespace — if so, the URL must include it: /services/apexrest/{namespace}/mcp.

Guest user receives 'Insufficient Privileges' error when calling tools

In Salesforce Setup, navigate to the Site's Public Access Settings > Enabled Apex Classes and ensure your MCP server Apex class (e.g., DemoServer) is listed. Also verify that any objects accessed by your tools have appropriate object-level permissions on the guest user profile.

Package installation fails in sandbox

Use the sandbox-specific installation link from the repository (not the production link). Ensure the sandbox type supports managed packages — Developer Pro or higher is required. Check the installation log in Setup > Installed Packages for detailed error messages.

Frequently Asked Questions about Apex SDK

What is Apex SDK?

Apex SDK is a Model Context Protocol (MCP) server that apex sdk for building model context protocol (mcp) servers natively in salesforce It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Apex SDK?

Follow the installation instructions on the Apex SDK GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Apex SDK?

Apex SDK works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Apex SDK free to use?

Yes, Apex SDK is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mcp-apex-sdk": { "command": "npx", "args": ["-y", "mcp-apex-sdk"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Apex SDK?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides