Skip to main content
Glama
pg-readonly-mcp

pg-readonly-mcp

by vinit1009

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MCP_PG_DSNYeslibpq connection string or URL. Prefer ~/.pgpass or PGPASSWORD to a password in the string.
MCP_PG_AUDIT_LOGNoWhere the audit log goes (created with mode 600).~/.pg-readonly-mcp/audit.jsonl
MCP_PG_ROW_LIMITNoMost rows one run_query returns (hard maximum 10,000). Claude can ask for fewer.200
MCP_PG_TIMEOUT_MSNoStatement timeout for each query.10000
MCP_PG_SEARCH_PATHNoSchemas searched for unqualified table names.public
MCP_PG_ALLOWED_TABLESYesComma-separated schema.table entries, or schema.* for a whole schema. A bare name means public.name. Quote mixed-case names: "Sales"."Q1 Orders".
MCP_PG_MAX_CELL_CHARSNoLong text values are cut to this length so one cell cannot flood the context.2000
MCP_PG_ALLOW_SUPERUSERNoSet to 1 only for a throwaway local database.off
MCP_PG_EXTRA_FUNCTIONSNoExtra function names to allow, e.g. similarity, unaccent.

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

Read-only access to one PostgreSQL database. Start with list_tables, then describe_table for the columns you need. run_query takes exactly one SELECT (CTEs, joins, window functions and aggregates are fine) and returns at most the server's row limit, so aggregate or filter in SQL instead of pulling raw rows. Only allow-listed tables can be read; writes, multiple statements and functions that touch files or settings are refused, and every call is written to an audit log. If a query is refused, the error says why: fix the query rather than retrying.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}

Tools

Functions exposed to the LLM to take actions

NameDescription
list_tablesA

List the tables and views this server may read, with approximate row counts and comments, plus the row limit and timeout that apply to run_query.

describe_tableA

Show the columns (name, type, nullable, default, comment), primary key and foreign keys of one allow-listed table or view. Pass schema.table, or just the table name for the default schema.

run_queryA

Run one read-only SQL SELECT (PostgreSQL dialect) and return columns and rows. At most limit rows come back (capped by the server's row limit); truncated says whether more rows matched. Writes, multiple statements and non-allow-listed tables are refused.

explain_queryA

Show PostgreSQL's query plan for one SELECT without running it (EXPLAIN, no ANALYZE). Use it before a query that might be slow on a large table.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A4.3/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly distinct role: discovering tables, inspecting one table's schema, executing a read-only SELECT, and explaining a query plan. The list_tables vs describe_table distinction is obvious from scope and output. There is no meaningful overlap that would cause misselection.

Naming Consistency5/5

All four names follow a consistent snake_case verb_noun convention: list_tables, describe_table, run_query, explain_query. The pattern is predictable and readable throughout.

Tool Count5/5

Four tools is appropriately scoped for a read-only PostgreSQL inspection server. Each tool earns its place, and there is no unnecessary surface area.

Completeness4/5

The set covers the core read-only workflow: discover tables, inspect schema, execute queries, and preview query plans. Minor gaps exist in schema introspection, such as indexes and unique constraints beyond primary/foreign keys, but agents can work around them.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues