musaddiq-dev avatar

PostgreSQL MCP Server

musaddiq-dev/postgresql-mcp-server

Connects Claude to PostgreSQL databases with a full suite of inspection and querying tools. You get schema discovery, read-only query execution with automatic row limits and transaction rollback, query plan explanations, foreign key relationship mapping, and index analysis. The write query tool accepts single INSERT, UPDATE, DELETE, or DDL statements and commits them, so you'll want a read-only user for most workflows. Exposes MCP resources for table lists and schema definitions. Ships with configurable row limits and runs queries in explicit read-only transaction mode for safety. Install via uvx and configure with standard Postgres connection parameters.

tool
1
auth
Secret needed
transport
STDIO
env vars
6
last updated
May 23, 2026

Tools

1 tools

Public tool metadata for what this MCP can expose to an agent.

execute_custom_queryExecute a custom SQL query against the database. WARNING: Use with care. Do not expose to untrusted input.4 params

Execute a custom SQL query against the database. WARNING: Use with care. Do not expose to untrusted input.

Parameters* required
connectionStringstring
PostgreSQL connection string
querystring
SQL query to execute
timeoutnumber
Optional query timeout in milliseconds
valuesarray
Optional parameter values for the query

Sponsors

Configuration

POSTGRES_HOST*default: localhost

PostgreSQL host

POSTGRES_PORT*default: 5432

PostgreSQL port

POSTGRES_USER*

PostgreSQL username

POSTGRES_PASSWORDsecret

PostgreSQL password

POSTGRES_DB*

PostgreSQL database name

POSTGRES_READ_QUERY_LIMITdefault: 1000

Maximum rows returned by read queries

Readme

PostgreSQL MCP Server

A Python Model Context Protocol (MCP) server for inspecting and querying PostgreSQL databases from MCP-compatible clients. It provides schema discovery, safe read-only query execution, query explanation, table previews, index analysis, relationship inspection, and PostgreSQL resources for table metadata.

Features

  • List public tables and inspect table schemas
  • Execute read-only SQL in a PostgreSQL read-only transaction
  • Explain query plans without executing the target query directly
  • Preview table rows with a fixed limit
  • Inspect foreign-key relationships and indexes
  • Expose passive MCP resources for table lists and schema details

Safety Model


View the full README on GitHub

Details

Repository
github.com/musaddiq-dev/postgresql-mcp-server
Category
Databases
Package
mdev-postgresql-mcp-server
Transport
STDIO
Auth
Required
Registry
MCP registry, active

More from musaddiq-dev

Related Databases MCP servers

View all
1neo4j-contrib avatarMcp Neo4j Aura Managerneo4j-contrib/mcp-neo4jMCP server for Neo4j Aura Database Instance Manager.958stars
2waystation-ai avatarSupabasewaystation-ai/mcpConnect to your Supabase database to query data and schemas.0stars
3spences10 avatarMcp Sqlite Toolsspences10/mcp-sqlite-toolsMCP server for local SQLite database operations19stars
4neverinfamous avatarPostgreSQL MCP Serverneverinfamous/postgres-mcpEnterprise PostgreSQL MCP server with 63 tools, 10 resources, 10 prompts for AI-native operations8stars
5hovecapital avatarRead Only Local Mysql Mcp Serverhovecapital/read-only-local-mysql-mcp-serverMCP server for read-only MySQL database queries in Claude Desktop6stars
6afgong avatarAfgong Sqlite Mcp Serverafgong/sqlite-mcp-serverExplore your Messages SQLite database to browse tables and inspect schemas with ease. Run flexible…0stars