Skip to main content
Glama
ChingEnLin
by ChingEnLin

run_query

Read-only

Run read-only SQL statements on your PostgreSQL database to fetch data without risking modifications, as writes are automatically rejected and transactions rolled back.

Instructions

Execute a read-only SQL statement against the connected PostgreSQL database.

Only a single SELECT / WITH / TABLE / VALUES / EXPLAIN / SHOW statement is accepted, and it runs inside a READ ONLY transaction that is always rolled back — writes are rejected by PostgreSQL itself.

Example: SELECT status, count(*) FROM public.orders GROUP BY status ORDER BY 2 DESC

Args: sql: A single read-only SQL statement. limit: Max rows to return (default 100). database: Database name. Defaults to the session database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
limitNo
databaseNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

While annotations already declare readOnlyHint=true and destructiveHint=false, the description adds valuable execution details: the statement runs inside a READ ONLY transaction that is rolled back, and PostgreSQL rejects writes. It also mentions the limit default and database default, enhancing behavioral understanding beyond annotations.

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?

The description is well-structured and concise: a one-line purpose, followed by key constraints, a concrete example, and a clean argument list. Every sentence contributes meaning with no redundancy or filler.

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?

The description is complete for a query tool: it states the read-only guarantee, allowed statement types, parameter semantics, and gives an example. Since an output schema exists, return value documentation is unnecessary. The only minor omission is a mention of connection prerequisites, but the phrase 'connected PostgreSQL database' implies an established context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides no property descriptions (0% coverage), so the description must compensate. It does so thoroughly, explaining sql as a single read-only statement, limit as max rows with default 100, and database as the database name defaulting to the session database. An example query further clarifies sql syntax.

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?

The description clearly states the tool executes a read-only SQL statement against the connected PostgreSQL database. This specific verb+resource combination distinguishes it from sibling tools like list_tables or describe_table, which focus on schema inspection rather than arbitrary queries.

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?

The description gives clear context on when to use the tool: for executing read-only SQL of specific statement types (SELECT, WITH, etc.) and notes that writes are rejected. It does not explicitly name alternative tools, but the constraints and read-only scope effectively guide usage.

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/ChingEnLin/SQMCPaL'

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