Skip to main content
Glama

db_query

Run a pre-approved named query against an allow-listed PostgreSQL, MySQL, or Redis preset, returning rows as JSON. SQL is fixed at preset definition time, so arbitrary queries are blocked.

Instructions

Run a NAMED QUERY against a database preset (PostgreSQL, MySQL, or Redis). You supply query_name (must match one declared in the preset) and params (positional). The SQL / command is FIXED at preset definition time — you cannot send arbitrary SQL. Returns rows as JSON. Approval prompt fires per the preset's policy. If the user previously approved a time-boxed window for this preset+action, the call proceeds without a new prompt and is recorded as 'windowed' in the audit log.

Input Schema

NameRequiredDescriptionDefault
paramsNoPositional parameters; types must match the named query's `param_types`.
query_nameYesMust match one of the preset's declared `queries[].name`.
preset_nameYes

Output Schema

NameRequiredDescriptionDefault
rowsYes
rows_affectedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: it discloses that the SQL is fixed at preset definition time, that an approval prompt fires per policy, that a previously approved time-boxed window bypasses the prompt and is logged as 'windowed', and that results come back as JSON rows. These are non-obvious side effects an agent must know before calling.

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?

The critical constraint (named query only, no arbitrary SQL) is front-loaded and the return format follows. The closing sentence on the pre-approved window is longer than needed but conveys a real behavioral difference rather than filler.

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

Completeness4/5

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

Return values are covered by the output schema and the approval/audit behavior is explained in prose, so the main gaps are covered. The one omission is a definition of preset_name and where presets come from, which matters for a three-parameter tool.

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 only 67%, and the description compensates by explaining that query_name must match a preset-declared name and that params are positional with types matching the named query's param_types. The remaining undocumented parameter, preset_name, is left implicit — the agent can infer it but it is never defined.

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 a NAMED QUERY against a database preset') and immediately bounds the scope with 'you cannot send arbitrary SQL'. This distinguishes it from a generic SQL tool and from siblings like list_presets or proxy_http without needing their schemas.

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?

Clearly establishes the precondition that query_name must match one declared in the preset, and explains the approval flow that governs invocation. It stops short of explicitly routing the agent to a sibling (e.g. list_presets to discover query names) or stating when another tool such as proxy_http would be preferred.

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