Skip to main content
Glama
simonl77

Salesforce MCP Server

by simonl77

salesforce_write_apex

Create or update Apex classes in Salesforce to implement custom business logic and automate processes within the CRM platform.

Instructions

Create or update Apex classes in Salesforce.

Examples:

  1. Create a new Apex class: { "operation": "create", "className": "AccountService", "apiVersion": "58.0", "body": "public class AccountService { public static void updateAccounts() { /* implementation */ } }" }

  2. Update an existing Apex class: { "operation": "update", "className": "AccountService", "body": "public class AccountService { public static void updateAccounts() { /* updated implementation */ } }" }

Notes:

  • The operation must be either 'create' or 'update'

  • For 'create' operations, className and body are required

  • For 'update' operations, className and body are required

  • apiVersion is optional for 'create' (defaults to the latest version)

  • The body must be valid Apex code

  • The className in the body must match the className parameter

  • Status information is returned after successful operations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesWhether to create a new class or update an existing one
classNameYesName of the Apex class to create or update
apiVersionNoAPI version for the Apex class (e.g., '58.0')
bodyYesFull body of the Apex class
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context about required/optional parameters for different operations, validation rules (e.g., body must be valid Apex code, className must match), and that status information is returned. However, it doesn't cover important behavioral aspects like error handling, permissions needed, or whether operations are reversible/destructive.

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 appropriately sized and front-loaded with the core purpose. The examples and notes are well-organized and add necessary detail without redundancy. However, some information in the notes (e.g., 'operation must be either create or update') is already implied by the enum in the schema, making it slightly less efficient than ideal.

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?

Given the complexity of a write operation with no annotations and no output schema, the description is moderately complete. It covers the basic operations, parameters, and validation rules but lacks details on error responses, authentication requirements, rate limits, or what specific 'status information' is returned. For a mutation tool without structured safety hints, more behavioral context would be beneficial.

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?

The schema description coverage is 100%, so the baseline is 3. The description adds significant value beyond the schema by clarifying parameter semantics through examples and notes: it explains when apiVersion is optional (defaults to latest), distinguishes required parameters for create vs. update operations, and provides validation rules for body and className matching. This compensates well for the schema's basic descriptions.

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 the tool's purpose with specific verbs ('Create or update') and resource ('Apex classes in Salesforce'). It distinguishes itself from sibling tools like salesforce_read_apex (read vs. write) and salesforce_write_apex_trigger (classes vs. triggers), making the scope unambiguous.

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 provides implied usage guidance through examples and notes (e.g., operation must be 'create' or 'update'), but it lacks explicit guidance on when to use this tool versus alternatives like salesforce_dml_records or salesforce_execute_anonymous. No when-not-to-use scenarios or prerequisites are mentioned.

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/simonl77/mcp-server-salesforce'

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