A chat-based interface for querying your database using natural language. Built with MCP (Model Context Protocol).
Read the full article on Medium here: https://medium.com/@jonortega20/building-a-database-querier-with-mcp-17df0f49a2de
- Clean, modern UI with responsive design
- Chat-style interface for natural language database queries
- Real-time interaction with your PostgreSQL database
- Supports code block formatting in responses
- Status indicators and loading animations
- Python 3.11+
- Flask
- LangChain OpenAI
- Postgre MCP
-
Clone this repository
-
Install the required Python packages:
pip install flask flask-cors langchain_openai python-dotenv- Make sure you have MCP installed:
pip install mcp_use- Make sure you have an OpenAI API key and your database connection string in your .env file:
OPENAI_API_KEY=your_api_key_here
DB_LINK=your_database_connection_string_here
- Start the Flask server:
python app.py- Open your browser and navigate to:
http://localhost:5000
- Start asking questions about your database!
- "How many users are in the database?"
- "Show me a random user's information"
- "What is the average age of the users?"
- "What is the percentage of active users?"
- "How many users are there per country?"
Jon Ortega
