Based off of the official TypeScript implementation server: https://github.com/modelcontextprotocol/servers/tree/main/src/postgres
Install deps
uv sync --frozen --all-groupsAdd your Postgres database URI:
cp .env.example .env
$EDITOR .envpoe mcp-devInstall to Claude Desktop:
poe install-claude-desktopAdd to other clients:
{
"mcpServers": {
"psql": {
"command": "/opt/homebrew/bin/uv",
"args": [
"run",
"--with",
"mcp[cli]",
"--with-editable",
"/Users/robby/projects/mcp-psql",
"mcp",
"run",
"/Users/robby/projects/mcp-psql/server.py"
],
"env": {
"DATABASE_URI": "postgresql://username:password@localhost/my-db"
}
}
}
}Run:
uv run --env-file .env server.py --transport sseAdd to client config:
{
"mcpServers": {
"psql": {
"url": "http://localhost:8000/sse",
}
}
}