Execute Anonymous Apex
apexlog_execute_anonymousExecute anonymous Apex in a Salesforce org and save the debug log for analysis. Manages trace flags and debug levels so you can profile performance and governor limits.
Instructions
Execute anonymous Apex in a Salesforce org as the targetOrg user; DML commits unless the run fails. Saves the debug log and returns its path for the analysis tools. With no active trace flag, adds one for the run, deleted after, and a debug level, left in the org.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apex | No | The anonymous Apex to execute, or use apexFilePath | |
| outputDir | No | Log directory (default: .apex-log-mcp/ in the first client root, else cwd) | |
| targetOrg | No | Alias or username of the target Salesforce org. Uses the project default if not specified. | |
| debugLevel | No | This run's log levels. Omit for the user's trace flag levels, else the defaults; "default" forces the defaults; a bare level sets every category; an object sets the named categories over the defaults. Defaults: apexCode, apexProfiling, visualforce, workflow FINE; callout, system, validation DEBUG; database FINEST; nba, wave INFO. | |
| apexFilePath | No | Absolute path to a file of anonymous Apex |