Skip to main content
Glama
YawLabs

@yawlabs/postgres-mcp

by YawLabs

pg_readonly

Read-onlyIdempotent

Execute any SQL statement in a read-only transaction, ensuring no writes occur. Ideal for SELECT and EXPLAIN queries with parameterized input to prevent SQL injection.

Instructions

Run a SQL statement guaranteed read-only. Always executes inside a BEGIN READ ONLY transaction regardless of ALLOW_WRITES, so postgres itself rejects any write attempt. Use this whenever the goal is to read - SELECT, EXPLAIN, SHOW, VALUES, WITH ... SELECT, etc. Hosts that gate tools individually (Claude Code permissions, mcp.hosting) can safely auto-allow this one. Use params for parameterized queries to avoid SQL injection. Params can be strings, numbers, booleans, null, arrays (for postgres arrays / ANY), or objects (for json/jsonb columns). Large result sets are truncated to POSTGRES_MAX_ROWS (default 1000) with a truncated: true flag.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesThe SQL statement to execute. Hard cap of 1 MB.
paramsNoPositional parameters referenced as $1, $2, ... in the SQL.
Behavior5/5

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

Annotations already mark the tool as read-only and idempotent. The description adds crucial details: always runs in BEGIN READ ONLY, SQL write attempts are rejected by PostgreSQL, parameter types for arrays/JSON, and result truncation behavior with a truncated flag. 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?

Approximately 6 sentences, each serving a distinct purpose: core behavior, use cases, safety, parameter guidance, truncation. Front-loaded with the key guarantee. No redundant or unnecessary text.

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?

For a tool with 2 parameters, no output schema, and rich annotations, the description covers all essential aspects: execution model, security, parameter types, result limits. No obvious gaps remain.

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?

Schema covers both parameters fully (100% coverage). The description enhances by explaining params are positional ($1, $2), listing accepted types (strings, numbers, booleans, null, arrays, objects) and their PostgreSQL mappings (arrays for ANY, objects for jsonb). Adds value beyond schema.

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 runs SQL statements guaranteed read-only within a BEGIN READ ONLY transaction. It lists specific SQL commands (SELECT, EXPLAIN, SHOW, VALUES) and contrasts with sibling tools like pg_query, making its purpose unambiguous.

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?

Explicitly advises to use this tool 'whenever the goal is to read' and includes examples of appropriate SQL. It warns that PostgreSQL itself rejects writes, and mentions safe auto-allow for permission-gating hosts. Also recommends using params for injection safety.

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/YawLabs/postgres-mcp'

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