Simple PostgreSQL MCP Server is an MCP server that connects AI assistants directly to PostgreSQL relational databases. Developed by Netanel Bollag, it serves as both a lightweight interface for querying data and an educational template for developers learning to build their own Model Context Protocol tools. Software engineers, data analysts, and researchers use this server to interact with schemas and records through natural language. The server exposes database querying tools such as execute_query and test_connection, alongside dedicated resources for inspecting table lists and schema definitions across a specified database namespace. It also implements pre-built prompt templates for automated query generation and analytical query construction. The codebase is written in Python and operates using Astral's uv package manager, making it simple to inspect, adapt, or expand for custom relational workflows. It enables conversational agents to fetch data, inspect column types, verify connections, and run SELECT queries against local or hosted PostgreSQL instances.
Category: Databases & Data Stores
Tags: database, postgresql, relational, SQL
Visit Simple PostgreSQL MCP Server
bash uv venv source .venv/bin/activate uv pip install -r requirements.txt 3. Add the server configuration to your MCP client (such as Claude Desktop) under mcpServers: json { "mcpServers": { "postgres": { "command": "/path/to/uv", "args": [ "--directory", "/path/to/simple-psql-mcp", "run", "postgres" ], "env": { "DSN": "postgresql://username:password@localhost:5432/my-db", "SCHEMA": "public" } } } } 4. Alternatively, execute ./generate_mcp_config.sh to generate the configuration interactively. 5. Test the setup using npx @modelcontextprotocol/inspector uv --directory . run postgres -e DSN=postgresql://username:password@hostname:port/database -e SCHEMA=public.Part of MCP Servers
Simple PostgreSQL MCP Server is an open source Model Context Protocol server that allows AI assistants like Claude to connect to PostgreSQL databases. It provides tools to test database connections and run queries, resources to inspect schemas and tables, and prompt templates for building analytical SQL queries.
You install it by cloning the repository, creating a virtual environment with uv, and installing dependencies via requirements.txt. You then configure your client using the provided JSON structure with your PostgreSQL DSN and schema, or run the generate_mcp_config.sh script.
It works with any client supporting the Model Context Protocol standard, including Claude Desktop and the MCP Inspector interface. Claude Desktop supports its tools, resources, and prompt templates natively.
No. The project is an experimental template meant for learning and local development. It checks whether queries start with SELECT, but it does not provide comprehensive protection against SQL injection and should not be run in production environments.
Yes, Simple PostgreSQL MCP Server is open source software released under the MIT license. The full source code is publicly accessible on GitHub.