Northwind PostgreSQL MCP Server
A read-only MCP server that connects Claude to the Northwind sample PostgreSQL database, allowing natural language queries to generate SQL and charts.
README
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.
Prerequisites
Before you start, make sure you have the following installed:
| Tool | Version | Download |
|---|---|---|
| Python | 3.11+ | https://www.python.org/downloads |
| Docker Desktop | Latest | https://www.docker.com/products/docker-desktop |
| Node.js (for Claude Code) | 18+ | https://nodejs.org |
Setup
1. Clone the repository
git clone <your-repo-url>
cd postgres_mcp
2. Start the database
Docker Desktop must be running (look for the whale icon in your system tray).
docker compose up -d
On first run this will:
- Pull the
postgres:16image - Download
northwind.sqlfrom GitHub (~2 minutes depending on your connection) - Initialise the database automatically
Verify the database is ready:
docker compose ps
The db service should show healthy.
3. Set up your environment file
cp .env.example .env
The default .env connects to the Docker container:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/northwind
No 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-dotenv
Connecting to Claude
Option A — Claude Code CLI (recommended)
Install Claude Code if you have not already:
npm install -g @anthropic-ai/claude-code
Register the MCP server:
claude mcp add postgres-northwind \
--env DATABASE_URL=postgresql://postgres:postgres@localhost:5432/northwind \
python /full/path/to/postgres_mcp/server.py
Replace /full/path/to/postgres_mcp with the actual path on your machine.
Verify it was registered:
claude mcp list
Start Claude Code and try it out:
claude
Then 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.json - macOS:
~/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 |
|---|---|
list_tables |
Lists all tables in the database |
describe_table |
Shows columns, types, and primary keys for a table |
sample_table |
Returns the first N rows of a table (max 100) |
query |
Runs any SELECT or WITH query (results capped at 500 rows) |
get_schema |
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 withSELECTorWITH - Database 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 down
To also delete the stored data:
docker compose down -v
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 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 ps - Confirm
server.pypath in your MCP config is the full absolute path - Confirm
DATABASE_URLmatches your Docker setup
psycopg2 installation fails on Windows
Use the binary build which has no system dependencies:
pip install psycopg2-binary
Port 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。