- DATA
- ADMIN
- TEST
- HUMAN
Short answer
Can I run Apex via my AI client?
Yes. You can send Apex code to Salesforce to run as an anonymous block. This lets you handle data updates and admin tasks through your agent. Here is how it works.
The outcomes
What you get done
The AI handles the execution while you control the logic.
DATA
Clean up records
The AI executes scripts to update fields or fix bulk data errors. You get the results of the execution immediately in your chat.
ADMIN
Manage settings
Run code to change organizational configurations or user permissions. It bypasses the need to click through complex setup menus.
TEST
Verify logic
The AI runs small snippets of code against your live data to see how they behave. You see the success or error messages right away.
HUMAN
Review code
The AI drafts the script based on your request, but you decide when to run it. You stay in the loop for every change made to the org.
The workflow
What your AI does when you request a script.
The AI acts as the bridge between your natural language and the Salesforce runtime.
Draft the script
Your AI writes the specific Apex code needed to fulfill your request.
sf_execute_apexSend to Salesforce
The AI sends the code block to your Salesforce instance for execution.
sf_execute_apexProcess execution
Salesforce runs the code in the current context and returns the outcome.
sf_execute_apexReport results
The AI reads the response from the system and tells you if the script worked or why it failed.
sf_execute_apex
Try it
Copy these to start.
Paste these into your chat to begin.
Starting points
Replace the object and field names with the ones used in your specific Salesforce org.
Salesforce Connector
You're all set. Choose your MCP client and follow the setup instructions.
https://edge.vinkius.com/vk_preview_dXvoArPaPUkxjgPIyVRNAViK8yMiulYVKtQj5F9V/mcpClaude Desktop
Follow the steps below to connect in seconds.
- 1In Claude Desktop, open Settings → Connectors.
- 2Click “Add custom connector” and paste the connector link above as the remote MCP server URL.
- 3Click Add and start a new chat — Salesforce capabilities are ready to use.
{
"mcpServers": {
"salesforce-admin-metadata-mcp": {
"url": "https://edge.vinkius.com/vk_preview_dXvoArPaPUkxjgPIyVRNAViK8yMiulYVKtQj5F9V/mcp"
}
}
}Run an anonymous Apex script to update all Account names containing 'Test' to 'Legacy Account'.
Execute Apex to find all Contacts without an Email address and set their status to 'Invalid'.
Run this Apex snippet to delete all Task records created yesterday: [paste code here]
Write and run an Apex script to change the OwnerId of all Open Opportunities to a specific User ID.
Claude
ChatGPT
Cursor
VS Code
Windsurf
Claude Code
JetBrains
Cline
Start here
Connect Salesforce Admin & Metadata once, then ask.
Link your account once and your credentials stay encrypted on our side. You can then use any compatible client to run your scripts.
Connect Salesforce Admin & Metadata to your AIFAQ
How the task behaves
- 01
Does the AI run code automatically?
No. The AI drafts the script, but you must review it and tell the agent to execute it.
- 02
Can the AI delete my data?
Yes. If you ask the AI to run a script that includes a delete command, it will execute that command in Salesforce.
- 03
Can I run scheduled Apex jobs?
No. This tool is only for running anonymous Apex blocks.
- 04
Does it work with the Developer Console?
It provides an alternative to the Developer Console, allowing you to run code from your AI client instead.
- 05
Can the AI create new Apex classes?
No. The tool is limited to executing anonymous Apex code.
More questions about Salesforce Admin & Metadata? The Connector page answers them. See everything the Salesforce Admin & Metadata Connector can do
Connect Salesforce to Claude, Cursor, ChatGPT & more
