Skip to main content
Glama
MadlyFriese

pg-readonly-mcp

by MadlyFriese

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MCP_DB_DSNNoConnection string for the SELECT-only role
DATABASE_URLNoAlternative connection string for the SELECT-only role
MCP_DB_POOL_MAXNoConnection pool maximum size4
MCP_DB_POOL_MINNoConnection pool minimum size1
MCP_DB_MAX_BYTESNoResponse byte cap (hard max 524288)65536
MCP_DB_CONNECT_TIMEOUT_SNoConnection timeout in seconds10
MCP_DB_STATEMENT_TIMEOUT_MSNoPer-statement timeout in milliseconds5000

Capabilities

Features and capabilities supported by this server

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

Tools

Functions exposed to the LLM to take actions

NameDescription
list_schemasA

List schemas the connected read-only role can access.

list_tablesA

List tables and views in schema with an estimated row count and comment.

Returns columns=[name, row_estimate, comment, kind]. row_estimate comes from the planner statistics (pg_class.reltuples) and is approximate; it is null for views.

describe_tableA

Describe a table: columns, types, nullability, primary key, FKs, indexes.

Columns come back flat as column_names (the field labels) and column_rows (one positional row per column), in ordinal position.

sample_tableA

Return the first n rows of a table. n is clamped to 1..50.

run_queryA

Run a single read-only SELECT and return a bounded, columnar result.

Accepts one statement of any read-only shape: SELECT, WITH ... SELECT, UNION / UNION ALL / INTERSECT / EXCEPT, and any nesting of those. Rejected before execution: multiple statements, DML/DDL anywhere in the tree (including data-modifying CTEs), SELECT ... INTO, COPY, row locking, and any function not on the read-only allowlist (pg_read_file, dblink, ...).

The query is wrapped in SELECT * FROM (<sql>) sub LIMIT max_rows, so the cap applies to the combined result of a set operation, not to one branch. max_rows defaults to 100 and is capped at 1000. The response is separately capped in bytes, in which case truncated is true.

Performance note: plain UNION deduplicates, which costs a sort or hash over the full result of both branches before any row is returned — the outer LIMIT cannot short-circuit it. On large tables that is the most likely way to hit the server's statement timeout. Prefer UNION ALL when you do not need duplicates removed.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

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/MadlyFriese/pg-readonly-mcp'

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