Skip to main content
Glama
database-mcp

database-mcp

run_query

Execute read-only SQL queries against PostgreSQL or MySQL databases. Return columns, rows, and a markdown table, with preview mode to sanity-check results before a full run.

Instructions

Execute a READ-ONLY SQL query (SELECT/CTE/SHOW/DESCRIBE/EXPLAIN only — writes are rejected at multiple layers). Returns columns, rows, row_count, truncated flag, and a ready-to-display markdown_table. Set preview=true to sanity-check a few rows before a full run. An automatic LIMIT is applied to unbounded SELECTs.

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": {
      "connection": "<connection>",
      "sql": "<sql>"
    },
    "name": "run_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesA single read-only SQL statement.
limitNoMax rows (default 100, hard cap 1000).
previewNoIf true, return only 5 rows as a sanity check.
connectionYesNamed connection from list_connections (preferred) or a raw connection string.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.5

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations at all, the description carries the full burden and mostly succeeds: it discloses that writes are rejected at multiple layers, that an automatic LIMIT is imposed on unbounded SELECTs, and that results may be truncated. It stops short of disclosing permission/connection-scope constraints or rate limits, which would matter for a query executor.

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?

Four compact sentences, front-loaded with the read-only constraint and allowed statement types, then the return shape, then the preview workflow, then the automatic LIMIT. Every sentence contributes a distinct fact with no repetition of the schema.

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 4-parameter query tool with no output schema, the description covers the critical unknowns: write rejection, automatic limiting, truncation, and the exact return fields (columns, rows, row_count, truncated, markdown_table). An agent has enough to call it correctly and interpret the result without guessing.

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 already 100%, so the baseline is 3; the description exceeds that by explaining the motivation for preview (sanity check before a full run) and by adding behavior the schema does not state, namely that an automatic LIMIT is applied to unbounded SELECTs, framing how the limit parameter interacts with the default behavior.

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 ('Execute a READ-ONLY SQL query') and enumerates the allowed statement classes (SELECT/CTE/SHOW/DESCRIBE/EXPLAIN), so the agent knows exactly what it is and what it is not. Combined with the sibling set (list_tables, get_schema, etc.), the distinction between a free-form query runner and metadata helpers is evident.

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?

Provides a concrete operating workflow: use preview=true to sanity-check a few rows before a full run, and be aware an automatic LIMIT is applied to unbounded SELECTs. It does not explicitly route the agent away from this tool toward explain_query or describe_table, so there are no stated exclusions.

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