Flows
Lightning Flows can be exposed as custom MCP tools, giving AI agents access to declarative automation your team has already built. If you've implemented a business process in Flow Builder — routing a lead, sending an approval request, creating a set of related records from a template, triggering a notification sequence — that same flow can now be invoked by an agent through MCP without any code changes.
Flows are a natural path for orgs that manage business processes declaratively. Rather than writing Apex just to give agents access to automation, admins can publish existing flows as tools directly through the Salesforce Setup UI.
You configure Flow-backed tools through the custom server Setup UI — select a Flow as the backing type, choose an autolaunched flow with defined input and output variables, name the tool, provide a description, and publish. See Custom MCP Servers for the full configuration walkthrough.
The MCP server generates a tool from the flow's input and output variable schema. When an agent invokes the tool, Salesforce launches the flow server-side with the provided inputs and returns the output variables.
Because the flow runs in Salesforce, it has full access to platform capabilities: it can query and update records, call external services via Named Credentials, send emails, trigger subflows, and interact with approval processes — all with the authenticated user's permissions applied.
Use Flows as MCP tools when:
- You have existing flows that implement the process you want to expose. Reuse is faster than rebuilding in Apex.
- The business process is owned by admins who maintain it in Flow Builder. Keeping the automation in Flow means future changes don't require code deployments.
- The operation involves sequential, multi-step logic that's easier to express declaratively (branching, looping, record lookups) than as a single API call.
- The process needs to be auditable and modifiable by non-developers. Flows are visible and editable in Flow Builder without an IDE.
Use Invocable Actions (Apex) instead when:
- The operation requires complex computation, external API calls with custom error handling, or logic that's difficult to express in Flow Builder.
- Performance is critical — Apex generally executes faster than flows for compute-intensive operations.
- You need fine-grained control over bulkification, transactions, or exception handling.
-
Lead routing: An agent collects lead qualification information from a conversation and invokes a flow tool that assigns the lead to the right territory and rep, creates a follow-up task, and sends an intro email — all in one step.
-
Onboarding provisioning: An agent working through a customer onboarding checklist invokes a flow that creates the initial set of records (Account, Contact, Opportunity, related custom objects) from a template, eliminating manual data entry.
-
Approval initiation: An agent reviewing a contract identifies a discount that exceeds policy thresholds and invokes a flow tool that submits the record to the appropriate approval process and notifies the manager — without the agent needing to know the approval process configuration.
- Only autolaunched flows (not screen flows or scheduled flows) can be exposed as MCP tools. The flow must have defined input and output variables.
- Flow execution runs as the authenticated user, not as a system context. Flow logic that relies on permissions or sharing may behave differently depending on who invokes the tool.
- Governor limits apply. Flows invoked via MCP consume Apex and DML limits the same as flows triggered from the UI or Apex. Bulk operations that would exceed limits should use Batch Apex or Bulk API patterns instead.
- Tool descriptions are set at configuration time. If the flow's behavior changes significantly, update the tool description in Setup to keep agents informed.
- There is no streaming or progress reporting for long-running flows. The agent waits for the flow to complete and receives the final output. For processes that take more than a few seconds, consider a flow that returns a job ID for later status checking.