postgres-mcp-server
Provides tools for interacting with a PostgreSQL database, allowing users to list tables, describe schemas, run read queries, explain query plans, get database stats, and optionally execute write queries.
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-mcp-serverShow me the first 10 rows from the orders table"
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
An enterprise-ready Model Context Protocol (MCP) server built with Node.js & TypeScript for PostgreSQL databases. Compatible with Antigravity, Claude Desktop, Cursor, Continue, and any standard MCP client.
๐ Features & Tools Exposed
Tool Name | Mode | Description |
| Read-only | Lists all schemas, tables, views, estimated row counts, and table disk sizes. |
| Read-only | Details table schema: column types, nullability, defaults, primary keys, foreign keys, and indexes. |
| Read-only | Executes SELECT queries safely inside DB-level |
| Read-only | Generates PostgreSQL query execution plans ( |
| Read-only | Returns DB health stats: database size, top 10 largest tables, active connections, and cache hit ratios. |
| Write (Optional) | Executes |
Related MCP server: PostgreSQL MCP Server
๐ ๏ธ Quick Start
1. Install Dependencies & Build
npm install
npm run build2. Configure Environment Variables
Copy .env.example to .env and fill in your PostgreSQL credentials:
# Database Connection String
DATABASE_URL=postgresql://postgres:password@localhost:5432/mydb
# OR individual settings:
PGHOST=localhost
PGPORT=5432
PGUSER=postgres
PGPASSWORD=your_password
PGDATABASE=mydb
# Enable write capabilities if needed (Default: false)
ALLOW_WRITE_QUERIES=false๐ Registering with MCP Clients
This server uses standard stdio communication and can be added to any MCP-compliant application.
1. Antigravity Configuration
Add to your Antigravity MCP settings:
Global Config:
%USERPROFILE%\.gemini\antigravity-cli\mcp_config.json(Windows) or~/.gemini/antigravity-cli/mcp_config.json(Linux/macOS)Workspace Config:
.agents/mcp.json
{
"mcpServers": {
"postgres-db": {
"command": "node",
"args": [
"D:/Projects/AI/MCP/postgres-connector/dist/index.js"
],
"env": {
"DATABASE_URL": "postgresql://your_user:your_password@localhost:5432/your_project_db",
"ALLOW_WRITE_QUERIES": "false"
}
}
}
}2. Claude Desktop Configuration
Add to your Claude Desktop configuration file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"postgres-db": {
"command": "node",
"args": [
"D:/Projects/AI/MCP/postgres-connector/dist/index.js"
],
"env": {
"DATABASE_URL": "postgresql://your_user:your_password@localhost:5432/your_project_db",
"ALLOW_WRITE_QUERIES": "false"
}
}
}
}3. Cursor / Continue / Standard MCP Clients
For Cursor, Continue, or any other MCP host supporting stdio servers:
{
"mcpServers": {
"postgres-db": {
"command": "node",
"args": [
"D:/Projects/AI/MCP/postgres-connector/dist/index.js"
],
"env": {
"DATABASE_URL": "postgresql://your_user:your_password@localhost:5432/your_project_db",
"ALLOW_WRITE_QUERIES": "false"
}
}
}
}Tip (Development Mode): You can also run the server directly with
npx tsxwithout a build step:"command": "npx", "args": [ "-y", "tsx", "D:/Projects/AI/MCP/postgres-connector/src/index.ts" ]
๐งช Testing & Local Debugging
Option 1: Interactive GUI Testing with MCP Inspector (Recommended)
The official MCP Inspector allows you to visually trigger tool calls (list_tables, read_query, describe_table, etc.) and view response payloads in your browser:
Quick development testing (no compilation step required):
npx @modelcontextprotocol/inspector npx tsx src/index.tsProduction build testing:
npm run build npx @modelcontextprotocol/inspector node dist/index.js
The command will automatically open the inspector in your default browser (e.g. http://localhost:<port>/?MCP_INSPECTOR_API_TOKEN=...), where you can inspect available tools, fill in parameters, and view responses in real time.
Option 2: Live Integration via MCP Hosts
Register the server in your AI host config (such as Antigravity or Claude Desktop) as detailed in Registering with MCP Clients, then restart your host application to test tool invocation through natural language prompts.
Option 3: Code Compilation & Type Check
Verify TypeScript types and esbuild bundle output:
npm run build๐ Security Best Practices
By default, all queries executed via
read_queryrun insideBEGIN READ ONLY; ... COMMIT;transactions to prevent unexpected data mutations.Write queries via
execute_queryare disabled by default unlessALLOW_WRITE_QUERIES=true.
๐ License & Attribution
This project is licensed under the BSD 3-Clause License.
Mandatory Terms:
Attribution Required: You are free to use, modify, and distribute this software, provided that all copies retain the original copyright notice (
Copyright (c) 2026, Rajath Kumar D) and license terms.No Unauthorized Endorsement: You may not use the author's name (Rajath Kumar D) or contributors to endorse or promote derived products without prior written permission.
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
- AlicenseAqualityAmaintenanceMCP server with 14 tools for PostgreSQL database operations. Query databases, explore schemas, analyze tables, with SQL injection prevention and read-only mode by default.Last updated1410MIT
- Alicense-qualityCmaintenanceAn open-source MCP server for PostgreSQL schema introspection and guarded read-only queries. It enables MCP clients to discover schemas, tables, columns, indexes, relationships, and safe queryable data from a configured PostgreSQL database.Last updated30MIT
- Alicense-qualityCmaintenanceRead-only PostgreSQL MCP server that enables running SELECT queries, listing tables and schemas, and describing columns, with built-in protection against writes and malicious SQL attacks.Last updated484MIT
- Alicense-qualityDmaintenanceA secure, read-only PostgreSQL MCP server that provides safe database introspection and querying capabilities.Last updated25MIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
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/rajath002/postgres-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server