Skip to main content
Glama

Export query results

export_query_results
Read-only

Run SQL on one connection and return the whole result as a file body in CSV, JSON or XLSX. Use it when the user wants a file to download, attach or load into another tool, or needs more rows than execute_query returns (10000 at most). To read or analyse rows yourself, use execute_query instead: it is smaller and returns structured rows. For a recurring export to Google Sheets or Slack, use create_schedule. On PostgreSQL and MySQL, omitting limit exports every row the query returns, bounded only by the query timeout; other engines stop at 100000 rows. Always reads the database, never the result cache. Read-only: only a single SELECT, WITH or EXPLAIN statement is accepted. Refused on an approved_queries connection. Counts against the company's monthly query quota and a limit of 30 queries per minute (the team can set a lower one per connection). Needs the execute scope and a member role that can edit. CSV and JSON come back as text; XLSX comes back base64-encoded. The team can require a person to approve some requests: the call then fails with code APPROVAL_REQUIRED and an approvalUrl. Show the user that link, wait until they say it is approved, then repeat the exact same call with approvalId. An approval works once, for that SQL, within 30 minutes.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "connectionId": "<connectionId>",
      "sql": "<sql>",
      "format": "<format>"
    },
    "name": "export_query_results"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesThe SQL whose result to export, in the connection's own dialect.
limitNoMaximum rows, up to 100000. Omit on PostgreSQL and MySQL to export every row; other engines then default to 100000.
formatYescsv for spreadsheets and other tools, json for programs, xlsx for an Excel file (returned base64-encoded).
approvalIdNoOnly when repeating a call that came back with APPROVAL_REQUIRED, after the user approved it. Send the same arguments again.
connectionIdYesConnection id from list_connections.

Output Schema

NameRequiredDescriptionDefault
formatYes
contentYesThe file body: CSV or JSON text, or base64 for xlsx.
truncatedNoTrue when a row limit or memory cap cut the file short.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / properties / approvalId
      Added value: +{
      +  "description": "Only when repeating a call that came back with APPROVAL_REQUIRED, after the user approved it. Send the same arguments again.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / truncated
      Added value: +{
      +  "description": "True when a row limit or memory cap cut the file short.",
      +  "type": "boolean"
      +}
  2. Changed4 schema fields changed
    • changedInput schema / properties / format / description
      Previous value: -"File format of the export."New value: +"csv for spreadsheets and other tools, json for programs, xlsx for an Excel file (returned base64-encoded)."
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum rows. Omit on PostgreSQL and MySQL to export everything the query returns."New value: +"Maximum rows, up to 100000. Omit on PostgreSQL and MySQL to export every row; other engines then default to 100000."
    • changedInput schema / properties / limit / maximum
      Previous value: -9007199254740991New value: +100000
    • changedInput schema / properties / sql / description
      Previous value: -"The SQL whose result to export."New value: +"The SQL whose result to export, in the connection's own dialect."
  3. Changed2 schema fields changed
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / limit / maximum
      Added value: +9007199254740991
  4. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Goes far beyond readOnlyHint=true and openWorldHint=false: it discloses the single-statement restriction (SELECT/WITH/EXPLAIN only), refusal on approved_queries connections, monthly quota and a 30-per-minute rate limit that teams can lower, required execute scope and edit-capable member role, and the engine-dependent behaviour of an omitted limit. It also documents the APPROVAL_REQUIRED failure mode, the approvalUrl handoff, and that an approval is single-use for 30 minutes — exactly the kind of operational context annotations cannot carry.

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?

Long but dense: the core purpose and the file-vs-rows distinction come first, then alternatives, then limits/behaviour, then the approval flow. Each sentence carries operational information, and the few overlaps with the schema (limit defaults, format encodings) are minor reinforcement rather than padding.

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

Completeness5/5

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

Covers everything an agent needs for a read-only, quota-metered export tool with an approval branch: what is returned and in what encoding, what SQL is accepted, engine-specific row bounds, auth/role requirements, rate limits, and the exact recovery procedure for APPROVAL_REQUIRED. With an output schema present, it correctly omits detailed return-shape explanation.

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?

Schema coverage is 100%, so the schema already documents all five parameters including the engine-specific limit behaviour and the approvalId repeat-the-same-call rule. The description largely restates those facts (limit defaults, format encodings, approvalId usage) rather than adding new syntax or constraints, so it lands at the baseline for a fully documented 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?

States a specific verb and resource ('Run SQL on one connection and return the whole result as a file body in CSV, JSON or XLSX') plus the distinguishing scope: whole-result file output rather than rows. It explicitly contrasts with execute_query and create_schedule, so an agent can pick the right tool without opening a schema.

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?

Gives explicit when-to-use ('user wants a file to download, attach or load into another tool, or needs more rows than execute_query returns') and when-not with named alternatives: execute_query for reading/analysing rows, create_schedule for recurring exports to Sheets or Slack. Exclusions are concrete rather than implied.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources