postgres-mcp-server
Provides tools to execute SQL queries and inspect database schema in a PostgreSQL instance.
Click on "Deploy 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 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.
PostgreSQL MCP Server
An MCP server that exposes PostgreSQL database operations as tools for AI assistants.
What is MCP?
Model Context Protocol (MCP) connects AI assistants to external tools and data. This server lets AI assistants execute SQL queries and inspect your PostgreSQL database schema.
Related MCP server: PostgreSQL MCP Server
Setup
Python version: This project currently supports Python 3.10–3.13. Python 3.14 is excluded due to upstream dependency wheel support (e.g., psycopg2-binary and pydantic-core).
1. Install Dependencies
Note: This project uses Poetry for dependency management. If you don't have Poetry installed, you can install it with:
curl -sSL https://install.python-poetry.org | python3 -See the official Poetry documentation for alternative installation methods.
poetry install2. Configure Database
Copy .env.example to .env and add your PostgreSQL credentials:
cp .env.example .envEdit .env:
DB_NAME=your_database
DB_USER=postgres
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432Testing
MCP Inspector (Recommended)
Note: The Inspector runs via
npx, so you need Node.js (which includes npm). If you don't have it installed, get it from the official Node.js installer.
npx @modelcontextprotocol/inspector poetry run python postgres-mcp-server/main.pyThis opens a web UI where you can:
View available tools under the Tools tab
Test
get_schemaSee real-time results
Quick Test
poetry run python postgres-mcp-server/main.pyPress Ctrl+C to stop. No errors = working correctly.
Available Tools
get_schema() - Get database schema
Connect to Cursor
Add to your Cursor MCP config (global settings):
{
"mcpServers": {
"postgres": {
"command": "poetry",
"args": ["-C", "/absolute/path/to/postgres-mcp-server", "run", "python", "postgres-mcp-server/main.py"]
}
}
}Replace /absolute/path/to/postgres-mcp-server with your actual project path.
Future Proof Data Science - Teaching data scientists to optimize workflows with AI
This server cannot be deployed
Maintenance
Related MCP Connectors
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
- SchemaOAuthai.schemalabs
The AI that understands raw data: Schema over your tables and databases, as MCP tools.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to execute SQL queries and inspect PostgreSQL database schema.-
- FlicenseNot gradedqualityDmaintenanceConnects AI assistants to PostgreSQL databases, enabling schema inspection and SQL query execution through MCP tools.-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to securely interact with PostgreSQL databases through a standardized MCP interface, supporting SQL queries, schema inspection, and database management.MIT
- FlicenseNot gradedqualityBmaintenanceEnables agents to run SQL queries against PostgreSQL databases through MCP with connection pooling, tenant isolation, and read-only guardrails. Supports introspection of schemas, tables, and columns.-