apex-log-mcp
v2.1.0MCP server that analyzes Salesforce Apex debug logs for slow operations and governor limit usage, and runs Apex, fetches logs and sets trace flags in an org.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
apexlog_list_slow_operations List Slow Apex Log Operations
Rank what an Apex debug log spent its time on by self-execution time, or on the heap it retains - code units, methods, queries, searches, DML, callouts, flows and workflows in one table, each row with its calls, durations, database counts and rows, so the caller can see what to optimize and why, beside the query optimizer's plan for the queries among them.
| Parameter | Type | Description |
|---|---|---|
logFilePath * | string | Absolute path |
debugCategory | array | Rank only these debug log categories |
groupBy | string | Fold repeats into one row; default name. callerNamespace attributes platform DML to the package that drove it. debugCategory folds a namespace's event types together and so states no type or name. non… |
limit | integer | Page size (default: 10); fewer if the page would be too large |
minSelfMs | number | Drop operations below this self time (default: 0), whichever sortBy is used |
namespace | array | Rank only these namespaces |
offset | integer | Ranked rows to skip (default: 0): the last page's nextOffset |
sortBy | string | Default durationSelfMs. heapSelfNetBytes adds that column. |
type | array | Rank only these log event types, e.g. SOQL_EXECUTE_BEGIN, DML_BEGIN, METHOD_ENTRY |
apexlog_get_summary Get Apex Log Summary
Get a high-level summary of an Apex debug log: how long the transaction ran, where the time went by debug log category and the level each was logged at, every governor limit it and each namespace consumed, whether the log is complete, the exceptions and flow errors it raised, and what ended the transaction if it failed. Best for a quick overview.
| Parameter | Type | Description |
|---|---|---|
logFilePath * | string | Absolute path |
apexlog_list_limit_risks List Apex Log Limit Risks
List the governor limits an Apex log transaction has nearly used up - CPU time, heap, SOQL queries and rows, SOSL queries, DML statements and rows, callouts and every other limit - worst first, with how much of each was used
| Parameter | Type | Description |
|---|---|---|
logFilePath * | string | Absolute path |
threshold | number | Minimum usedPercentage to report (default: 80) |
apexlog_search_events Search Apex Log Events
Search the events of an Apex debug log in log order: what the code printed (USER_DEBUG), validation rules, statements, or every event under one method. For plain text in the saved .log, grep is cheaper; use this for event types, nesting, or without a shell. Text past 400 characters is elided; ask for one event by eventId to read up to 30,000.
| Parameter | Type | Description |
|---|---|---|
logFilePath * | string | Absolute path |
contains | string | Only events whose text holds this, ignoring case |
eventId | integer | Only this event, with more of its text |
limit | integer | Page size (default: 50) |
namespace | array | Only these namespaces |
offset | integer | Rows to skip (default: 0): the last page's nextOffset |
parentEventId | integer | Only events below this one |
type | array | Only these log event types, e.g. USER_DEBUG, VALIDATION_RULE |
apexlog_list_org_logs List Org Debug Logs
List the debug logs stored in a Salesforce org, with how many match. Pass ids to apexlog_get_org_logs to download them.
| Parameter | Type | Description |
|---|---|---|
cursor | string | nextCursor from the previous page |
limit | integer | Page size (default: 20) |
minFileSizeBytes | integer | |
operation | string | Part of the operation, any case, e.g. "aura" for /aura |
request | string | e.g. "Api" or "Application" |
sortBy | string | Descending (default: startTime) |
startTimeFrom | string | ISO 8601 with a zone, e.g. 2026-10-09T09:00:00Z |
startTimeTo | string | |
succeeded | boolean | true: succeeded logs only; false: failed logs only |
targetOrg | string | Alias or username of the target Salesforce org. Uses the project default if not specified. |
user | string | Username whose activity was logged |
apexlog_get_org_logs Get Org Debug Logs
Download debug logs from a Salesforce org, by id or the newest N, and return each saved file's path, which the analysis tools accept.
| Parameter | Type | Description |
|---|---|---|
ids | array | Log ids, from apexlog_list_org_logs |
latest | integer | The newest N logs, in place of ids (default: 1) |
outputDir | string | Log directory (default: .apex-log-mcp/ in the first client root, else cwd) |
targetOrg | string | Alias or username of the target Salesforce org. Uses the project default if not specified. |
apexlog_create_trace_flag Create Trace Flag
Trace a user, class or trigger in a Salesforce org until the trace flag expires. A user's flag stores each transaction they run as a debug log, which can fill log storage; a class or trigger flag only sets that code's levels. Refused if a flag of its log type overlaps the new one. Leaves a debug level in the org.
| Parameter | Type | Description |
|---|---|---|
tracedEntity * | string | A username or user id, or a class or trigger name (ns.Name if namespaced) |
debugLevel | A level for every category, or the named ones over apexlog_execute_anonymous's defaults (default: those) | |
durationMinutes | integer | How long it logs (default: 30) |
targetOrg | string | Alias or username of the target Salesforce org. Uses the project default if not specified. |
apexlog_execute_anonymous Execute Anonymous Apex
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.
| Parameter | Type | Description |
|---|---|---|
apex | string | The anonymous Apex to execute, or use apexFilePath |
apexFilePath | string | Absolute path to a file of anonymous Apex |
debugLevel | 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.… | |
outputDir | string | Log directory (default: .apex-log-mcp/ in the first client root, else cwd) |
targetOrg | string | Alias or username of the target Salesforce org. Uses the project default if not specified. |