PostgreSQL MCP Server
Provides tools for interacting with PostgreSQL databases, including executing SELECT queries to read data, listing all tables, and viewing schema information for specific tables.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
PostgreSQL MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with PostgreSQL databases.
Tools
read_query - Execute SELECT queries to read data from the database
list_tables - Get a list of all tables in the database
describe_table - View schema information for a specific table
Related MCP server: PostgreSQL MCP Server
Installation
1. Create and activate a virtual environment
cd <path-to-project>
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate2. Install the package
pip install -e .Usage
The server supports two transport modes:
stdio (default) - Standard input/output, for direct MCP client integration
http - HTTP with streamable transport, for standalone server mode
Command Line
postgres-mcp --host <host> --port <port> --database <database> --user <user> --password <password> [--transport stdio|http]Arguments:
Argument | Required | Default | Description |
| Yes | - | PostgreSQL host |
| No | 5432 | PostgreSQL port |
| Yes | - | Database name |
| Yes | - | Database user |
| Yes | - | Database password |
| No | stdio | Transport type: |
| No | 127.0.0.1 | Host for HTTP server |
| No | 8080 | Port for HTTP server |
Example (stdio mode):
postgres-mcp --host localhost --port 5432 --database mydb --user admin --password secretExample (HTTP mode):
postgres-mcp --host localhost --database mydb --user admin --password secret --transport http --http-port 8080As a Python module
python -m postgres_mcp --host localhost --database mydb --user admin --password secretUsing run.sh (for AWS RDS with IAM authentication)
The run.sh script handles AWS RDS IAM authentication and SSL configuration:
./run.shThis script:
Sets up SSL certificates for RDS
Generates a temporary IAM auth token via
aws-vaultLaunches the MCP server in HTTP mode on
http://127.0.0.1:8080/mcpYou need to configure the environment variables for credentials and RDS connection details before running the script.
MCP Client Configuration
HTTP Mode (recommended for AWS RDS / complex environments)
Start the server in a terminal with the correct environment:
./run.shConfigure your MCP client:
For clients that support HTTP directly (e.g., Cursor):
{ "mcpServers": { "postgres": { "type": "streamable-http", "url": "http://127.0.0.1:8080/mcp" } } }For clients that only support stdio (e.g., Claude Code):
Use the stdio-to-HTTP proxy:
{ "mcpServers": { "postgres": { "command": "<path-to-project>/.venv/bin/postgres-mcp-proxy", "args": ["--server-url", "http://127.0.0.1:8080/mcp"] } } }
Stdio Mode (for simple setups)
Direct execution
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"postgres": {
"command": "<path-to-project>/.venv/bin/postgres-mcp",
"args": [
"--host", "localhost",
"--port", "5432",
"--database", "mydb",
"--user", "admin",
"--password", "secret"
]
}
}
}Claude Code:
{
"mcpServers": {
"postgres": {
"command": "<path-to-project>/.venv/bin/postgres-mcp",
"args": [
"--host", "localhost",
"--port", "5432",
"--database", "mydb",
"--user", "admin",
"--password", "secret"
]
}
}
}Development
Install in development mode
pip install -e .Project structure
db-mcp/
├── pyproject.toml
├── README.md
├── run.sh # AWS RDS launcher script
└── src/
└── postgres_mcp/
├── __init__.py
├── __main__.py # CLI entry point
├── database.py # Connection pool management
├── server.py # MCP server implementation
└── proxy.py # Stdio-to-HTTP proxy for Claude CodeTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Managed Postgres MCP: projects, SQL, docs search, and storage buckets via OAuth.
Hosted MCP server for PostgreSQL diagnostics: slow queries, missing indexes, connection pressure.
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables secure querying of PostgreSQL databases through MCP-compatible clients. Supports read-only SQL execution, table exploration, and connection management with built-in security validation.356 npm9MIT
- AlicenseNot gradedqualityDmaintenanceEnables interaction with PostgreSQL databases through both HTTP and stdio transports. Supports executing read-only SQL queries, listing tables, and retrieving schema information with stateful session management.MIT
- FlicenseNot gradedqualityDmaintenanceEnables interaction with PostgreSQL databases through MCP, allowing users to explore database structures, inspect table schemas, and execute read-only SQL queries.-
- AlicenseCqualityDmaintenanceEnables querying PostgreSQL database metadata including table lists and schema information through the MCP protocol. Supports stdio transport for Cursor/IDE integration as well as HTTP transport with health check endpoints.2MIT