Skip to main content
Glama
MCP Database Server

MCP Database Server

by RifkyR3

db_execute_query

Executes SQL queries against a database using a connection ID or main connection plus database name, with optional parameters and row limits for controlled results.

Instructions

Execute a SQL query against any database. Connection can be specified via connectionId (sub-connection alias or "mainId:db") or mainId + database

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

Input Schema

NameRequiredDescriptionDefault
queryYesThe SQL query to execute
mainIdNoMain connection ID (e.g. "postgres_main")
paramsNoOptional parameterized values for prepared statements
maxRowsNoMax rows to return (default: 100)
databaseNoDatabase name on the main server (e.g. "app_db")
connectionIdNoSub-connection alias (e.g. "app_db") or composite ("postgres_main:app_db")

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.2

TDQS

B3.1/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full behavioral burden, yet it says nothing about whether DDL/DML statements are executed, whether a transaction wraps execution, how errors surface, or how the default maxRows truncation behaves on large result sets. For a tool that can run arbitrary destructive SQL, this is a significant disclosure gap.

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?

Two tight sentences: the action comes first, then the connection targeting rule. No filler, no restatement of the tool name.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Connection targeting is adequately covered for a 6-parameter tool with no output schema, but the absence of annotations means the description should also cover execution semantics and destructive-query risk, which it does not. It is minimally viable for invocation but incomplete for safe use.

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 description coverage is 100%, so the baseline is 3. The description does add genuine value by stating the connection-resolution contract — either connectionId (alias or "mainId:db" composite) or the mainId + database pair — which the schema presents as independent fields without explaining the either/or relationship.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb and resource ("Execute a SQL query against any database") and clarifies that it is the generic execution path rather than one of the discovery/registration siblings. It stops short of explicitly contrasting with db_describe_table or db_list_tables, but the intent is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to reach for this tool versus the schema-introspection siblings (e.g., describe a table first), and no indication of whether read-only and mutating statements are both permitted. An agent must infer all usage conditions from the name alone.

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