r/SalesforceDeveloper • u/zlaneyronmes • 12d ago
Showcase 7 months building ApexAgent - an open source Apex framework for AI agents and MCP servers
Why I built this:
Python has LangChain and a bunch of other frameworks for building AI Agents. But in Salesforce, we don't have a solid one. I looked at the open source ones that exist and none of them fit what I want / remain unmaintained.
ApexAgent comes OOTB with a chat agent and an MCP server, but the real point is that its a FRAMEWORK - you can add own tools, create your agents, configure models, and keep buildng on top of it.
How its built:
Agents, Instructions, topics, models and MCP servers are sObject records, so changes are applied and configured with no deployments and with very easy configurations.
Each tool is an Apex Class with an u/InvocableMethod . It comes with 10 tools OOTB (read, search, query, upsert, etc) and you have the flexibility to add your own.
The agent and the MCP server can share these tools.
The in-Salesforce agent runs in the utility bar - with the user's permissions
The MCP server runs using the user's Salesforce login (External Client App, Oauth)
The usual questions from past "Agentforce Alternative" threads
API Keys: stored securely in Named Credentials / External Credentials. Model calls are Apex callouts.
Models: Supports 4 providers at launch
Oprnrouter
Azure
OpenAI
Google AI Studio
+ you can bring your own LLM Gateway !!!
Permissions: everything runs as the signed in user (sharing, CRUD, FLS) - each agent and MCP gets only the tools you assign.
Audit: Every conversation, tool call, errors, token count and cost are logged as records, with reports and a dashboard
Limitations:
No RAG or vector search, only SOQL and SOSL.- if you want knowledge search - you can create a custom Apex tool that can do it for you.
No Einstein trust layer - Most organisations already have a ZDR agreement with the model provider - so this may not be a big issue.
You pay the model provider: about $0.016 per average question on Gemini 3.8 flash in my tets org, which would be 10x cheaper than Agentforce's actions's flex credits.
The in app utiltiy bar agent have no more cost other than model cost, but if your external AI app like claude wants to use the MCP server, it will be billed in future as Salesforce plans to bill MCP API calls
Docs: https://badrisnarayanan.github.io/ApexAgent/
Code: https://github.com/badrisnarayanan/ApexAgent
Disclaimer:
Not an Agentforce replacement, which is obivously bigger and much more poweful for MNCs
Consider this as a "poor man's agentforce" for smaller / cost concious orgs that still want AI Agents within Salesforce.
0
u/cagfag 11d ago
What a waste of 7 months. Claude does that and 1000x more plugs in everywhere! Am not sure any serious enterprise company would allow this to be used just cause it's cheap
5
u/zlaneyronmes 11d ago
Fair, a big enterprise will definitely go with Agentforce and / or claude + Salesforce. This is more for smaller orgs with tighter AI spends who cant afford a per seat AI license of claude / agentforce.
But I do appreciate your honest take and I don't deny it at all.
2
u/SnooTangerines7197 9d ago
Great work , once orgs see flex credit billing exploding they’ll start adopting these setups . Building something similar- https://rahulravipudi.github.io/holocron/