Skip to main content
Glama
atengk

mcp-server-rdbms

by atengk

sql_query

Execute read-only SQL or fetch query plans across multiple databases, with automatic row limits, format options, and EXPLAIN-based slow query analysis.

Instructions

安全执行只读 SQL 查询或获取执行计划。支持多数据库路由(通过 db 参数指定目标数据库连接别名,缺省时路由至默认库)。在初次探索未知业务表时,强烈建议显式指定 limit=3~5 获取结构样本;未显式指定 limit 时系统底层将安全截断至 100 行。支持 json、markdown 表格与 csv 格式输出,具备 AST 校验及慢查询熔断防护;支持 explain=True 获取执行计划分析慢查询。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dbNo
sqlYes
limitNo
formatNojson
explainNo
timeoutNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.4.0
    • addedInput schema / properties / explain
      Added value: +{
      +  "default": false,
      +  "title": "Explain",
      +  "type": "boolean"
      +}
  2. First observedv1.1.4

TDQS

A4.3/5.0
Behavior4/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 well: it discloses read-only enforcement, AST validation, slow-query circuit breaking, automatic truncation to 100 rows when limit is omitted, and multi-DB routing behavior. It omits auth/permission requirements and what happens on validation failure, which keeps it short of a 5.

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?

Three dense sentences lead with the core capability, then routing, then the sampling/safety guidance, and every clause carries information. Slightly heavy in a single paragraph, but no 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?

An output schema exists so return values need no explanation, and the missing annotations are largely compensated by the safety and routing disclosures. The remaining gap is the undocumented timeout parameter and a lack of error/failure behavior, which is minor for a well-specified read 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 0%, so the description must compensate, and it explains five of six parameters: db (connection alias, default routes to the default database), limit (default truncation at 100, recommended 3-5 for sampling), format (json/markdown/csv), and explain (returns an execution plan). Only timeout is left undocumented, and its unit is never stated.

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+resource ('安全执行只读 SQL 查询') plus a second mode ('获取执行计划'), and the explicit 只读 (read-only) qualifier separates it from the write-oriented siblings sql_dml and sql_ddl without opening 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?

It gives concrete when-to guidance: use limit=3~5 when first exploring unknown business tables, and use explain=True to analyze slow queries. It does not explicitly name sql_dml/sql_ddl as alternatives for writes, so the routing is implied by 'read-only' rather than spelled out.

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