mcp-postgres
Provides tools for executing SQL queries (read-only by default), listing tables, and describing table structures in a PostgreSQL database.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-postgreslist all tables in the public schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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-runThis server cannot be installed
Maintenance
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
- FlicenseAqualityDmaintenanceEnables AI agents to inspect and query PostgreSQL databases safely, with features like listing tables, retrieving schemas, and running read-only SQL queries.Last updated3
- Flicense-qualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases through natural language queries, schema inspection, and safe SQL execution.Last updated151
- Flicense-qualityDmaintenanceEnables AI models to execute SQL queries, list tables, and describe table structures on a local PostgreSQL database.Last updated8
- Alicense-qualityCmaintenanceEnables 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.Last updated1MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Comprehensive PostgreSQL documentation and best practices, including ecosystem tools
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/mgcrea/mcp-postgres'
If you have feedback or need assistance with the MCP directory API, please join our Discord server