Skip to main content
Glama
advancedcommunities

Salesforce MCP Server

query_records_to_file

Read-only

Execute SOQL queries on Salesforce SObjects and save the results to CSV or JSON files for export or analysis.

Instructions

Query records from a Salesforce SObject and save to a file. This command allows you to execute a SOQL query against a specified Salesforce SObject in a given Org and save the results to a file. You can specify the SELECT clause (fields, functions like COUNT(), aggregations, etc.), an optional WHERE clause, and save the results in various formats. The results can be saved in CSV format by default, or in other formats if specified. IMPORTANT: Always execute the sobject_list tool first to understand which objects are available in the org, and optionally execute sobject_describe for the specific SObject to understand its fields and structure before querying.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.7.0

TDQS

A3.9/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, and openWorldHint=true, so the safety profile is covered. The description adds that the operation writes a file (a side effect not captured by annotations) and that CSV is the default format, but omits where files land and whether an existing file is overwritten — notable for a file-writing tool.

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

Conciseness3/5

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

The core purpose is front-loaded, but the text repeats itself — 'save the results to a file' is restated twice and CSV-default is stated redundantly with the schema default. Several sentences could be merged without loss.

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?

With no output schema, the description should clarify what the call returns (a path, a summary, a confirmation) — it does not, saying only that results are saved. Prerequisites and format options are well covered, but the post-write behavior and file destination are left unspecified for a tool whose whole point is producing a file.

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 description coverage is reported at 0% for the single top-level 'input' parameter, so the description must compensate, and it does: it explains the SELECT clause can hold fields, functions like COUNT(), and aggregations, that WHERE is optional, and that format defaults to CSV. It covers the main nested fields but does not mention orderBy, targetOrg, or outputFileName.

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?

States a specific verb+resource+terminal action: query a Salesforce SObject and save to a file. This distinguishes it from the sibling query_records, which returns results rather than persisting them. An agent can tell what it produces without opening the schema.

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

Usage Guidelines4/5

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

Explicitly instructs running sobject_list first and optionally sobject_describe before querying, which is real prerequisite guidance. It does not, however, state when to prefer this over the sibling query_records or search_records, so the routing choice between query tools is left implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.