mcp-postgres
Connects to a PostgreSQL database and exposes schema inspection and safe SELECT query execution as MCP tools and resources for use with Claude Desktop or any MCP-compatible client.
README
mcp-postgres
An MCP server that connects to a PostgreSQL database and exposes schema inspection and safe query execution as tools and resources — ready to plug into Claude Desktop or any MCP-compatible client.
Tools
| Tool | Description |
|---|---|
list_tables |
List all tables in the public schema |
describe_table(table_name) |
Show columns, types, and nullability for a table |
run_query(query) |
Execute a SELECT query and return results (mutating statements are blocked) |
Resources
| URI | Description |
|---|---|
schema://tables |
Full schema dump — all tables with their columns |
Setup
1. Clone and install
git clone <repo-url>
cd mcp-postgres
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
2. Configure environment
cp .env.example .env
# Edit .env — set DATABASE_URL to your PostgreSQL connection string
3. Run the server
mcp-postgres
Or directly:
python -m mcp_postgres.server
Claude Desktop Integration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"postgres": {
"command": "/path/to/.venv/bin/mcp-postgres",
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mydb"
}
}
}
}
Project Structure
src/mcp_postgres/
__init__.py — package marker
db.py — psycopg2 connection context manager
server.py — FastMCP server, tools, and resources
Security
run_query rejects any statement that does not begin with SELECT. This prevents accidental or malicious data modification through the MCP interface.
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.