Skip to main content
Glama
smn2gnt

MCP Salesforce Connector

by smn2gnt

run_soql_query

Execute SOQL queries to retrieve Salesforce data efficiently using the MCP Salesforce Connector, enabling direct interaction with Salesforce records for streamlined data access.

Instructions

Executes a SOQL query against Salesforce

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SOQL query to execute

Implementation Reference

  • The handler logic within the call_tool function that parses the query argument, executes it using the Salesforce client's query_all method, and returns the results as formatted 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)}",
            )
        ]
  • The registration of the 'run_soql_query' tool in the list_tools handler, including its name, description, and input schema requiring a 'query' string.
    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"],
        },
    ),
  • The JSON schema definition for the input arguments of the 'run_soql_query' tool, specifying an object with a required 'query' string property.
        "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 offers minimal information. It states the action is an execution but doesn't cover permissions needed, rate limits, query result formats, pagination, error handling, or whether this is a read-only or mutating operation. The description is technically accurate but lacks operational context.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded with the core action and target, making it easy to parse quickly. Every word earns its place in conveying the essential purpose.

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?

Given the complexity of executing queries in Salesforce (with potential for large datasets, permissions, and system limits), the description is incomplete. No annotations exist to cover behavioral aspects, and there is no output schema to describe return values. The description fails to address critical context like result formatting, error cases, or usage constraints, leaving significant gaps for an agent.

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' clearly documented in the schema. The description adds no additional parameter semantics beyond what the schema already provides, such as SOQL syntax examples, validation rules, or query length limits. The baseline score of 3 reflects adequate but minimal value addition.

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 ('a SOQL query against Salesforce'), making the purpose immediately understandable. It distinguishes this from non-query siblings like create_record or update_record, though it doesn't explicitly differentiate from similar query tools like run_sosl_search.

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 on when to use this tool versus alternatives like run_sosl_search, apex_execute, or restful. It doesn't mention prerequisites, limitations, or typical use cases, leaving the agent to infer usage from the tool name alone.

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

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

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