Skip to main content
Glama

run_soql_query

Execute SOQL queries to retrieve Salesforce data for analysis, reporting, or integration purposes.

Instructions

Executes a SOQL query against Salesforce

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SOQL query to execute

Implementation Reference

  • Handler logic for the run_soql_query tool: extracts query argument, executes sf_client.sf.query_all, formats results as JSON text content.
    if name == "run_soql_query":
        query = arguments.get("query")
        if not query:
            raise ValueError("Missing 'query' argument")
    
        results = sf_client.sf.query_all(query)
        return [
            types.TextContent(
                type="text",
                text=f"SOQL Query Results (JSON):\n{json.dumps(results, indent=2)}",
            )
        ]
  • Registration of run_soql_query tool in list_tools(), including name, description, and inputSchema.
    types.Tool(
        name="run_soql_query",
        description="Executes a SOQL query against Salesforce",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The SOQL query to execute",
                },
            },
            "required": ["query"],
        },
    ),
  • JSON Schema for run_soql_query input: requires 'query' string.
    inputSchema={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The SOQL query to execute",
            },
        },
        "required": ["query"],
    },
Behavior2/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 but provides minimal information. It doesn't mention whether this is a read-only operation (likely, but not stated), what permissions are required, whether there are query limits or performance considerations, what happens with malformed queries, or what the return format looks like. For a query execution tool with zero annotation coverage, this is insufficient.

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

Conciseness5/5

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

The description is maximally concise with a single sentence that directly states the tool's function. There's zero wasted language, no redundancy, and the core purpose is communicated immediately without unnecessary elaboration.

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

Completeness2/5

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

For a query execution tool with no annotations and no output schema, the description is inadequate. It doesn't explain what SOQL is (versus SOSL), what the expected return format is, whether there are limitations on query complexity or result size, what authentication is required, or how this differs from other Salesforce query methods. Given the complexity of Salesforce data access and the presence of multiple sibling tools, more context is needed.

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?

The schema description coverage is 100% with the single parameter 'query' well-documented in the schema. The description doesn't add any parameter information beyond what the schema already provides (no examples of valid SOQL syntax, no constraints on query complexity, no field/object requirements). With complete schema coverage, the baseline score of 3 is appropriate.

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?

The description clearly states the action ('Executes') and target resource ('SOQL query against Salesforce'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'run_sosl_search' which also executes queries against Salesforce, or from 'restful' which might also execute queries, so it doesn't achieve full sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance about when to use this tool versus alternatives. With multiple sibling tools that interact with Salesforce data (create_record, delete_record, get_record, update_record, run_sosl_search, apex_execute, tooling_execute), there's no indication whether SOQL is preferred for certain query types, whether it has different performance characteristics, or what distinguishes it from SOSL searches.

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/leilaabdel/MCP-Salesforce'

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