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 Claude to the Northwind sample PostgreSQL database. Ask Claude natural language questions and it will query the database on your behalf.
What is this?
This project lets Claude act as a data analyst over the Northwind database — a classic sample dataset covering customers, orders, products, employees, and suppliers. Claude 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
Before you start, make sure you have the following installed:
Tool | Version | Download |
Python | 3.11+ | |
Docker Desktop | Latest | |
Node.js (for Claude Code) | 18+ |
Setup
1. Clone the repository
git clone <your-repo-url>
cd postgres_mcp2. Start the database
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:16imageDownload
northwind.sqlfrom GitHub (~2 minutes depending on your connection)Initialise the database automatically
Verify the database is ready:
docker compose psThe db service should show healthy.
3. Set up your environment file
cp .env.example .envThe default .env connects to the Docker container:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/northwindNo changes needed unless you are using a different PostgreSQL instance.
4. Install Python dependencies
pip install -e .If you get a
hatchlingerror, runpip install hatchlingfirst, then retry.
Alternatively, install dependencies directly without the editable install:
pip install "mcp[cli]>=1.0.0" psycopg2-binary python-dotenvConnecting to Claude
Option A — Claude Code CLI (recommended)
Install Claude Code if you have not already:
npm install -g @anthropic-ai/claude-codeRegister 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 B — Claude Desktop (claude.ai)
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"
}
}
}
}Restart Claude Desktop. The MCP tools will appear automatically in new conversations.
Available tools
Once connected, Claude 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 |
Examples of claude prompts to generate reports from NorthWind DB
"Show me monthly revenue for 1997, as a bar chart. Include a trend line and highlight the top 3 months."

"Who are our top 20 customers by total spend? Show a horizontal bar chart and flag any who haven't ordered in 90+ days."

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 the database
docker compose downTo also delete the stored data:
docker compose down -vTroubleshooting
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 to appear in the system tray before retrying.
pip install -e . fails with a hatchling error
pip install hatchling
pip install -e .Claude says the MCP server is not connected
Confirm the database is running:
docker compose psConfirm
server.pypath in your MCP config is the full absolute pathConfirm
DATABASE_URLmatches your Docker setup
psycopg2 installation fails on Windows
Use the binary build which has no system dependencies:
pip install psycopg2-binaryPort 5432 is already in use
Another PostgreSQL instance is running locally. Either stop it or change the port in docker-compose.yml:
ports:
- "5433:5432"Then update your DATABASE_URL to use port 5433.
License
This project is released under the MIT License. You are free to use, modify, and distribute it for personal or commercial purposes, including connecting it to your own business database.
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
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