Skip to main content
Glama
Postgres MCP

Postgres MCP

by freakynit

Execute a SQL query

execute_raw_query

Run SQL against PostgreSQL with automatic permission detection and approval prompts for writes or dangerous DDL; optionally validate queries with dry-run before execution.

Instructions

Execute a SQL query. The system will automatically detect the required permission level and request user approval for write operations and dangerous DDL commands.

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": "execute_raw_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesThe SQL statement to run.
dry_runNoIf true, validates the query without executing it

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.1

TDQS

B3.2/5.0
Behavior3/5

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

With no annotations supplied, the description carries the full burden, and it does disclose real behavior: automatic permission-level detection and user approval gating for write operations and dangerous DDL. That is valuable context beyond the schema, but it omits what happens on rejection, whether reads are auto-approved, transaction/side-effect semantics, and what the call returns.

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?

Two short sentences, front-loaded with the core action and followed by the approval behavior, with no filler. It is efficient, though its brevity comes at the cost of the guidance and return-value context noted elsewhere.

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?

For an arbitrary-SQL execution tool with no annotations and no output schema, the definition covers the approval/risk story but is thin on outcome expectations, error behavior, and how results come back. Adequate to call correctly, not complete enough for an agent to predict consequences.

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 both parameters are already documented (sql, and dry_run as validate-without-executing). The description adds no meaning about the sql string's dialect/limits or about when to set dry_run, so the baseline of 3 applies.

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 states a specific verb and resource ('Execute a SQL query'), which along with the 'raw' qualifier in the name sets it apart from metadata siblings like describe_tables and list_tables. It is clear what the tool does, though it never explicitly contrasts itself with those read-only siblings.

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 when-to-use or when-not-to-use guidance: nothing tells the agent to prefer describe_tables/list_tables for schema inspection, nor when a raw query is appropriate versus those alternatives. The dry_run parameter's intended workflow is also left unexplained in the description.

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