execute_queryLABSCO SUMMARY
Its real output is the code, not the query tool.
Tools, resources and prompts are all demonstrated against one small domain, which is exactly what is missing from most MCP examples — and the bundled docs make the fork path short. Take the author's warning literally though: the only guard on a query is that it begins with SELECT, so this belongs on a scratch database, not on anything with customers in it.
What it is
A template project that happens to be a working PostgreSQL MCP server. It demonstrates all three MCP primitives against a real database: tools that execute queries, resources that expose the schema, and prompts that generate query templates. The code is kept straightforward with the MCP documentation bundled alongside it, so it can be read end to end and adapted into your own server.
What you get
- SQL run against your database, and a connection check for when nothing is coming back —
execute_query,test_connection - Schema browsable as resources rather than queries: every table in the schema, one table's structure, or the whole schema at once —
db://tables,db://tables/{table_name},db://schema - Prompt templates for query generation and analytical query building
- A worked example database: a script that starts a PostgreSQL container pre-populated with sample users and addresses tables
- A config generator script that writes the client configuration from your DSN and schema name, rather than editing JSON by hand
- A layout intended to be copied: add a directory under
/src, implement the server, add it to[project.scripts]inpyproject.toml
Requirements
A PostgreSQL database you can reach, and its DSN. Python 3.8+, the uv package manager, and npx from Node.js for the MCP Inspector. Create the environment with uv venv and install from requirements.txt. Two environment variables carry the configuration: DSN in the form postgresql://<YOUR_DB_USER>:<YOUR_DB_PASSWORD>@<YOUR_DB_HOST>:<YOUR_DB_PORT>/<YOUR_DB_NAME>, and SCHEMA, typically public. The client runs it as uv --directory <YOUR_PATH_TO_SIMPLE_PSQL_MCP> run postgres; the pyproject is simple-psql-mcp 1.0.0 with a postgres entry point. The author's own security note is blunt: the server checks that a query starts with SELECT and nothing beyond that is guaranteed, so do not point it at a production database.
Setup effort
Build from source — git clone https://github.com/NetanelBollag/simple-psql-mcp.git
USE CASES
Learning how an MCP server is put together
Read one small server that exercises tools, resources and prompts against a real database, then copy the layout for your own.
Asking questions of a development database
Browse the schema as resources first, then run the SELECT the assistant proposes against your scratch data.
Trying it without a database handy
Run the included setup script to get a PostgreSQL container with sample users and addresses tables, then connect to that.
2 tools
Listed in project docs. Your client may show a different list.
test_connectionBEFORE YOU INSTALL
What to know first
Tools you get
2 tools named in the project's documentation.
Requires
- Python 3.8+
- uv
- A PostgreSQL database you can connect to
- DSN (postgresql://username:password@hostname:port/database) and SCHEMA (typically public) in the client configuration
Where it runs
The documented client runs the server on your machine.
INSTALLATION
Connect your client
You clone this one yourself.
Server setup
git clone https://github.com/NetanelBollag/simple-psql-mcp.git
cd simple-psql-mcp
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txtMCP Clients
Any MCP client
{
"mcpServers": {
"postgres": {
"command": "<YOUR_PATH_TO_UV>",
"args": [
"--directory",
"<YOUR_PATH_TO_SIMPLE_PSQL_MCP>",
"run",
"postgres"
],
"env": {
"DSN": "postgresql://<YOUR_DB_USER>:<YOUR_DB_PASSWORD>@localhost:5432/<YOUR_DB_NAME>",
"SCHEMA": "public"
}
}
}
}