Skip to main content
Glama
codedb-io

codeDB Lens

Official

query

Read-only

Run one read-only SELECT or WITH statement against a saved SQL Server or PostgreSQL profile to return columns and rows, using SQL aggregation to stay within per-profile row and cell limits.

Instructions

Run one read-only SELECT (or WITH ... SELECT) on a profile and get columns and rows. Aggregate in SQL (GROUP BY, TOP/LIMIT) instead of fetching raw rows: results stop at the profile's row limit (500 unless the user changed it), cells at 2 KB, and truncated: true means the answer is partial. Writes, EXEC, multiple statements and functions with side effects are refused; quote a column named like an SQL keyword. SQL Server reads uncommitted data, like the health check.

Input Schema

NameRequiredDescriptionDefault
sqlYesone SELECT or WITH ... SELECT statement
profileYesprofile name from list_profiles
databaseNodatabase name from list_databases; default: the profile's
max_rowsNorow limit; default and ceiling: the profile's
timeout_sNoseconds; default and ceiling: the profile's

Output Schema

NameRequiredDescriptionDefault
noteNo
rowsYes
columnsYes
warningNo
truncatedYes
elapsed_msYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.9.0

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the readOnlyHint annotation, the description discloses the row limit (500 unless changed), 2 KB cell limit, truncated flag semantics, refusal of multi-statement and side-effecting SQL, keyword-quoting guidance, and uncommitted-read behavior. These are substantial behavioral details an agent needs before calling the tool.

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 front-loaded with the core action, then adds operational guidance and limits in dense but purposeful sentences. Almost every sentence adds a constraint, caveat, or usage rule rather than restating the name.

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?

Given that annotations mark the tool read-only and an output schema exists, the description covers the critical gaps: SQL restrictions, row/cell truncation, profile row limits, and dirty-read behavior. It is complete enough for an agent to invoke query correctly without needing to inspect sibling tools.

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 100%, so the schema already documents all five parameters. The description still adds useful meaning by giving the concrete default row limit of 500 unless the user changed it, explaining truncated results, and clarifying that sql must be a single SELECT or WITH ... SELECT.

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: run one read-only SELECT (or WITH ... SELECT) on a profile and return columns and rows. This clearly separates it from sibling tools such as list_tables, describe_table, compare, or record_command, which do not execute arbitrary read-only SQL.

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 gives actionable usage guidance: aggregate in SQL with GROUP BY or TOP/LIMIT instead of fetching raw rows, and it explains that writes, EXEC, multiple statements, and side-effecting functions are refused. It does not explicitly route the agent to list_tables/describe_table for schema inspection, so it is clear but not exhaustive.

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