Skip to main content
Glama
aaron-pienza

Salesforce MCP Server

by aaron-pienza

salesforce_execute_anonymous

Run anonymous Apex code in Salesforce to test logic, debug, or perform unsupported data operations.

Instructions

Execute anonymous Apex code in Salesforce.

Examples:

  1. Execute simple Apex code: { "apexCode": "System.debug('Hello World');" }

  2. Execute Apex code with variables: { "apexCode": "List accounts = [SELECT Id, Name FROM Account LIMIT 5]; for(Account a : accounts) { System.debug(a.Name); }" }

  3. Execute Apex with debug logs: { "apexCode": "System.debug(LoggingLevel.INFO, 'Processing accounts...'); List accounts = [SELECT Id FROM Account LIMIT 10]; System.debug(LoggingLevel.INFO, 'Found ' + accounts.size() + ' accounts');", "logLevel": "DEBUG" }

Notes:

  • The apexCode parameter is required and must contain valid Apex code

  • The code is executed in an anonymous context and does not persist

  • The logLevel parameter is optional (defaults to 'DEBUG')

  • Execution results include compilation success/failure, execution success/failure, and debug logs

  • For security reasons, some operations may be restricted based on user permissions

  • This tool can be used for data operations or updates when there are no other specific tools available

  • When users request data queries or updates that aren't directly supported by other tools, this tool can be used if the operation is achievable using Apex code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apexCodeYesApex code to execute anonymously
logLevelNoLog level for debug logs (optional, defaults to DEBUG)
Behavior4/5

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

With no annotations, the description carries full burden. It discloses that code executes anonymously and does not persist, debug logs are optional, and results include compilation/execution status. It implies DML effects ('data operations or updates') but does not explicitly state that data changes persist, which is a minor gap.

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?

The description is well-structured with examples and notes, but slightly verbose. It earns its length by covering usage, parameters, and behavior, though it could be slightly trimmed without losing clarity.

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

Completeness4/5

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

Given no output schema, the description explains return values (execution results, debug logs). Parameters are fully covered. It could elaborate on error types or detailed restrictions, but overall provides sufficient context for a complex tool.

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

Parameters4/5

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

Schema coverage is 100%, baseline 3. Description adds value by providing examples, noting apexCode must be valid Apex, and explaining the optional logLevel defaults to DEBUG, which enhances understanding beyond schema.

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

Purpose5/5

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

The description clearly states 'Execute anonymous Apex code in Salesforce' with multiple examples and explicitly distinguishes this tool as a fallback when no other specific tool supports the user's request. It covers both data queries and updates.

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

Usage Guidelines4/5

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

The description advises using this tool for operations not supported by other tools and explains the anonymous context and security restrictions. However, it does not explicitly list when not to use it, but the fallback guidance is clear.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aaron-pienza/mcp-server-salesforce'

If you have feedback or need assistance with the MCP directory API, please join our Discord server