Salesforce MCP · Apex actions · Walkthrough + Playbook

Salesforce MCP Tools That Run Apex: Interactive Walkthrough & Playbook

When a rep asks Claude to create an opportunity, Claude should call a governed Create Opportunity tool, not guess how your Opportunity object works. Click through the full build, from the Apex action to the approved write, then take the playbook.

SalesforceClaude

Walkthrough screens are an illustrative JayOh recreation with fictional data, not the live products. Setup steps follow Salesforce’s Hosted MCP Servers documentation.

What you’ll learn

Predefined actions, not freeform object edits

The right pattern for any Salesforce org where Claude writes to the CRM.

01

Why freeform writes break data: what happens when Claude creates records with generic SObject tools.

02

Apex to MCP tool: turn an @InvocableMethod into a tool on a custom Salesforce MCP server.

03

Approval by design: how tool annotations and Claude permissions keep every write reviewed.

04

The rollout: what JayOh builds, the action library we start with and what we measure.

Interactive walkthrough · 12 steps · 6 min

Watch Claude create an opportunity the governed way

Start in Salesforce with what freeform writes leave behind, build the Apex-backed server, connect it to Claude, then follow one request from plain English to a clean record. Click Next or use your arrow keys.

Illustrative recreation of Salesforce Setup, Lightning Experience and the Claude app with fictional data (Brightline Software). Not the actual products; labels can change between releases.

12 screens, from Apex to approved write

What an admin, a developer and a rep each see.

1

Freeform writes guess at your process

Six opportunities Claude created with generic SObject tools; only one is clean.

2

Write the action once, in Apex

An @InvocableMethod with a plain-language description and only the inputs Claude may send.

3

Open MCP Servers in API Catalog

Standard servers are off by default and can't be edited. Custom ones can.

4

Create a custom server

Label, permanent name and a description that scopes what the server is for.

5

Add only the actions you trust

Add Server Assets, Add Tools, Apex actions: four in, two left out on purpose.

6

Annotate the tools, then activate

Read-only and Idempotent hints, then activate and copy the server URL.

7

Let Claude sign in as each user

External Client App with Claude's callback URL, two scopes and PKCE.

8

Add the connector in Claude

Customize, Connectors, Add custom connector, then sign in to Salesforce.

9

Reads run, writes ask first

Claude groups tools by annotation: read-only always allowed, writes need approval.

10

The rep asks in plain English

Claude picks Create Opportunity and shows the five inputs before it runs.

11

Claude runs the action and reports back

Your Apex answers: CREATED, the record Id and the duplicate check.

12

The record follows your process

Discovery stage, a price book line, an audit stamp and the rep as owner.

The play

The play: governed Salesforce writes through Apex-backed MCP tools

4Apex actions on the first server
0freeform create or update tools
2OAuth scopes on the External Client App
100%of pilot writes approved by the rep

Pilot defaults JayOh starts with. Your action count depends on which tasks reps ask Claude to do most.

The problem

Salesforce’s standard MCP servers give Claude general tools: query records, create records, update records. They respect field-level security and sharing, so they’re safe in the access sense. But they don’t know your process. Claude fills in stage, close date, amount and record type from context, and a guess that passes validation still becomes bad pipeline.

Salesforce now documents a better pattern. A custom MCP server can expose Apex invocable actions, flows and Apex REST methods as tools. Claude calls Create Opportunity, and your code decides how an opportunity gets created.

Step-by-step setup

  1. Write one invocable action per business task. A global class with an @InvocableMethod, a plain-language description and only the inputs Claude may send.
  2. Put the rules in the action. Stage, price book, owner, duplicate check and user-mode DML live in one bulk-safe service.
  3. Create a custom server. Setup › API Catalog › MCP Servers › Create Salesforce MCP Server.
  4. Add the actions as tools. Add Server Assets › Add Tools › Apex actions, and add only what reps need.
  5. Annotate and activate. Mark read-only tools Read-only, mark retry-safe tools Idempotent, then activate and copy the server URL.
  6. Create an External Client App. Callback https://claude.ai/api/mcp/auth_callback, scopes refresh_token and mcp_api, PKCE required.
  7. Add the custom connector in Claude. Customize › Connectors › Add custom connector with the server URL, then use your own OAuth client with the consumer key as the OAuth Client ID.
  8. Keep writes on Needs approval. Read-only tools can always run; write tools ask the rep first until the data says otherwise.

What JayOh builds

  • The action library: Apex classes, the shared service layer and test coverage
  • One custom MCP server per persona, deployed sandbox to production with the Metadata API
  • The External Client App, permission sets and a Created Via audit field
  • Claude connector setup, tool permissions and rep prompts
  • A Salesforce report on every MCP-created record

What we measure

  • Claude-created records that fail your data checks (target: 0)
  • Duplicate opportunities created through Claude
  • Time from the rep’s request to a usable record
  • Share of writes approved without edits
Guardrail

No freeform write tools on any server reps use. Standard SObject servers stay read-only; every write goes through an action you can test, version and audit.

Generic SObject tools vs. governed Apex tools

Both run as the signed-in user. Only one knows your process.

Standard SObject tools (create_records, update_records)Custom server with Apex actions
What Claude can writeAny field on any object the user can editOnly the inputs each action defines
Business rulesValidation rules and flows only; everything else is Claude’s guessCoded once in Apex: stage, price book, owner, defaults
DuplicatesWhatever your duplicate rules catchThe action checks first and returns the existing record
PermissionsThe user’s profile, field-level security and sharingThe same, when the class runs with sharing and user-mode DML
Approval in ClaudeGrouped with every other writePer tool, with annotations Claude reads
Best forQuestions, lookups and reportingEvery write a rep asks for

A starter action library for RevOps

The actions JayOh usually ships first. Each one does a single task.

WRITE

Create Opportunity

Sets stage, price book, close date and primary contact; returns the open opportunity if one exists.

WRITE

Log Meeting Outcome

Logs the meeting, next step and next-step date in one call, so activity history stays complete.

WRITE

Advance Opportunity Stage

Moves one stage forward only when that stage’s exit criteria are filled in.

READ-ONLY

Check Opportunity Readiness

Lists missing fields and exit criteria for the next stage. Safe to always allow.

WRITE

Request Discount Approval

Submits a discount into your approval process instead of editing the price.

WRITE

Create Renewal Opportunity

Builds the renewal from the contract with the right term, products and owner.

Where teams get governed MCP tools wrong

Four patterns we fix most often.

WRONG

SObject All for writes

The broadest server gets turned on first and reps start creating records through it.

RIGHT

Read standard, write custom

Standard servers answer questions. Every write goes through a custom server.

WRONG

Descriptions written for developers

“Inserts Opp via service layer” tells Claude nothing about when to use it.

RIGHT

Descriptions written for Claude

Say what the tool does, when to use it and what it returns, in plain language.

WRONG

One do-anything action

A generic “update opportunity” action with 40 optional inputs is freeform editing with extra steps.

RIGHT

One action per task

Small actions with required inputs. Claude picks better and you test less.

WRONG

Always allow on day one

Writes run silently before anyone has checked what Claude sends.

RIGHT

Needs approval until proven

Loosen one tool at a time once the MCP-created records report stays clean.

Salesforce MCP tools and Apex: common questions

What is a Salesforce MCP tool that runs Apex?

It is a tool on a custom Salesforce MCP server that is backed by Apex, most often a global method annotated with @InvocableMethod. Salesforce builds the tool schema from the method's inputs and outputs, and an AI client like Claude calls it by name. The Apex decides how records are created or changed, so Claude never edits objects freeform.

Do Apex-backed MCP tools respect Salesforce permissions?

Salesforce runs the action as the user who signed in through OAuth, so governor limits and sharing apply. Build the class with sharing and use user-mode queries and DML so field-level security is enforced too. Each rep connects with their own Salesforce login, so Claude can only do what that rep can do.

Should we turn off the standard SObject servers?

Not necessarily. Standard servers such as SObject Reads are useful for questions and lookups. The pattern JayOh recommends is to read with standard tools and write only through a custom server of Apex actions, so every write follows your process.

Which Salesforce automation can become an MCP tool?

Custom servers can expose Apex invocable actions, AuraEnabled Apex methods, Apex REST methods, autolaunched flows, APIs from API Catalog, Agentforce agents and prompt templates. Use Apex or flows for anything with business rules or more than one step.

How do we connect Claude to a custom Salesforce MCP server?

Create an External Client App with the callback URL https://claude.ai/api/mcp/auth_callback, the refresh_token and mcp_api scopes and PKCE required. In Claude, add a custom connector with the server URL from Setup, choose your own OAuth client and enter the app's consumer key as the OAuth Client ID, then connect and sign in to Salesforce.

Want Claude writing to Salesforce the governed way?

We build the action library, the custom MCP server and the Claude setup, then run a two-week pilot with one team.

Talk to our team