Skip to main content
Glama
Postgres MCP Server

Postgres MCP Server

by Zotriq

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
LLM_MODELNoModel used to write SQL.gpt-4o-mini
LLM_API_KEYNoAPI key for the ask tool.
DATABASE_URLNoSingle database connection URL.
LLM_BASE_URLNoAny OpenAI-compatible endpoint.OpenAI
PG_MCP_MAX_ROWSNoMaximum rows returned per query.200
PG_MCP_DATABASESNoJSON map of database name to connection URL. Overrides DATABASE_URL.
PG_MCP_STATEMENT_TIMEOUT_MSNoPer-query timeout in milliseconds.5000

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 PostgreSQL access. Start with list_databases and list_tables, use describe_table before writing SQL, then run_query. Use ask to let the server write the SQL from a plain-English question. All queries are read-only and row-limited.

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_databasesA

List the configured database names.

list_tablesB

List tables and views with approximate row counts.

describe_tableB

Show columns, types, primary key and foreign keys for a table (e.g. 'public.orders').

run_queryA

Run a single read-only SELECT. Writes, DDL and unsafe functions are rejected; rows are capped.

explain_queryB

Show the PostgreSQL query plan for a SELECT without running it.

askB

Answer a plain-English question: writes safe SQL from the live schema and (optionally) runs it.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A3.6/5.0

Scored across 6 tools

Disambiguation4/5

Most tools target clearly distinct actions: listing databases/tables, describing a table, running a SELECT, and explaining a query plan. The only real overlap is between 'ask' and 'run_query', since 'ask' can also generate and execute SQL, but the natural-language vs raw-SQL distinction and the optional execution flag make them separable.

Naming Consistency4/5

Five of six tools follow a clean verb_noun or verb_object pattern (list_databases, list_tables, describe_table, run_query, explain_query). 'ask' is a stylistic outlier but is still a single readable verb, so the set remains predictable.

Tool Count5/5

Six tools is well-scoped for a read-only Postgres inspection server — each one covers a distinct step in the explore-inspect-query workflow. Nothing feels padded or missing at the count level.

Completeness4/5

The surface covers the core read-only lifecycle: discover databases, browse tables, inspect schema, execute, and plan queries, with 'ask' as a convenience layer. Minor gaps exist — no schema-level listing beyond table names, no index/constraint detail beyond PK/FK, and writes/DDL are intentionally excluded, which an agent can work around for read-only tasks.

Maintenance

ActivityMaintained
ResponsivenessOutdated data