MCP PostgreSQL Demo
@Tibiritabara
About MCP PostgreSQL Demo
Postgres MCP server
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"postgres-mcp-tibiritabara": {
"command": "python",
"args": [
"-m",
"venv",
".venv"
]
}
}
}Tools
1Execute SQL queries against the database (SELECT queries only)
Overview
What is MCP PostgreSQL Demo?
A FastMCP server that enables LLMs to connect and interact with PostgreSQL databases. It demonstrates how to use the Model Context Protocol (MCP) to allow Language Models to query and explore database schemas and tables.
How to use MCP PostgreSQL Demo?
Install Python 3.12+, PostgreSQL, and UV. Clone the repository, create a virtual environment, install dependencies with uv sync, and configure environment variables. Uncomment the run function in src/main.py and start the server with python -m src.main. Alternatively, use Docker with the provided Dockerfile. For client applications, add the MCP configuration to the client’s MCP config file (e.g., .cursor/mcp.json).
Key features of MCP PostgreSQL Demo
- Schema Exploration: Retrieve metadata about database schemas
- Table Inspection: Get detailed information about table structures
- Database Querying: Execute SQL SELECT queries against the database
- YAML Formatting: Results returned in YAML format for LLM consumption
- Predefined prompts for schema, table descriptions, and data queries
Use cases of MCP PostgreSQL Demo
- Allow LLMs to explore database schemas without direct SQL access
- Enable LLMs to query table data using natural language via prompts
- Provide structured metadata to LLMs for context-aware responses
- Demonstrate MCP integration with PostgreSQL for AI assistants
FAQ from MCP PostgreSQL Demo
What are the prerequisites for running the server?
Python 3.12 or higher, a PostgreSQL database, and UV package manager (recommended).
How do I configure the database connection?
Set environment variables: DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, and DB_NAME. Default values are provided in .env.example.
Can I execute any SQL query?
Only SELECT queries are allowed via the query_database tool; no modifications are supported.
How are query results formatted?
Results are returned in YAML format for easy parsing by LLMs.
Can I run this server in Docker?
Yes, build the image with docker build -t mcp-demo . and run with docker run --env-file .env.docker -p 8000:8000 mcp-demo.
Frequently asked questions
What are the prerequisites for running the server?
Python 3.12 or higher, a PostgreSQL database, and UV package manager (recommended).
How do I configure the database connection?
Set environment variables: `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`, and `DB_NAME`. Default values are provided in `.env.example`.
Can I execute any SQL query?
Only SELECT queries are allowed via the `query_database` tool; no modifications are supported.
How are query results formatted?
Results are returned in YAML format for easy parsing by LLMs.
Can I run this server in Docker?
Yes, build the image with `docker build -t mcp-demo .` and run with `docker run --env-file .env.docker -p 8000:8000 mcp-demo`.
Basic information
More Databases MCP servers

Sqlite
modelcontextprotocolModel Context Protocol Servers

nuzur
nuzur is a model-first database platform for MySQL and PostgreSQL. The MCP server lets any AI assistant or agent (Claude, Cursor, Gemini, or anything else that speaks MCP) design your schema, query your data, generate mi
MongoDB Lens
furey🍃🔎 MongoDB Lens: Full Featured MCP Server for MongoDB Databases
mcp-server-qdrant: A Qdrant MCP server
qdrantAn official Qdrant Model Context Protocol (MCP) server implementation
Multi Database MCP Server
FreePeakA powerful multi-database server implementing the Model Context Protocol (MCP) to provide AI assistants with structured access to databases.
Comments