Skip to main content
Glama
aaron-pienza

Salesforce MCP Server

by aaron-pienza

salesforce_query_records

Query records from any Salesforce object using SOQL, with support for parent-to-child and child-to-parent relationship queries. Paginate through results with limit and offset.

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.

Pagination: Results default to 200 records per page. Use limit and offset to page through results. Response includes total record count and next offset. Note: Pages are not snapshot-consistent — if data changes between requests, records may shift. For stable pagination, add a deterministic WHERE clause (e.g., WHERE CreatedDate < 2026-04-07T00:00:00Z ORDER BY Id).

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'"

  5. Paginate through results:

    • objectName: "Account"

    • fields: ["Name"]

    • limit: 50

    • offset: 100

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 (default 200)
offsetNoNumber of records to skip for pagination (default 0, max 2000)
Behavior4/5

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

Describes pagination behavior (default 200, limit/offset, not snapshot-consistent, stable pagination advice) and relationship query syntax. No annotations provided, so description carries burden; could mention read-only nature but covers key behaviors.

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?

Well-structured with brief intro, note on alternative, pagination details, examples, and syntax notes. Front-loaded with purpose. Could be slightly more concise but every part adds value.

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?

Covers input thoroughly but lacks explicit description of return format (though mentions total record count and next offset). No output schema; for a query tool, typical Salesforce response is expected but not documented.

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 has 100% coverage with descriptions, but description adds practical examples for each parameter (e.g., whereClause with relationships, limit/offset for pagination). Adds value 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?

Description clearly states it queries records from any Salesforce object using SOQL, including relationship queries. It distinguishes itself from sibling tool salesforce_aggregate_query by specifying when to use that instead.

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?

Explicitly states when not to use this tool (for GROUP BY, aggregate functions, HAVING) and directs to salesforce_aggregate_query. Provides pagination guidance and relationship query usage notes.

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