Skip to main content
Glama
salesforce-mcp

salesforce-mcp

by uoparaji

salesforce_execute_apex

Run anonymous Apex code against a Salesforce org in system context, use System.debug() to inspect results, and return the debug log output.

Instructions

Execute anonymous Apex code on the Salesforce org. The code runs in a system context. Use System.debug() to output results. Returns the debug log output.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "salesforce_execute_apex"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe anonymous Apex code to execute. Use System.debug() to output data you want to inspect.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It usefully discloses that the code runs in a system context (elevated privileges) and that the return value is the debug log, but it omits whether DML commits or rolls back, governor/CPU limits, and permission requirements — significant gaps for an arbitrary-code-execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, front-loaded with the action and followed by the two facts an agent most needs (execution context and how to get output). 'Returns the debug log output' mildly restates the System.debug() sentence but is not wasteful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a one-parameter tool with no output schema or annotations, the description covers what it does, the execution context, and the return channel. It stops short of the safety and limit information an agent needs before running arbitrary code that can mutate org data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single 'code' parameter, so the baseline is 3. The description's System.debug() hint adds a little meaning beyond the schema, but the schema already says the same thing, so no extra credit is warranted.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Execute anonymous Apex code on the Salesforce org'), which no sibling tool plausibly duplicates — salesforce_rest_api and salesforce_query operate on different surfaces. It is clear what the tool does, though it does not explicitly name which sibling to prefer when Apex is not required.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description tells the agent how to retrieve results ('Use System.debug()') but never when this tool is the right choice versus salesforce_rest_api or the query tools. Usage is implied by the nature of Apex execution rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.