Skip to main content
Glama

Query a site's database

db_query
Destructive

Run one SQL statement on a site's database, connecting with the site's own credentials (you never need the password). SELECT, SHOW, DESCRIBE and EXPLAIN run straight away in a read-only transaction; anything that changes data needs the user's approval. Remember the table prefix from list_sites. Query only the tables and columns the task needs. Do not select or return payment card numbers, government ID numbers, health or biometric data or password hashes, and never ask the user for them: if a table holds them, leave those columns out.

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

Input Schema

NameRequiredDescriptionDefault
sqlYes
whyNoOne plain sentence for the user, shown on the approval page if this call needs their approval: what it does and why it is needed.
siteNoSite root folder, like /var/www/shop, or one of the site's domains. Optional when the server has one site (see list_sites).
serverNoServer name or id. Optional when the account has one server.
max_rowsNoDefault 200, max 1000.
approval_idNoOnly when repeating a call the user approved.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false and openWorldHint=true; the description adds real context beyond them: credentials are handled for you, safe statement classes run in a read-only transaction, mutations are gated on user approval. It stops short of describing what happens on approval denial, approval expiry, or result/error shape.

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 sentences, front-loaded with the action and connection model, then permissions, then the cautionary rules. Every sentence carries operational weight; nothing is redundant with the title or schema.

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?

For a 6-parameter, no-output-schema, destructive-capable tool this is close to complete: safety profile, approval flow, data-handling policy and prefix prerequisite are all covered. The remaining gap is return behavior and row-cap enforcement, which matter somewhat for a query tool.

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 83%, so the schema already documents sql, why, site, server, max_rows and approval_id. The description adds constraint meaning to the sql parameter (permitted statement classes, transaction mode) and a hint tying site selection to list_sites, but nothing about length, dialect, or multi-statement limits. Baseline 3 is appropriate given the schema does most of the work.

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 SQL statement on a site's database') plus the connection model (site's own credentials). An agent can distinguish this from db_dump/db_restore/db_restore-style siblings by the single-statement, credential-managed framing without opening another schema.

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 explicit when-to-run-straight-away guidance (SELECT, SHOW, DESCRIBE, EXPLAIN in a read-only transaction) versus when approval is required (anything that changes data), and directs the agent to list_sites for the table prefix. It does not name sibling alternatives such as db_dump or db_restore, so it stops short of a full routing rule.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources