Skip to main content
Glama

pgsql-mcp

pgsql-mcp gives MCP clients safe PostgreSQL inspection, bounded SQL, reviewed changes, and operational diagnostics.

The server starts in restricted mode. Write tools require an explicit unrestricted configuration.

Why use pgsql-mcp

Control

Behavior

Evidence

Safe default

Restricted mode permits bounded read operations

Database read-only transactions and SQL validation

Reviewed change

Migration and maintenance plans require a review hash

Durable ledgers and commit guards

Bounded output

Public tools apply row, time, and result limits

Server-side cursors and hard ceilings

Broad catalog

Core catalogs expose relations, types, extensions, and providers

OID-backed identities and deterministic results

Release quality

Main commits run the complete quality system

Tests, coverage, mutation, stress, and compatibility jobs

Related MCP server: PostgreSQL MCP Server

Safety boundary

Use a dedicated PostgreSQL role with the minimum required privileges.

Use stdio for local clients when possible. Put remote transports behind authentication and transport encryption.

Read the security model before production use.

Quick start

Set a read-only database URI.

DATABASE_URI='postgresql://readonly_user:password@localhost:5432/app' \
uvx pgsql-mcp

Use unrestricted mode only for a controlled environment.

DATABASE_URI='postgresql://developer:password@localhost:5432/app_dev' \
uvx pgsql-mcp --access-mode=unrestricted

Do not use a production owner or superuser role.

MCP configuration

{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": ["pgsql-mcp"],
      "env": {
        "DATABASE_URI": "postgresql://readonly_user:password@localhost:5432/app"
      }
    }
  }
}

Docker

docker run -i --rm \
  -e DATABASE_URI='postgresql://readonly_user:password@host.docker.internal:5432/app' \
  pgsql-mcp

Server profiles

Command

Scope

Pool

Write access

pgsql-mcp

Full catalog, SQL, diagnostics, and reviewed changes

Configured pool

Explicit unrestricted mode

pgsql-mcp-lite

Six focused read-only tools

Two connections

No

pgsql-mcp-ha

Replication and failover inspection

Focused pool

No

Capability map

Catalog and diagnostics

  • Inspect schemas, relations, routines, types, privileges, policies, and partitions.

  • Search trusted PostgreSQL catalogs.

  • Report installed and available extension profiles.

  • Inventory objects that belong to an installed extension.

  • Report PostGIS columns and spatial indexes.

  • Report pgvector columns and indexes.

  • Report provider capabilities without reading secrets.

  • Inspect replication topology and failover readiness.

SQL and data

  • Execute one bounded read-only SQL statement.

  • Bind values with native PostgreSQL parameters.

  • Select typed pages with stable keyset pagination.

  • Insert, upsert, update, and delete rows with commit guards.

  • Execute guarded atomic transactions in unrestricted mode.

Reviewed operations

  • Create and hash transactional migration plans.

  • Apply and roll back reviewed migrations.

  • Create and hash nontransactional maintenance plans.

  • Apply maintenance and reconcile an unknown outcome.

Analysis

  • Explain validated queries.

  • Read bounded workload statistics.

  • Analyze query and workload index opportunities.

  • Run database health checks.

  • Publish privacy-preserving runtime metrics.

Hard limits

Surface

Limit

Full server rows

5,000

Lite server rows

500

Typed data rows

500

Extension objects

500

PostGIS columns and indexes

500 combined

pgvector columns and indexes

500 combined

Protected operations also apply query, lock, and idle-transaction timeouts.

Production use

The current release scope is ready for trusted internal and operator workflows when all checklist items are true.

  • Use a dedicated database role.

  • Keep restricted mode unless a reviewed write workflow is required.

  • Keep remote transports behind authentication and TLS.

  • Set explicit row and timeout limits.

  • Monitor the main branch quality jobs.

  • Test each upgrade against a disposable PostgreSQL database.

  • Review production readiness before deployment.

Future roadmap items are not release guarantees. Read the project plan for planned work.

Documentation

Topic

Guide

Security and deployment

Security model

Production review

Production readiness

Architecture

Execution safety

Compatibility

PostgreSQL compatibility

Catalog model

Catalog inspection

Typed data

Data operations

Reviewed changes

Migrations and maintenance

Extensions

Profiles, objects, PostGIS, and pgvector

High availability

Replication

Quality system

Testing and documentation index

Writing profile

ASD-STE100 project profile

Development

uv sync --all-extras
uv run ruff format --check .
uv run ruff check .
uv run pyright
uv run pytest -v
python scripts/check_ste_docs.py .

Run the complete gates locally before merge. GitHub Actions run only after a commit reaches main.

Read CONTRIBUTING.md before you change the project.

Release

Main branch jobs build and validate the package and container. They do not publish artifacts.

Read PUBLISHING.md for the manual release procedure.

License

MIT

Install Server
A
license - permissive license
B
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    F
    maintenance
    Enables AI assistants to safely explore, analyze, and maintain PostgreSQL databases with read-only mode by default, SQL injection prevention, query performance analysis, and optional write operations.
    Last updated
    61
    Apache 2.0
  • A
    license
    -
    quality
    D
    maintenance
    Provides comprehensive PostgreSQL database access with 36 tools for querying, managing schemas, JSONB operations, and database administration. Includes security features like query validation, rate limiting, SSL/TLS support, and optional write operations.
    Last updated
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    Enables comprehensive PostgreSQL database management including index tuning, query plan analysis, health monitoring, schema-aware SQL generation, and safe SQL execution with configurable access control for both development and production environments.
    Last updated
    9
    MIT
  • A
    license
    -
    quality
    D
    maintenance
    Enables AI agents to interact with PostgreSQL databases through schema intelligence, query execution, and DBA tooling including index analysis and health monitoring. Features configurable access levels and audit logging for secure database operations.
    Last updated
    576
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

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/surajmandalcell/pgsql-mcp'

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