Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

Run SELECT

run_select
Read-only

Validate and execute a read-only SQL query, rejecting writes and DDL before execution. Cap returned rows and optionally target a configured secondary read-only database.

Instructions

Validate and run a read-only SQL query. Writes, DDL, and other unsafe statements are rejected before execution.

Example: run_select(sql='SELECT id, email FROM users LIMIT 10', max_rows=1000)

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

Input Schema

NameRequiredDescriptionDefault
sqlYes
databaseNoOptional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected.
max_rowsNo

Output Schema

NameRequiredDescriptionDefault
rowsYes
columnsYes
row_countYes
truncatedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected."
  2. First observedv0.6.8

TDQS

B3.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, but the description still adds real behavior: unsafe statements are validated and rejected *before execution*, which tells the agent it can safely attempt a statement and expect a refusal rather than a partial write. What it omits is what happens when the result exceeds max_rows (truncation vs. error) and whether it targets only the primary database by default, though the latter is covered in the schema.

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 plus one example, with the core action and safety guarantee front-loaded. The example earns its place by demonstrating the untyped `sql` and `max_rows` usage, though its syntax is largely self-evident to an agent already reading the schema.

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?

The return format is covered by the output schema, so the description needn't explain results, and safety behavior is well covered. The gaps are the semantics of max_rows (truncation behavior) and any routing guidance against the tuned/parallel variants, which matter for a moderately complex query-execution tool in a crowded sibling set.

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 only 33%: the `database` parameter is documented in the schema, but `sql` and `max_rows` have no schema descriptions. The example partially compensates by showing a realistic sql string and max_rows=1000, implying max_rows is a row cap, but it never states whether exceeding that cap truncates results or raises an error, leaving the most consequential parameter underspecified.

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 ('Validate and run a read-only SQL query') and adds a safety constraint ('Writes, DDL, and other unsafe statements are rejected'). An agent knows exactly what the tool does. However, it never distinguishes itself from near-identical siblings such as run_select_tuned, run_select_parallel, or run_analytical_query, so the agent cannot tell why this variant should be chosen.

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 guidance and no mention of alternatives. With siblings like run_select_tuned (tuned execution), run_select_parallel, run_analytical_query, explain_query, and the cursor tools (open_cursor/fetch_cursor), an agent has no stated rule for picking this tool over those; the read-only framing only implies intended usage.

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

Deploy Server

Other Tools