postgres-mcp
Provides tools for interacting with a PostgreSQL database, enabling read-only queries, data modifications, DDL operations, atomic transactions, and schema introspection.
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., "@postgres-mcpshow me the users table 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.
PostgreSQL MCP Server
A Model Context Protocol (MCP) server written in Node.js that exposes a full set of tools for running DDL and DML operations against a PostgreSQL database.
Features
Tool | Category | Description |
| Utility | Test DB connection & get server version |
| DQL | Run a SELECT / EXPLAIN (read-only) |
| DML | Run INSERT / UPDATE / DELETE / MERGE |
| DDL | Run CREATE / ALTER / DROP / TRUNCATE |
| DML+DDL | Run multiple statements atomically |
| Introspection | List all schemas |
| Introspection | List tables in a schema |
| Introspection | Show columns, types, PK, nullability |
| Introspection | Show indexes for a table |
Related MCP server: PostgreSQL MCP Server
Prerequisites
Node.js >= 18
A running PostgreSQL instance
Setup
# 1. Install dependencies
cd "Postgres MCP"
npm install
# 2. Create your .env file
copy .env.example .env
# Then edit .env with your database credentials.env fields
Variable | Required | Default | Description |
| No |
| DB host |
| No |
| DB port |
| Yes | — | Database name |
| Yes | — | DB username |
| Yes | — | DB password |
| No |
| Pool size |
| No |
| Idle timeout (ms) |
| No |
| Connect timeout (ms) |
Running
# Start the server (communicates over stdio)
npm start
# Development mode (restarts on file changes)
npm run devRegister with Claude Desktop / MCP Client
Add this to your MCP client config (e.g., claude_desktop_config.json):
{
"mcpServers": {
"postgres": {
"command": "node",
"args": ["C:/Pooja Data/services-app/mcps/Postgres MCP/src/index.js"],
"env": {
"POSTGRES_HOST": "localhost",
"POSTGRES_PORT": "5432",
"POSTGRES_DB": "your_database",
"POSTGRES_USER": "your_username",
"POSTGRES_PASSWORD": "your_password"
}
}
}
}Tool Usage Examples
Run a SELECT query
{
"tool": "pg_query",
"sql": "SELECT * FROM users WHERE status = $1 LIMIT 10",
"params": ["active"]
}Insert a row
{
"tool": "pg_execute",
"sql": "INSERT INTO users (name, email) VALUES ($1, $2) RETURNING id",
"params": ["Alice", "alice@example.com"],
"returning": true
}Create a table
{
"tool": "pg_ddl",
"sql": "CREATE TABLE IF NOT EXISTS products (id SERIAL PRIMARY KEY, name TEXT NOT NULL, price NUMERIC(10,2))"
}Run a transaction
{
"tool": "pg_transaction",
"statements": [
{ "sql": "UPDATE accounts SET balance = balance - $1 WHERE id = $2", "params": [100, 1] },
{ "sql": "UPDATE accounts SET balance = balance + $1 WHERE id = $2", "params": [100, 2] }
]
}Safety
pg_queryonly allows DQL statements (SELECT, EXPLAIN, etc.) — DML/DDL are rejected.pg_executeonly allows DML — DDL is rejected.pg_ddlonly allows DDL.pg_transactionwraps all statements in BEGIN/COMMIT and rolls back on any error.Transaction control keywords (BEGIN, COMMIT, ROLLBACK) in raw SQL are blocked — use
pg_transactioninstead.Results are capped at 200 rows to avoid oversized payloads.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This 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 Connectors
Comprehensive PostgreSQL documentation and best practices, including ecosystem tools
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Versioned agent memory in your own Postgres: portable context, permissioned, audit trail.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that enables interaction with PostgreSQL databases to list tables, retrieve schemas, and execute read-only SQL queries.12MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with PostgreSQL databases through the Model Context Protocol, providing database schema exploration, table structure inspection, and SQL query execution capabilities.15MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server implementation that provides a simple interface to interact with PostgreSQL databases, enabling SQL queries, database operations, and schema management through MCP.-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases by executing SQL queries and inspecting database schemas. It provides tools to facilitate database exploration and management through the Model Context Protocol.-
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/poojajuneja900/postgres-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server