Northwind PostgreSQL MCP Server
Allows querying and exploring the Northwind sample PostgreSQL database through a read-only interface, providing tools to list tables, describe schemas, sample data, run SELECT/WITH queries, and retrieve full schema overview.
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., "@Northwind PostgreSQL MCP ServerShow me monthly revenue for 1997, as a bar chart."
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.
Northwind PostgreSQL MCP Server
A read-only MCP (Model Context Protocol) server that connects AI models to the Northwind sample PostgreSQL database. Ask natural language questions and the model will query the database on your behalf.
What is this?
This project lets an AI model act as a data analyst over the Northwind database — a classic sample dataset covering customers, orders, products, employees, and suppliers. The model can list tables, inspect schemas, run SQL queries, and generate charts, all through a secure read-only connection.
Related MCP server: AWS PostgreSQL MCP Server
Prerequisites
Tool | Version | Download |
Docker Desktop | Latest | |
Node.js (for Claude Code only) | 18+ | |
Python (for Claude Code / Desktop only) | 3.11+ |
Setup
1. Clone the repository
git clone <your-repo-url>
cd postgres_mcp2. Set up your environment file
cp .env.example .envEdit .env and fill in your Anthropic API key:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/northwind
ANTHROPIC_API_KEY=sk-ant-...3. Start all services
Docker Desktop must be running (look for the whale icon in your system tray).
docker compose up -dOn first run this will:
Pull the
postgres:16andopen-webuiimagesDownload
northwind.sqlfrom GitHub and initialise the databaseStart the MCP server and Open WebUI
Verify everything is ready:
docker compose psAll services should show running and db should show healthy.
Connecting to a model
Option A — Open WebUI + Ollama (browser-based, no API key needed)
Open WebUI gives you a browser chat interface powered by a local Ollama model. No API key or cloud service required.
1. Make sure Ollama is running with at least one model pulled:
ollama pull llama3
ollama serve2. Start all services:
docker compose up -d3. Seed the Open WebUI config (first time only — sets up the MCP connection automatically):
docker exec postgres_mcp-open-webui-1 python3 /app/backend/webui-init.py4. Open the UI:
Go to http://openwebui.localhost and create an admin account on first launch.
5. Verify connections:
Go to Admin Settings → Connections — Ollama should show as connected at
http://host.docker.internal:11434Go to Settings → Tools —
postgres-mcpshould be listed and connected athttp://mcp:8000/mcp
You can now pick any Ollama model and chat — it will query the Northwind database through the MCP tools.
Tip: Models that generate better charts:
qwen2.5-coder:7b,deepseek-coder-v2,phi4. Pull withollama pull <model>.
Option B — Claude Code CLI
Install Claude Code if you have not already:
npm install -g @anthropic-ai/claude-codeStart the database:
docker compose up -d dbRegister the MCP server:
claude mcp add postgres-northwind \
--env DATABASE_URL=postgresql://postgres:postgres@localhost:5432/northwind \
python /full/path/to/postgres_mcp/server.pyReplace /full/path/to/postgres_mcp with the actual path on your machine.
Verify it was registered:
claude mcp listStart Claude Code and try it out:
claudeThen ask: "List the tables in my database"
Option C — Claude Desktop
Open your Claude Desktop config file:
Windows:
C:\Users\<username>\AppData\Roaming\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add the following inside "mcpServers":
{
"mcpServers": {
"postgres-northwind": {
"command": "python",
"args": ["C:\\full\\path\\to\\postgres_mcp\\server.py"],
"env": {
"DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/northwind"
}
}
}
}Start the database first:
docker compose up -d dbRestart Claude Desktop. The MCP tools will appear automatically in new conversations.
Available tools
Once connected, the model has access to these tools:
Tool | Description |
| Lists all tables in the database |
| Shows columns, types, and primary keys for a table |
| Returns the first N rows of a table (max 100) |
| Runs any SELECT or WITH query (results capped at 500 rows) |
| Full schema overview — all tables and columns in one call |
Example prompts
"List all tables in the Northwind database"
"How many customers are there, and which countries do they come from?"
"Show me the top 10 best-selling products"
"Show monthly revenue for 1997 as a Chart.js bar chart"

"Who are our top 20 customers by total spend? Show a horizontal bar chart."

Security
All database access is read-only, enforced at two levels:
Application level — the
querytool rejects any SQL that does not start withSELECTorWITHDatabase level — every connection is opened with
readonly=True, so PostgreSQL itself will reject any write attempt even if the application check were bypassed
Table and column names supplied by users are validated against a strict identifier pattern before being used in queries, preventing SQL injection.
Stopping
docker compose downTo also delete stored data (resets the database and Open WebUI config):
docker compose down -vAfter
down -v, re-run the webui-init step on next startup to restore the MCP connection config.
Troubleshooting
docker compose up fails with "cannot find the file specified"
Docker Desktop is not running. Open it from the Start menu and wait for the whale icon in the system tray.
Open WebUI shows "Trouble accessing Ollama"
Ollama is not running. Start it with ollama serve in a terminal.
Open WebUI MCP connection fails
The tool URL must use the Docker service name, not localhost:
http://mcp:8000/mcpUsing localhost inside Docker will not work — mcp is the correct hostname.
pip install -e . fails with a hatchling error
pip install hatchling
pip install -e .Port 5432 is already in use
Another PostgreSQL instance is running locally. Change the port in docker-compose.yml:
ports:
- "5433:5432"Then update DATABASE_URL in .env to use port 5433.
psycopg2 installation fails on Windows
Use the binary build:
pip install psycopg2-binaryLicense
This project is released under the MIT License. You are free to use, modify, and distribute it for personal or commercial purposes.
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.
Latest Blog Posts
- 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/mosesliao/postgres-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server