PostgreSQL MCP Server
Provides tools for interacting with a PostgreSQL database, enabling AI assistants to execute SQL queries and inspect database schemas.
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., "@PostgreSQL MCP Servershow me the database 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: MCP Server for PostgreSQL
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 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-qualityDmaintenanceA Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.Last updated126,78027MIT
- Flicense-qualityDmaintenanceA 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.Last updated
- Flicense-qualityDmaintenanceA Model Context Protocol server that enables querying PostgreSQL databases with tools for executing SELECT queries, inspecting database schemas, and listing tables through natural language.Last updated
- Alicense-qualityFmaintenanceA Model Context Protocol server providing dual transport (HTTP and Stdio) access to PostgreSQL databases, allowing AI assistants to query databases and fetch schema information through natural language.Last updated9131MIT
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for managing Prisma Postgres.
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/guibracco/postgres-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server