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.
Latest Blog Posts
- 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