mcp-postgres
Provides tools for executing SQL queries (read-only by default), listing tables, and describing table structures in a PostgreSQL database.
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.
mcp-postgres
MCP tool server providing PostgreSQL database access for AI agents.
Tools
Tool | Description |
| Execute SQL queries (read-only by default) |
| List all tables in a schema |
| Get table structure (columns, types, constraints) |
Related MCP server: PostgreSQL MCP Server
Quick Start
cp .env.example .env
# Edit .env with your Postgres connection details
make install
make serverEnvironment Variables
Variable | Default | Description |
|
| PostgreSQL host |
|
| PostgreSQL port |
|
| Database user |
| Database password | |
|
| Database name |
|
| Enforce read-only queries |
|
| Transport: |
|
| Server port (http only) |
Set
POSTGRES_READONLY=falseto enable read/write mode (INSERT, UPDATE, DELETE, etc.).
Endpoints
Path | Method | Description |
| GET | Health check for K8s probes |
| GET | Server info (name, version, transports) |
| POST | MCP Streamable-HTTP transport |
| GET | MCP SSE transport (legacy) |
Usage with .mcp.json
{
"mcpServers": {
"postgres": {
"type": "stdio",
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "MCP_TRANSPORT=stdio",
"-e", "POSTGRES_HOST=host.docker.internal",
"-e", "POSTGRES_PORT=5432",
"-e", "POSTGRES_USER=postgres",
"-e", "POSTGRES_PASSWORD=secret",
"-e", "POSTGRES_DB=mydb",
"ghcr.io/mgcrea/mcp-postgres"
]
}
}
}Use
host.docker.internalto connect to a PostgreSQL instance running on the host machine.
Docker
make docker-build
make docker-runTool 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
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI agents to inspect and query PostgreSQL databases safely, with features like listing tables, retrieving schemas, and running read-only SQL queries.3-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases through natural language queries, schema inspection, and safe SQL execution.4 npm1ISC
- AlicenseNot gradedqualityDmaintenanceEnables AI models to execute SQL queries, list tables, and describe table structures on a local PostgreSQL database.3 npmISC
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases, providing tools for querying, table listing, schema exploration, and multi-environment management with write protection and schema scoping.1MIT