mcp-postgres-server
Provides tools for interacting with PostgreSQL databases, enabling SQL query execution, table listing, and connection testing.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
PostgreSQL & Vertica MCP Server
A professional Model Context Protocol (MCP) server providing## π§© Project Structure
mcp-postgres-server/
βββ postgres_main.py # PostgreSQL server entry point
βββ vertica_main.py # Vertica server entry point
βββ config.py # Configuration and logging
βββ servers/
β βββ postgres_server.py # PostgreSQL MCP server implementation
β βββ vertica_server.py # Vertica MCP server implementation
βββ run_postgres_mcp.sh / run_postgres_mcp.bat # PostgreSQL wrapper scripts
βββ run_vertica_mcp.sh / run_vertica_mcp.bat # Vertica wrapper scripts
βββ setup_mcp.sh # Setup and testing script
βββ test_connection.py # PostgreSQL connection test
βββ test_vertica_connection.py # Vertica connection test
βββ client_json_config_example/ # Editor config templates for both servers
βββ .env.example # Environment template
βββ README.md # This file
```se access from AI tools like Claude Desktop and Zed Editor.
**Supports:** PostgreSQL and Vertica databases
---
## π Features
- **Dual Database Support:** PostgreSQL and Vertica database access
- **Direct Database Access:** Securely run SQL queries from AI assistants
- **Easy Integration:** Works out-of-the-box with Claude Desktop and Zed Editor
- **Cross-Platform:** Supports Linux, macOS, and Windows
- **Automatic Lifecycle:** Server starts/stops automatically with your editor
- **Safe & Audited:** Parameterized queries, error handling, and logging
---
## β‘ Quick Start
### 1. Prerequisites
- Python 3.13+
- PostgreSQL or Vertica database (or both)
- [`uv`](https://docs.astral.sh/uv/) package manager
### 2. Installation
```bash
git clone https://github.com/Nayab-zak/mcp-postgres-server.git
cd mcp-postgres-server
uv sync
cp .env.example .env # Edit .env with your DB details3. Configuration
Edit .env with your database connection strings:
For PostgreSQL:
DB_URL=postgresql://username:password@localhost:5432/database_nameFor Vertica:
VERTICA_HOST=localhost
VERTICA_PORT=5433
VERTICA_DB=VMart
VERTICA_USER=dbadmin
VERTICA_PASSWORD=your_passwordFor Claude Desktop/Zed Editor, see client_json_config_example/ for ready-to-use config templates:
claude_desktop_config.json- PostgreSQL onlyvertica_claude_desktop_config.json- Vertica onlycombined_claude_desktop_config.json- Both serverszed_settings.json- PostgreSQL only for Zedvertica_zed_settings.json- Vertica only for Zedcombined_zed_settings.json- Both servers for Zed
4. Run the Servers
PostgreSQL Server:
Linux/macOS:
./run_postgres_mcp.shWindows:
run_postgres_mcp.bat
Vertica Server:
Linux/macOS:
./run_vertica_mcp.shWindows:
run_vertica_mcp.bat
Or let Claude Desktop/Zed Editor start the servers automatically when you ask database questions.
π₯οΈ How to Check if Servers are Running
PostgreSQL Server:
Linux/macOS:
ps aux | grep PostgresMCPServer # or ps aux | grep "python postgres_main.py"Windows:
tasklist | findstr PostgresMCPServer tasklist | findstr python
Vertica Server:
Linux/macOS:
ps aux | grep VerticaMCPServer # or ps aux | grep "python vertica_main.py"Windows:
tasklist | findstr VerticaMCPServer tasklist | findstr python
If you only see the grep/findstr line, the server is not running.
Related MCP server: postgres-mcp
π Server Lifecycle
Automatic: Servers start/stop automatically with Claude Desktop or Zed Editor.
Manual: You can start/stop them from the terminal for testing.
No need to restart manually during normal useβthe editor manages them for you.
Multiple servers: You can run both PostgreSQL and Vertica servers simultaneously.
π οΈ Available Tools
Tool | Description | Example Usage |
| Test DB connectivity | "Test the database connection" |
| Execute SQL queries | "Show me the first 5 users" |
| List all tables with metadata | "List all tables in the database" |
π§βπ» Manual Testing
PostgreSQL:
uv run python test_connection.py # Test PostgreSQL connection
uv run python postgres_main.py # Run PostgreSQL server directlyVertica:
uv run python test_vertica_connection.py # Test Vertica connection
uv run python vertica_main.py # Run Vertica server directlyπ§© Project Structure
mcp-postgres-server/
βββ main.py # Entry point
βββ config.py # Configuration and logging
βββ servers/
β βββ postgres_server.py # MCP server implementation
βββ run_mcp.sh / run_mcp.bat # Wrapper scripts
βββ setup_mcp.sh # Setup and testing script
βββ test_connection.py # DB connection test
βββ client_json_config_example/ # Editor config templates
βββ .env.example # Environment template
βββ README.md # This fileπ Troubleshooting
Connection failed?
PostgreSQL: Check if PostgreSQL is running:
pg_isready -h localhost -p 5432Vertica: Check if Vertica is running and accessible on the configured port
Verify credentials in
.env
Server won't start?
PostgreSQL: Test connection:
uv run python test_connection.pyVertica: Test connection:
uv run python test_vertica_connection.pyCheck logs:
tail -f logs/app.log
Editor integration issues?
Linux/macOS: Ensure full path to wrapper scripts in editor config and make them executable
Windows: Ensure full path to
.batscripts in editor config with proper backslashesUse the appropriate config templates in
client_json_config_example/Restart your editor after config changes
π Security Notes
Parameterized queries prevent SQL injection
All DB operations are logged
Supports read-only DB users for safety
Error messages are sanitized
π License
MIT License β see the LICENSE file for details.
π€ Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/your-feature)Commit your changes (
git commit -m 'Add your feature')Push to the branch (
git push origin feature/your-feature)Open a Pull Request
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MCP server for PostgreSQL diagnostics: slow queries, missing indexes, connection pressure.
MCP server for interacting with the Supabase platform
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA secure MCP server that enables querying PostgreSQL databases through an SSH tunnel with enforced read-only access, connection pooling, and comprehensive data exploration tools.ISC
- AlicenseAqualityBmaintenanceMCP server with 14 tools for PostgreSQL database operations. Query databases, explore schemas, analyze tables, with SQL injection prevention and read-only mode by default.1412MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that provides tools for PostgreSQL database operations and Swagger/OpenAPI integration, enabling database queries and API interactions through MCP.-
- AlicenseNot gradedqualityNot gradedmaintenanceMCP server for connecting to databases (PostgreSQL, MySQL, SQL Server, Redis) enabling SQL queries, table exploration, and Redis key-value operations.1MIT