
Postgres MCP Server
A Model Context Protocol server that enables querying PostgreSQL databases with tools for executing SELECT queries, inspecting database schemas, and listing tables through natural language.
README
MCP Postgres Server
A Model Context Protocol server for querying PostgreSQL databases with tools for data retrieval and schema inspection.
Setup
Prerequisites: Python 3.11+ and PostgreSQL
# Install dependencies
pip install -r requirements.txt
# Configure database connection (defaults shown)
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_DB=housing
Usage
Development
Run the following command to start the server in development mode and launch the MCP Inspector:
mcp dev main.py
MCP Client Integration
You can also add the following to your MCP client configuration to use the server:
{
"mcpServers": {
"postgres": {
"command": "python",
"args": ["main.py"],
"env": {
"POSTGRES_HOST": "localhost",
"POSTGRES_PORT": "5432",
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "postgres",
"POSTGRES_DB": "housing"
}
}
}
}
See mcp.json for an example of how to add the server in Cursor IDE.
Available Tools
query_database
- Execute SELECT queries (with SQL injection protection)get_table_schema
- Get table column information and constraintslist_tables
- List all database tablespostgres://schema
- Access complete database schema (resource)
Comparison with Official MCP Postgres Server
This implementation differs from the official @modelcontextprotocol/server-postgres in several key ways:
Feature | This Server (Python) | Official Server (TypeScript) |
---|---|---|
Safety | Guards against SQL injection | No protection |
Connection Pooling | ✅ Built-in (asyncpg) | ❌ Single connection |
Security
- Only
SELECT
statements allowed - Parameterized queries supported
- Environment-based configuration (no hardcoded credentials)
Next Steps
- [ ] Implement auth for postgres - currently I'm still relying on env variables which doesn't seem very secure
- [ ] Extend this to run on multiple databases and potentially multiple postgres instances as well
- [ ] Implement table / column pruning
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.