Skip to main content
Glama

execute_query

Read-only

Run SELECT-only SQL queries against a Metabase database to fetch data, with support for row limits, pagination, and column selection.

Instructions

Execute a SQL query (SELECT statements only)

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": {
      "database_id": "<database_id>",
      "sql": "<sql>"
    },
    "name": "execute_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL query (SELECT statements only)
limitNoMax rows to return (default: server maxRows setting)
fieldsNoColumn names to include in results (default: all)
formatNoResponse format (default: compact). Use "default" for pretty-printed output
offsetNoRow offset for pagination
database_idYesDatabase ID to query

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.7.0
    • removedInput schema / additionalProperties
      Removed value: -false
  2. Changed4 schema fields changedv1.3.0
    • addedInput schema / properties / fields
      Added value: +{
      +  "description": "Column names to include in results (default: all)",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / format
      Added value: +{
      +  "description": "Response format (default: compact). Use \"default\" for pretty-printed output",
      +  "enum": [
      +    "default",
      +    "compact"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / limit
      Added value: +{
      +  "description": "Max rows to return (default: server maxRows setting)",
      +  "maximum": 10000,
      +  "minimum": 1,
      +  "type": "number"
      +}
    • addedInput schema / properties / offset
      Added value: +{
      +  "description": "Row offset for pagination",
      +  "minimum": 0,
      +  "type": "number"
      +}
  3. First observedv1.1.1

TDQS

B3.2/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true and openWorldHint=true, and the SELECT-only note is consistent with that read-only profile rather than contradicting it. Beyond that the description adds nothing: no disclosure of row caps, timeouts, cost, or what happens if a non-SELECT statement is submitted.

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?

A single front-loaded sentence with no filler, which is appropriate. The parenthetical duplicates the sql field's schema description, a small redundancy that keeps it from being maximally efficient.

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?

For a 6-parameter query tool with pagination, formatting options, and a batch sibling, the description is thin — it omits result-size behavior and the batch-vs-single choice. The rich schema and readOnly annotation cover much of the burden, so it is minimally viable rather than inadequate.

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 description coverage is 100%, so every parameter (sql, limit, offset, fields, format, database_id) is already documented in structured form with defaults and bounds. The description's parenthetical merely restates the sql parameter's own description, adding no new semantics; baseline 3 applies.

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?

"Execute a SQL query" gives a specific verb and resource, and "(SELECT statements only)" narrows scope to read-only queries. It stops short of distinguishing this tool from siblings like batch_execute or execute_card, so an agent must infer the boundary.

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 only guidance is the SELECT-only restriction, which is a constraint rather than a when-to-use rule. Nothing says when to prefer this over batch_execute, or that database_id should come from list_databases/get_database_schema, and no exclusions or prerequisites are stated.

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