- Home
- MCP servers
- PostgreSQL MCP AI Explorer
PostgreSQL MCP AI Explorer
- typescript
0
GitHub Stars
typescript
Language
4 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"chlee10-postgresql_mcp": {
"command": "poetry",
"args": [
"run",
"python",
"-m",
"postgresql_mcp.server",
"--sse"
],
"env": {
"DB_HOST": "localhost",
"DB_NAME": "postgres",
"DB_PORT": "5432",
"DB_USER": "postgres",
"PYTHONPATH": "<project_path>",
"DB_PASSWORD": "your_password",
"OPENAI_API_KEY": "sk-OPENAI-KEY",
"ANTHROPIC_API_KEY": "sk-ANTHROPIC-KEY"
}
}
}
}This MCP server connects a PostgreSQL database to the MCP (Model Context Protocol), enabling you to converse with your data in natural language. You can query, explore, and visualize data by chatting with the AI, then instantly see results and charts without writing complex SQL.
How to use
You interact with the MCP server through an MCP client, such as Claude Desktop in stdio mode or a Streamlit-based web UI. Start by initializing your demo data, configure your client to connect to the local MCP server, and then ask natural language questions. The system translates your questions into SQL queries, runs them against PostgreSQL, and returns results with optional Plotly charts in the UI.
How to install
Prerequisites: install Python 3.10 or newer, have a PostgreSQL database available (local or Docker), and install Poetry as your Python package manager.
# Install dependencies
poetry install
# Create an environment file with database and API keys (see .env guidance below)
# Edit .env after creating it
Additional configuration and run flow
Configure the MCP server to run in stdio (local) mode or connect via Claude Desktop in SSE or stdio mode.
To connect Claude Desktop in stdio mode, add the MCP server entry to Claude Desktop's configuration as shown below. This enables Claude Desktop to start the MCP server automatically when launched.
{
"mcpServers": {
"postgresql": {
"command": "<project_path>\\.venv\\Scripts\\python.exe",
"args": ["-m", "postgresql_mcp.server"],
"env": {
"PYTHONPATH": "<project_path>"
}
}
}
}
Start via Claude Desktop (stdio auto-connect) and Streamlit (SSE)
For Claude Desktop in stdio mode, configure as shown above and then restart Claude Desktop. The MCP server connects automatically and you can start asking natural language questions right away.
For a web UI using Streamlit with SSE, run the following in two terminal windows.
# Terminal 1: start the MCP server in SSE mode
poetry run python -m postgresql_mcp.server --sse
# Terminal 2: start the Streamlit web UI
poetry run streamlit run streamlit_app.py
Available tools
chat_interface
Interactive chat interface for natural language queries and results display.
viz_charts
Auto-generated Plotly charts based on query results for visual insights.