Skip to main content
Glama
codeDB Lens

codeDB Lens

Official

query

Read-only

Run a guarded read-only SELECT or WITH query against a saved profile to get columns and rows, with row and time limits enforced and writes refused.

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: counts and sums taken while other transactions are open can be off, so present them as approximate, not final.

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": {
      "profile": "<profile>",
      "sql": "<sql>"
    },
    "name": "query"
  }
}

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.4/5.0
Behavior5/5

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

Goes well beyond the readOnlyHint/idempotentHint annotations: discloses the 500-row default limit, the 2 KB cell truncation with a truncated: true signal, refusal of writes/EXEC/multi-statement calls, keyword-quoting behavior, and the uncommitted-read isolation caveat that makes counts approximate. That is exactly the operational context an agent needs and annotations cannot express.

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?

Front-loads the core action in the first sentence, then layers limits, refusals, and the isolation caveat. Dense but every clause carries information; the final caveat sentence is slightly long yet earns its place by preventing a wrong presentation of results.

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?

Despite an output schema existing, the description still supplies the critical behavioral facts (row limit, truncation flag, refusal rules, isolation effects) that govern correct invocation and interpretation. Nothing an agent needs to call this safely is missing.

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 coverage is 100% and each parameter already documents its default and ceiling (max_rows, timeout_s defer to the profile). The description reinforces the profile row limit but adds no new per-parameter syntax or constraint beyond the schema. Baseline 3 is appropriate.

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 one read-only SELECT (or WITH ... SELECT) on a profile, returning columns and rows. This distinguishes it from siblings like check, describe_table, or list_* tools, which don't execute ad-hoc 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?

Gives concrete usage direction — aggregate in SQL with GROUP BY/TOP/LIMIT rather than fetching raw rows — and explicitly rules out writes, EXEC, multiple statements, and side-effecting functions. It doesn't name a sibling alternative for cases where query isn't right, but the exclusions cover the practical when-not case.

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