postgres-mcp
Provides PostgreSQL database management capabilities including connection management, schema browsing, SQL query execution, stored procedure analysis, and test data generation.
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 schema of 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 Manager + MCP Server
A complete Python application for PostgreSQL database management with two modes:
Desktop GUI (Tkinter) — for direct human use
MCP Server — for AI-assisted database analysis via Claude Desktop
What It Does
🔌 Connection Management
Save multiple named PostgreSQL connection profiles in
config.iniTest connections before saving
Fields: host, port, database, username, password, SSL mode
🌲 Object Explorer
Browse: Schemas → Tables → Columns (with types, nullability, PK markers)
Browse: Schemas → Views
Double-click a table → auto-generates
SELECT * FROM ... LIMIT 100Right-click → Select Top 100, Show Columns
📝 SQL Query Editor
Syntax highlighting for SQL keywords
Press F5 to execute (or click Run)
Query history (session-based, navigate with ↑/↓ buttons)
Select specific text to run only that portion
📊 Results Grid
Scrollable table with column headers
Row count + elapsed time display
Export to CSV with one click
🧪 SP Analyzer + Test Data Generator
Upload a .sql file containing a stored procedure or function:
Analyse — extracts SELECT queries, detects referenced tables, infers WHERE conditions
Generate Preview — creates Faker-based test data respecting types, FKs, enums, UNIQUE
Insert Test Data — inserts into an open transaction (NOT committed)
Run your SP manually in the query editor to verify
Commit or Rollback — on-demand, manual control
🤖 MCP Server (AI-Powered Mode)
When connected to Claude Desktop, Claude can:
Fetch SP bodies directly from
pg_procExecute SELECT queries found in the SP
Recursively follow SQL strings stored inside DB column values (the killer feature)
Understand schema, FKs, enums, CHECK constraints
Generate and insert test data in FK-dependency order
Wait for you to verify, then commit or rollback
Related MCP server: dbecho
Prerequisites
Mandatory
Requirement | Version | Check Command |
Python | 3.10+ |
|
pip | any |
|
PostgreSQL | 10+ (any server) |
|
Optional (for MCP mode)
Requirement | Purpose |
Claude Desktop | AI client that connects to our MCP server |
⚠️ Python must be in your system PATH. Run
python --versionin a terminal to verify.
Installation
Option 1: Run the installer script (Windows)
install.batThis checks for Python, creates a virtual environment, and installs all dependencies.
Option 2: Manual
pip install -r requirements.txtDependencies installed:
psycopg2-binary— PostgreSQL driversqlparse— SQL statement parserFaker— realistic test data generationmcp[cli]— Anthropic's MCP SDK for the AI server
Running the Application
Desktop GUI
run.batOr manually:
python main.pyMCP Server (for Claude Desktop)
python mcp_server.pyWith auto-connect:
python mcp_server.py --host localhost --port 5432 --db mydb --user postgres --password secret
python mcp_server.py --profile local
python mcp_server.py --dsn "postgresql://user:pass@host:5432/db"Configuring Claude Desktop
Copy
claude_desktop_config.jsonto%APPDATA%\Claude\claude_desktop_config.json(or merge into your existing config)Restart Claude Desktop
The
postgres-mcptools will appear automatically
Example config:
{
"mcpServers": {
"postgres-mcp": {
"command": "python",
"args": ["C:/Balaji/MyProjects/postgres-mcp/mcp_server.py"],
"cwd": "C:/Balaji/MyProjects/postgres-mcp"
}
}
}Configuration — config.ini
[app]
theme = clam
font_size = 11
row_limit = 1000
default_test_rows = 10
[profile_local]
name = Local PostgreSQL
host = localhost
port = 5432
database = postgres
username = postgres
password =
ssl_mode = preferAdd more profiles by duplicating the [profile_xxx] section with a unique name.
MCP Tools Reference
Tool | Description |
| Connect with host/port/db/user/password |
| Check if connected |
| Fetch SP/function source from pg_proc |
| List all SPs/functions in a schema |
| List base tables |
| List views |
| Get view SQL (discover real tables behind views) |
| Full metadata: columns, PKs, FKs, UNIQUEs, CHECKs |
| Read valid values from FK parent tables |
| List valid enum labels |
| Sample existing rows |
| Run any SELECT/read SQL |
| Run INSERT/UPDATE/DELETE inside safe test tx |
| Faker-based row generation |
| Open a write transaction |
| Insert row dicts into the open transaction |
| Commit permanently |
| Roll back all test inserts |
| Check if a test transaction is open |
Troubleshooting
Issue | Solution |
| Add Python to system PATH |
| Install Visual C++ Build Tools, or use |
MCP server not showing in Claude | Check |
Connection refused | Verify PostgreSQL is running and accepting connections on the configured host:port |
| Run |
License
MIT
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 Servers
- Alicense-qualityDmaintenanceAn extensible MCP server for database operations that supports PostgreSQL for managing schemas, tables, data, and user permissions. It features automatic migration recording for DDL changes and integrates with various AI-powered editors like Cursor, Zed, and Claude Code.Last updated172MIT
- AlicenseAqualityAmaintenanceAn MCP server that gives AI agents direct read-only access to PostgreSQL databases, enabling natural language analytics through tools for schema exploration, querying, trend analysis, and data quality checks.Last updated115MIT
- Flicense-qualityBmaintenanceAn MCP server that allows Claude to query and manipulate a PostgreSQL database using natural language, with tools for listing tables, describing tables, and performing CRUD operations.Last updated1
- Alicense-qualityDmaintenanceA Model Context Protocol (MCP) Server that allows AI models to securely interact with data hosted in Azure Database for PostgreSQL. It enables natural language querying, schema exploration, and data management through MCP clients like Claude Desktop and Visual Studio Code.Last updatedMIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
GibsonAI MCP server: manage your databases with natural language
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/tsbr007/post-gres-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server