Execute Anonymous Apex
apexlog_execute_anonymousExecute anonymous Apex against a Salesforce org, save the debug log locally, and return a summary with the file path for analysis tools.
Instructions
Execute a snippet of anonymous Apex against an authenticated Salesforce org (via SF CLI). Saves the resulting debug log to a local file and returns a summary with the file path, which the analysis tools accept. Production orgs require per-call user confirmation or the --allow-production-orgs server flag.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apex | Yes | The anonymous Apex to be executed | |
| outputDir | No | Directory to save the debug log file. Defaults to .apex-log-mcp/ in the project root. | |
| targetOrg | No | Alias or username of the target Salesforce org. Uses the project default if not specified. | |
| debugLevel | No | Trace flag log levels. "default" restores the defaults; a bare level sets every category to it; an object sets only the categories named and leaves the rest unchanged. Defaults: apexCode, apexProfiling, visualforce, workflow FINE; callout, system, validation DEBUG; database FINEST; nba, wave INFO. |