PostgreSQL MCP Server (Model Context Protocol)
@VivekMalipatel
About PostgreSQL MCP Server (Model Context Protocol)
FastMCP Based MCP Server to Control Postgres
Basic information
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"Postgres_MCP_Server": {
"command": "python",
"args": [
"-m",
"venv",
".mcp"
]
}
}
}Tools
No tools detected
We auto-extract tools from the README. The maintainer can list them under a ## Tools heading to populate this section.
Overview
What is PostgreSQL MCP Server?
A FastMCP-powered Model Context Protocol server that gives AI assistants (Claude, Cursor, etc.) full, structured access to a PostgreSQL database β no SQL knowledge required from the user.
How to use PostgreSQL MCP Server?
Clone the repository, create a virtual environment, install dependencies from requirements.txt, and configure a .env file with database credentials. Then connect an MCP-compatible client (e.g., Claude Desktop) by adding the provided JSON block to its MCP config file. Alternatively, run manually with python postgres_mcp_server.py.
Key features of PostgreSQL MCP Server
- Exposes database as MCP Resources (read-only) and MCP Tools (read/write)
- Parameterised queries throughout β no SQL injection
- Structured stdout logs on every tool/resource call
- Schema inspection: list tables, column definitions
- Read/write/DDL operations via tools
- Raw SQL execution via the
execute_querytool
Use cases of PostgreSQL MCP Server
- AI assistant querying database in natural language
- Automated schema exploration and data preview
- Performing insert, update, delete operations through conversational interface
- Creating and dropping tables via AI assistant
FAQ from PostgreSQL MCP Server
What transport does PostgreSQL MCP Server use?
The server uses stdio transport (MCP protocol over standard input/output).
What are the runtime requirements?
Python 3.8+ and a PostgreSQL server (local or remote) with the uv package runner (recommended) or pip.
How are database credentials configured?
Via a .env file with POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD, or directly in the client config's env block.
What dependencies are required?
mcp[cli], asyncpg, psycopg2-binary, python-dotenv, httpx, uvicorn, and uv.
What are the limits on data access?
The postgres://data/{table_name} resource returns only the first 100 rows as a safe preview. Other tools allow configurable limits.
More Databases MCP servers
MongoDB Lens
fureyππ MongoDB Lens: Full Featured MCP Server for MongoDB Databases
PostgreSQL Model Context Protocol (PG-MCP) Server
stuzeromcp-server-duckdb
ktanaka101A Model Context Protocol (MCP) server implementation for DuckDB, providing database interaction capabilities
MCP Alchemy
runekaagaardA MCP (model context protocol) server that gives the LLM access to and knowledge about relational databases like SQLite, Postgresql, MySQL & MariaDB, Oracle, and MS-SQL.
Comments