Skip to main content
Glama
Nitesh-Nandan

query-executor

execute_postgres

Execute SQL queries against a PostgreSQL database and retrieve results as JSON. Use in readonly mode for safe SELECT queries or readwrite for full SQL access (non-production).

Instructions

Execute a SQL query against a PostgreSQL database and return rows as JSON.

Returns: {"rows": [...], "row_count": N}

Mode behaviour (per project in databases.json):

  • readonly — only SELECT/WITH accepted; writes are blocked before reaching the DB.

  • readwrite — all SQL allowed; use only on non-production projects.

Call describe_postgres_schema first to confirm table/column names. If row_count equals your LIMIT, there are likely more rows.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

With no annotations, the description fully discloses key behaviors: mode enforcement (readonly blocks writes), return format with row_count, type casting for non-serialisable types, and the indicator that row_count equal to LIMIT suggests more rows. No contradictions.

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?

Concise and well-structured: purpose, return format, mode behavior, prerequisite call, and a caution about LIMIT. Every sentence adds value and the most critical info is front-loaded.

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?

Covers prerequisites, mode details, common pitfalls (LIMIT), and return format. With an output schema present (context signal), description does not need to explain return values further. No gaps identified.

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?

Input schema already provides parameter descriptions (sql and project_id). The description adds context about mode behavior affecting the sql parameter and suggests LIMIT usage, but does not elaborate on parameter syntax or format beyond the schema. Given low schema description coverage (0%), it compensates partially but not fully.

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?

Clearly states the tool executes SQL queries on a PostgreSQL database and returns rows as JSON. Distinguishes from siblings like 'describe_postgres_schema' and 'explain_postgres' by focusing on execution rather than schema inspection or query planning.

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

Usage Guidelines5/5

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

Includes explicit guidance: call 'describe_postgres_schema' first, explains mode behavior (readonly vs readwrite) with conditions, and advises adding LIMIT for unfamiliar tables. Effectively helps agents decide when and how to use this tool vs alternatives.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nitesh-Nandan/query-executor'

If you have feedback or need assistance with the MCP directory API, please join our Discord server