Skip to content

Stacksync × Supabase Miami: AI-Native OperationsOct 13Reserve your spot

How to Cut Salesforce AI Agent Costs Before MCP Metering Starts

Salesforce will bill every successful agent call. Seven ways to cut calls per task: combined SOQL, cached schema, Flow tools, scoped servers, and serving agent reads from a synced database.

Author
Ignacio Malpartida · GTM Engineer
Published
Read time
6 min read
How to Cut Salesforce AI Agent Costs Before MCP Metering Starts
DATA ENGINEERING

How do you cut Salesforce agent costs?

Short answer: Salesforce will charge a flat number of Flex Credits for each successful call a registered agent makes, so your bill tracks calls per task. Cut calls by combining reads into one SOQL query, caching schema, calling Flows instead of chaining writes, giving each agent the narrowest server, and serving heavy reads from a synced database copy of Salesforce. Measure first in a sandbox, where Salesforce doesn't meter calls.

A chatty Salesforce agent makes 10 calls per task; an optimized one makes 1 or 2

Why calls per task decide your bill

Salesforce prices each Headless Platform Interaction (HPI) the same. A Salesforce spokesperson told Salesforce Ben that the number of interactions "depends entirely on the third-party agent's behavior and the specific implementation." Two agents that deliver the same answer can differ fivefold in cost.

The same Salesforce agent request at 10 HPIs unoptimized and 1 to 2 HPIs optimized
Same request, a tenth of the calls

Take one request: "Research Acme, update the renewal opportunity, and log a follow-up." Here is what an unoptimized agent often does on the hosted MCP server:

  • 01getObjectSchema (index)
  • 02getObjectSchema (Account)
  • 03getObjectSchema (Opportunity)
  • 04find for "Acme"
  • 05soqlQuery for the account
  • 06getRelatedRecords for contacts
  • 07getRelatedRecords for opportunities
  • 08soqlQuery for recent activities
  • 09updateSobjectRecord on the opportunity
  • 10createSobjectRecord for the task

That's 10 HPIs. The tactics below take the same request to 3 or fewer. At 20 credits per call, that saves $1.40 per request. Across 5,000 requests a month, it saves $7,000. Run your own numbers with our cost estimates.

1. Measure calls per task in a sandbox first

Salesforce doesn't meter sandboxes, scratch orgs, or Developer Edition orgs. Run each workflow 20 times there and log every tool call. Record the median and the worst case. You can't optimize a number you haven't measured, and you won't get a cheaper chance to measure it.

2. Put the schema in the prompt

Schema calls return the same answer every time. Every successful call still counts. Export the objects and fields each agent needs once, including the admin guidance getObjectSchema returns (such as "use Calculated_ACV__c, not Amount"). Put that into the agent's system prompt or a knowledge file. Refresh it when your metadata changes.

Saves: 2 to 3 calls per request in the example.

3. Combine reads into one SOQL query

SOQL supports parent lookups and child subqueries. One query can return the account, its contacts, and its open opportunities:

sql
SELECT Id, Name, Industry,
  (SELECT Name, Title, Email FROM Contacts),
  (SELECT Name, StageName, Amount, CloseDate FROM Opportunities WHERE IsClosed = false)
FROM Account
WHERE Name = 'Acme Corp'
LIMIT 1

Tell the agent in its instructions to prefer one combined soqlQuery over chains of getRelatedRecords. Use find only when the agent doesn't know which object holds the data.

Saves: 3 to 4 calls per request.

4. Wrap multi-step writes in a Flow or Apex tool

Salesforce lets admins publish Flows, Apex invocable actions, and Apex REST endpoints as custom MCP tools. A "Log Renewal Follow-up" Flow can update the opportunity, create the task, and notify the owner in one tool call. You also get your existing validation and approval logic for free.

Saves: 1 or more calls per write-heavy request, and fewer failed writes.

5. Give each agent the narrowest server

A research agent on sobject-all sees create, update, and delete tools it should never call. Extra tools invite extra calls and risky ones. Connect read-only agents to sobject-reads and write-capable agents to sobject-mutations. The endpoint guide maps each server.

6. Stop loops and retries

Cap tool calls per conversation in your agent harness. Return a clear error and stop after two failed queries instead of letting the model rewrite the query five times. Log calls per task in production so a prompt change that doubles your calls shows up within a day.

Book a Stacksync demo to give agents one synced database

7. Serve heavy reads from a synced database

Most agent work is reading. Pipeline reviews, account research, churn scans, and "find every account where…" questions read far more records than they write. The hosted MCP also caps soqlQuery at 50,000 records per transaction and find at 2,000 records.

Agents read a synced Postgres copy of Salesforce with SQL while Stacksync keeps both in two-way sync
Reads from the database, writes through MCP or the sync
Per-app MCP servers compared with one synced database for AI agents
Per-app MCP vs one synced database

Instead, keep a copy of your Salesforce data in Postgres or a warehouse, and let agents query it with SQL:

Agent reads Salesforce over MCPAgent reads a synced database
HPIs per read1 or more per query0. The query never reaches Salesforce
Record limits50,000 per SOQL transaction, 2,000 per searchDatabase limits only
Joins with other systemsNot possible in one queryJoin CRM data with ERP, billing, and product data
WritesThrough MCP toolsWrite to the database and sync back, or call MCP for the write

Stacksync keeps Salesforce and your database in two-way sync, so a write in either system shows up in the other. It batches record changes and lets you set API rate ceilings per app, which keeps the sync itself inside your Salesforce API budget. See how the sync handles API limits, and our comparison of per-app MCP servers vs one synced database.

A caveat you must resolve. Salesforce says traditional, non-agentic integrations, such as a scheduled middleware sync, keep their current pricing. It hasn't published how it classifies integration traffic that an agent triggers indirectly, such as an agent writing to Postgres and a sync carrying the change to Salesforce. Ask your account executive for a written answer before you build pricing or contracts on this architecture.

Saves: every read the agent would otherwise make against Salesforce.

The optimized version of the example

StepUnoptimizedOptimized
Schema discovery3 calls0 (in prompt)
Find and read account, contacts, opportunities, activities5 calls1 combined SOQL, or 0 from the database
Update opportunity and create task2 calls1 Flow tool call
Total HPIs101 to 2

A rollout plan

  • 01This week: inventory every agent and MCP client in production and register them as Salesforce requires. Use our Agentic Identity checklist.
  • 02Next two weeks: measure calls per task in a sandbox for your top five workflows.
  • 03Next month: apply tactics 2 through 6, then re-measure.
  • 04Before metering: move read-heavy workflows to a synced database and set Digital Wallet alerts at your modeled monthly spend.

Sources

Start syncing with Stacksync

FAQ

Frequently asked questions

How do I reduce Salesforce MCP costs?
Reduce successful calls per task: cache schema, combine reads into one SOQL query, wrap writes in Flow tools, scope servers, cap retries, and serve heavy reads from a synced database.
Does reading Salesforce data from Postgres avoid HPI charges?
A query against your own database doesn't call Salesforce, so it creates no HPI. The sync that keeps the database current is integration traffic; confirm with Salesforce in writing how it classifies that traffic in your setup.
Do schema lookups count as billable calls?
Salesforce meters every successful call by a registered agent. A successful getObjectSchema call is a call.
Is it cheaper to call the Salesforce REST API directly than MCP?
No. Salesforce meters registered agent calls on both MCP and direct APIs.
What's the fastest win?
Moving schema into the prompt and combining reads into one SOQL query. Both need prompt changes only.

About the author

Ignacio Malpartida
Ignacio Malpartida
GTM Engineer

Ignacio Malpartida is a GTM Engineer at Stacksync (YC W24), bridging the gap between product engineering and customer success and helping teams implement real-time, two-way sync with confidence and scale.

All posts by Ignacio Malpartida

About Stacksync

Stacksync powers real-time, two-way sync between CRMs, ERPs, and databases. Engineers sync data at scale and automate workflows, not dirty API plumbing.

Coworkers laughing in front of a laptop in a casual office setting

You just read how it should work.
See it run on your own data.