Apex Actions
Apex Actions — also commonly known as Invocable Actions — can be exposed as custom MCP tools, giving agents access to business logic your team has already written in Apex. Any Apex class with a global method annotated @InvocableMethod is eligible. The agent calls the tool; the Apex code runs server-side with full platform access.
Apex Actions are the right choice when you need tools that go beyond reading or writing a single record: a tool that generates a quote from an opportunity (multi-step with validation), escalates a case through an approval process, or enriches a contact by calling an external data service. Because the logic lives in Apex, it can do anything the platform supports — and the admin controls exactly which actions are exposed.
You configure Apex Action-backed tools through the custom server Setup UI — select Apex Action as the backing type, choose the action to expose, name the tool, provide a description, and publish. See Custom MCP Servers for the full configuration walkthrough.
When an agent invokes the tool, Salesforce executes the Apex method server-side with the provided inputs and returns the output variables defined by the method's schema.
Use Apex Actions when:
- The operation requires complex server-side logic — conditional branching, multi-step orchestration, external API calls, or data validation that's difficult to express as a single REST call or declarative flow.
- You have existing
@InvocableMethodclasses that implement business processes agents should be able to trigger.
Use Flows instead when:
- The business process is owned by admins and maintained in Flow Builder. Flows are easier to modify without a developer and don't require a code deployment to update.
- The logic is straightforward enough to express declaratively.
-
Quote generation: An agent reviewing an opportunity invokes an Apex Action that runs the quoting logic — applying product rules, pricing tiers, and approval thresholds — and returns a draft quote ID, rather than requiring the agent to replicate that logic itself.
-
Case escalation: An agent triaging support cases invokes an escalation action that applies the org's routing rules, updates the case record, notifies the assigned team, and logs an audit entry — all in one tool call.
-
Contact enrichment: An agent onboarding a new lead invokes an Apex Action that calls an external data service, retrieves firmographic data, and writes it back to the record — handling authentication and error cases in the Apex layer.
- Only Apex classes with a
globalmethod annotated@InvocableMethodcan be exposed as MCP tools through this backing type. - Apex Actions run as the authenticated user — governor limits and sharing rules apply the same as they would for any Apex execution triggered by that user.
- The Apex method's input and output variables define the tool's parameter schema. Methods with complex or nested types may require additional consideration to ensure the tool is easy for agents to call correctly.
- Updating the underlying Apex class (adding parameters, changing types) requires updating the tool configuration in Setup to stay in sync.