Simple PostgreSQL MCP Server
About
A beginner-friendly MCP server template featuring a PostgreSQL connector with clean, easy-to-understand code. Perfect for developers new to Model Context Protocol who want to experiment and create their own AI tool connectors with minimal setup.
Details
- Author
- NetanelBollag
- GitHub stars
- 31
- Downloads
- 305
- Categories
- Database, Other
Jump to
- execute_query tool – run SQL queries against the database
- test_connection tool – verify the database connection
- Resources: db://tables, db://tables/{table_name}, db://schema
- Prompts for query generation and analytical query building
- Template structure for extending with custom MCP servers
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Simple PostgreSQL MCP ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Prerequisites: Python 3.8+, uv, npx, and a PostgreSQL database. Set up a virtual environment, install dependencies, then run the server with the MCP Inspector using npx @modelcontextprotocol/inspector uv --directory . run postgres -e DSN=... -e SCHEMA=public. Alternatively, configure an AI assistant (e.g., Claude Desktop) with a JSON configuration file, or use the included generate_mcp_config.sh script. Once connected, ask the LLM questions in natural language about your data.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"simple postgresql mcp server": {
"simple-psql-mcp": {
"command": "uv",
"args": [
"venv"
]
}
}
}
}
McpServers
{
"simple-psql-mcp": {
"command": "uv",
"args": [
"venv"
]
}
}
Simple PostgreSQL MCP Server
This is a template project for those looking to build their own MCP servers. I designed it to be dead simple to understand and adapt - the code is straightforward with MCP docs attached so you can quickly get up to speed.
What is MCP?
TL;DR - It's a way to write plugins for AI
Model Context Protocol (MCP) is a standard way for LLMs to interact with external tools and data. In a nutshell:
- Tools allow the LLM to execute commands (like running a database query)
- Resources are data you can attach to conversations (like attaching a file to a prompt)
- Prompts are templates that generate consistent LLM instructions
Features
This PostgreSQL MCP server implements:
1. Tools
- execute_query - Run SQL queries against your database
- test_connection - Verify the database connection is working
2. Resources
- db://tables - List of all tables in the schema
- db://tables/{table_name} - Schema information for a specific table
- db://schema - Complete schema information for all tables in the database
3. Prompts
- Query generation templates
- Analytical query builders
- Based on the templates in this repo
Prerequisites
- Python 3.8+
- uv - Modern Python package manager and installer
- npx (included with Node.js)
- PostgreSQL database you can connect to
Quick Setup
1. Create a virtual environment and install dependencies:
# Create a virtual environment with uv
uv venv
# Activate the virtual environment
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
uv pip install -r requirements.txt
2. Run the server with the MCP Inspector:
# Replace with YOUR actual database credentials
npx @modelcontextprotocol/inspector uv --directory . run postgres -e DSN=postgresql://username:password@hostname:port/database -e SCHEMA=public
> Note: If this is your first time running npx, you'll be prompted to approve the installation. Type 'y' to proceed.
After running this command, you'll see the MCP Inspector interface launched in your browser. You should see a message like:
MCP Inspector is up and running at http://localhost:5173
If the browser doesn't open automatically, copy and paste the URL into your browser. You should see something like this:

3. Using the Inspector:
- Click the "Connect" button in the interface (unless there's an error message in the console on the bottom left)
- Explore the "Tools", "Resources", and "Prompts" tabs to see available functionality
- Try clicking on listed commands or typing resource names to retrieve resources and prompts
- The interface allows you to test queries and see how the MCP server responds
4. Take a look at the official docs
Official server developers guide: https://modelcontextprotocol.io/quickstart/server
More on the inspector: https://modelcontextprotocol.io/docs/tools/inspector
Connect Your AI Tool to the Server
You can configure the MCP server for your AI assistant by creating an MCP configuration file:
{
"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"
}
}
}
}
Alternatively, you can generate this config file using the included script:
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





