Skip to main content
Glama

db_query

Read-onlyIdempotent

Query discovered PostgreSQL, MySQL, or SQLite databases read-only. Obtain a connectionId with inspect_project, then run validated SELECT, WITH, or EXPLAIN statements; writes, functions, and unbounded executions are blocked.

Instructions

Read-only query of a discovered PostgreSQL, MySQL or SQLite database. First call inspect_project for a connectionId. Supports validated SELECT, read-only WITH and EXPLAIN SELECT, including metadata tables. Writes, arbitrary functions, multi-statements, comments and execution modifiers are rejected. Credentials remain inside the server. Rows and execution time are bounded.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
maxRowsNo
connectionIdYes

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?

Beyond the readOnlyHint and idempotentHint annotations, the description discloses concrete behavioral constraints: only validated SELECT, read-only WITH, EXPLAIN SELECT, and metadata tables are allowed; writes, arbitrary functions, multi-statements, comments, and execution modifiers are rejected. It also states that credentials remain on the server and that rows and execution time are bounded.

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?

The description is compact and information-dense, with no filler. It front-loads the core purpose, then provides prerequisite, allowed/rejected behavior, security, and bounds in a logical order, and every sentence adds value.

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?

For a read-only database query tool with rich annotations, the description covers prerequisite discovery, accepted SQL constructs, rejected inputs, security posture, and bounded execution. This is sufficient for an agent to invoke it correctly without an output schema.

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?

The description gives meaningful semantics for connectionId by saying to obtain it from inspect_project, and for query by describing supported and rejected SQL. However, maxRows is not explicitly described, and with 0% schema description coverage the description carries the burden for all parameters; the phrase 'Rows and execution time are bounded' only partially compensates.

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?

The description states a specific verb and resource: 'Read-only query of a discovered PostgreSQL, MySQL or SQLite database.' It clearly distinguishes this from sibling tools like http_request, git_status, and inspect_project by scoping it to database queries.

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?

It explicitly instructs the agent to call inspect_project first for a connectionId, which is a clear usage prerequisite. It also describes what SQL forms are allowed and rejected, but it does not explicitly name alternative tools for cases where db_query is not appropriate.

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