Step-by-Step Guide To Creating Custom MCP Server in Salesforce
Introduction
Salesforce's standard MCP servers are a good place to start. Switch one on and an AI client can query, create, and update records in your org, with your permissions still in charge.
But general-purpose is also the limitation. The assistant gets the whole object model and has to work out what to do with it. What you usually want is narrower — not "you can create any record," but "here's how we create a support case, with our defaults, our origin values, our logic."
That logic already exists in your org. It's sitting in Apex classes, in Flows, and in the queries behind your reports. A custom MCP server is how you hand exactly those pieces to an AI client, and nothing else.
This guide builds one end to end. You'll create a custom MCP server in Salesforce, add three tools to it — one written in Apex, one built as a Flow, one exposed through the Named Query API — connect it to Claude using an External Client App, and then drive all three from an ordinary conversation.
By the end you'll have an MCP server your team can genuinely use, and a pattern you can repeat for any process you want an AI client to reach.
Why this is worth learning
Salesforce Hosted MCP Servers went generally available in April 2026, and custom servers came with them. That matters more than it sounds. Every AI integration before this needed its own glue code, its own auth, its own maintenance. MCP replaces that with one governed pattern, and custom servers let you decide what goes through it.
Three reasons to learn this now rather than later.
You control the surface area. A standard server exposes broad capability. A custom server exposes a short, deliberate list — the tools you chose, described the way you want them understood. Nothing else in your org is reachable.
Your existing skills carry over. There's no new runtime to learn. If you can write an invocable Apex method, build an autolaunched Flow, or write a SOQL query, you can build an MCP tool. The work is in wrapping what you already know how to build.
Security stays where it belongs. Connection is per-user OAuth with PKCE. Every tool call runs as the person who authenticated, under their CRUD, field-level security, and sharing. You're not creating a service account with keys to everything.
Business use cases
Once the pattern clicks, the uses come quickly.
A support team working in chat all day can log a case from the conversation — through your Apex class, so the case is shaped the way every other case in the org is shaped.
A salesperson back from an event can turn scribbled notes into Leads without opening Salesforce, with a Flow applying the same field mapping your team already agreed on.
Anyone preparing for a call can ask who the contacts are at an account and get an answer from a Named Query that returns exactly the fields you decided to expose — no more, no less.
Step-by-step guide overview
The full walkthrough, with a screenshot for every step, is in the embedded guide below. Here's the shape of it.
You'll work through six stages.
First, create the custom MCP server in Setup and note its URL.
Second, write the CaseCreationTool Apex class with its invocable inputs and outputs, and add it to the server as a tool.
Third, build an autolaunched Flow with five input variables and one output, add a Create Records element for Lead, activate it, and add it as the second tool.
Fourth, create a Named Query API with a parameterised SOQL query, validate it, activate its actions from the API Catalog, and add it as the third tool.
Fifth, activate the MCP server and configure an External Client App with PKCE, the Claude callback URL, and the right scopes.
Finally, add the custom connector in Claude, authorise it, and put all three tools to work.
This guide is a lesson in our Mastering AIforce course. All Access Pass members can download the PDF from the lesson.
Summary and key takeaways
A custom MCP server lets you publish a short, deliberate list of capabilities from your org to any AI client that speaks MCP — and it does it without a line of integration code.
Tool descriptions are what drive tool selection, which makes them part of the build rather than documentation you write afterwards.