Skip to main content
Glama
tsmztech

Salesforce MCP Server

salesforce_query_records

Query Salesforce records using SOQL to retrieve data from any object, including parent-child relationships and related object filtering.

Instructions

Query records from any Salesforce object using SOQL, including relationship queries.

NOTE: For queries with GROUP BY, aggregate functions (COUNT, SUM, AVG, etc.), or HAVING clauses, use salesforce_aggregate_query instead.

Examples:

  1. Parent-to-child query (e.g., Account with Contacts):

    • objectName: "Account"

    • fields: ["Name", "(SELECT Id, FirstName, LastName FROM Contacts)"]

  2. Child-to-parent query (e.g., Contact with Account details):

    • objectName: "Contact"

    • fields: ["FirstName", "LastName", "Account.Name", "Account.Industry"]

  3. Multiple level query (e.g., Contact -> Account -> Owner):

    • objectName: "Contact"

    • fields: ["Name", "Account.Name", "Account.Owner.Name"]

  4. Related object filtering:

    • objectName: "Contact"

    • fields: ["Name", "Account.Name"]

    • whereClause: "Account.Industry = 'Technology'"

Note: When using relationship fields:

  • Use dot notation for parent relationships (e.g., "Account.Name")

  • Use subqueries in parentheses for child relationships (e.g., "(SELECT Id FROM Contacts)")

  • Custom relationship fields end in "__r" (e.g., "CustomObject__r.Name")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectNameYesAPI name of the object to query
fieldsYesList of fields to retrieve, including relationship fields
whereClauseNoWHERE clause, can include conditions on related objects
orderByNoORDER BY clause, can include fields from related objects
limitNoMaximum number of records to return
Behavior4/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 does well by explaining relationship query syntax (dot notation for parent relationships, subqueries for child relationships, custom field conventions), which is crucial behavioral context beyond basic parameter documentation. However, it doesn't mention rate limits, authentication requirements, or pagination behavior, which would be helpful for a query 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?

The description is well-structured with clear sections: purpose statement, important note about alternatives, and detailed examples. While comprehensive, some sentences could be more concise (e.g., the relationship field explanations are somewhat verbose). The front-loaded purpose statement is effective, but the overall length is substantial for a tool description.

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?

For a query tool with 5 parameters, 100% schema coverage, but no annotations or output schema, the description provides good contextual completeness. The examples cover multiple common use cases and relationship patterns, and the guidance about when to use the alternative tool is valuable. However, without an output schema, some information about return format would be helpful.

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%, so the schema already documents all 5 parameters thoroughly. The description adds value through examples that illustrate how parameters work together (especially fields with relationship syntax and whereClause with related objects), but doesn't provide additional semantic information beyond what the schema descriptions already cover.

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 ('Query records from any Salesforce object using SOQL') and resources ('Salesforce object'). It explicitly distinguishes from its sibling salesforce_aggregate_query by noting what types of queries should use that alternative instead, providing clear differentiation.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when NOT to use this tool (for queries with GROUP BY, aggregate functions, or HAVING clauses) and names the specific alternative tool (salesforce_aggregate_query). It also provides contextual guidance about relationship query patterns through the examples, helping users understand appropriate use cases.

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

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