PostgreSQL MCP Server
Connects Claude Desktop to a local PostgreSQL database running in Docker, enabling read-only querying of products via natural language.
README
š PostgreSQL MCP Server (Python & Docker)
A clean, fully executable implementation of a custom Model Context Protocol (MCP) server built in Python using Anthropic's FastMCP framework. This project connects Claude Desktop directly to a local PostgreSQL database running securely in Docker.
This repository contains all the code and configuration files showcased in the step-by-step YouTube tutorial.
šļø Architecture Overview
The connection is established using a simple client-server model defined by the Model Context Protocol: āāāāāāāāāāāāāāāāāāā JSON-RPC (stdio) āāāāāāāāāāāāāāāāāāāāā ā Claude Desktop ā <āāāāāāāāāāāāāāāāāāāāāāāāāā> ā Python MCP Server ā ā (MCP Client) ā ā (FastMCP) ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāā¬āāāāāāāāāā ā SQL ā (Authentication) ā¼ āāāāāāāāāāāāāāāāāāāāā ā PostgreSQL ā ā (Docker Container)ā āāāāāāāāāāāāāāāāāāāāā
- Authentication: The Python script uses a secure username/password credential set to authenticate with the Postgres database.
- Authorization: Claude is authorized strictly to fetch and view products via the
@mcp.tool()wrapper. It does not have access or permissions to perform destructive database modifications.
š Project Structure
mcp-postgres-demo/
āāā db/
ā āāā init.sql # Seed data & table schema definitions
āāā docker-compose.yml # Multi-container local database orchestrator
āāā server.py # FastMCP Server with stdio & SSE transport modes
āāā requirements.txt # Locked project dependencies
āāā .gitignore # Keeps local environments and OS junk out of Git
š Quick Start Guide
1. Clone & Set Up a Virtual Environment
Isolate your Python workspace to avoid dependency version conflicts:
# Clone this repository
git clone [https://github.com/](https://github.com/)<your-username>/claude-postgres-mcp-connector.git
cd claude-postgres-mcp-connector
# Create the virtual environment
python -m venv venv
# Activate it (macOS/Linux)
source venv/bin/activate
# Activate it (Windows PowerShell)
.\venv\Scripts\Activate.ps1
2. Install Project Dependencies
Install the locked dependencies defined in our requirement manifests:
pip install -r requirements.txt
3. Launch the Database (Docker)
We use Docker Compose to spin up a pre-configured Postgres database.
docker-compose up -d
Note: The docker-compose.yml mounts our SQL script using the :ro (Read-Only) volume flag. This is a secure best-practice protecting our local init.sql initialization script from being corrupted or altered by runtime database mutations.
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.