Skip to main content
Glama

Query the database

db_query
Destructive

Run SQL on the project's PostgreSQL 19 (env preview by default, or production: the live site's real data). Reads run directly, on production in a read-only transaction with a 5-second limit, and the result says it is live data. A statement that writes runs on preview after an automatic snapshot; on production it needs the db:production permission and confirm: true, and one that drops, truncates or alters, or updates or deletes without a WHERE clause (or about a thousand rows or more), waits for the owner's approval in the portal first. Prefer migration files (db migrate) for schema changes. Results are capped (max_rows, default 100); values come back as text. For a SELECT use db_read.

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": {
      "project": "<project>",
      "sql": "<sql>"
    },
    "name": "db_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
envNopreview
sqlYes
confirmNo
projectYesProject slug or id.
max_rowsNo
idempotency_keyNoAny unique string; a repeated call with the same key has no second effect.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Goes well beyond the annotations: read-only transaction and 5-second limit on production, automatic snapshot before preview writes, owner approval gating for DROP/TRUNCATE/ALTER or unbounded UPDATE/DELETE and large affected-row counts, and a capped result set with text values. The annotations (readOnlyHint=false, destructiveHint=true) are consistent with a tool that reads by default but can mutate. The only omission is that idempotency_key behavior is not described here.

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?

Dense but front-loaded: the core action, environment default, and safety model come first, with routing advice and result limits at the end. The single long paragraph could be split into scenario bullets for faster scanning, but no sentence is filler.

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 does cover result shape (capped rows, text values, live-data marker), which is important. However, a six-parameter destructive-capable tool leaves idempotency_key behavior and error/denial outcomes unaddressed, so a caller still has gaps to fill.

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 coverage is 33%, but the description compensates substantially by explaining env's default and semantics, confirm's role for production writes, and max_rows' default of 100 and cap. The idempotency_key parameter is left unexplained in the description and only lightly described in the 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 the project's PostgreSQL 19') with scope (preview vs production) and explicitly separates SELECT work to db_read, so the agent can choose between siblings without opening schemas.

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 routing: use db_read for SELECT, prefer migration files (db migrate) for schema changes, and production writes need db:production plus confirm: true. It also names the default env, so the agent knows what happens when env is omitted.

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