MCP Chatbot
A serverless backend that enables natural language querying of a Postgres database, converting user questions into SQL and returning structured, UI-friendly responses.
What is MCP Chatbot?
MCP Chatbot is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to serverless backend that enables natural language querying of a postgres database, converting user questions into sql and returning structured, ui-friendly responses.
A serverless backend that enables natural language querying of a Postgres database, converting user questions into SQL and returning structured, UI-friendly responses.
This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- A serverless backend that enables natural language querying
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx mcp-chatbotConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use MCP Chatbot
MCP Chatbot is a serverless backend application that connects a natural language interface to a PostgreSQL database (hosted on Supabase), converting plain English questions into SQL queries via OpenAI's GPT models and returning structured, UI-friendly JSON responses. Built with FastAPI and deployable to AWS Lambda via SAM or as a Docker container, it exposes a single /ask POST endpoint that handles the full NL-to-SQL pipeline including query generation, execution, and response summarization. Developers use it as a foundation for building conversational data exploration tools or internal analytics chatbots over existing Postgres schemas.
Prerequisites
- Python 3.8 or higher with pip or venv
- An OpenAI API key (OPENAI_API_KEY) for GPT-based SQL generation
- A PostgreSQL database on Supabase with connection credentials (host, port, name, user, password)
- Docker installed for containerized deployment, or AWS SAM CLI for Lambda deployment
- An MCP client or HTTP client (curl, Postman) to send requests to the /ask endpoint
Clone the repository and set up a Python environment
Clone the mcp-chatbot repository and create an isolated Python virtual environment to avoid dependency conflicts.
git clone https://github.com/rick-noya/mcp-chatbot.git
cd mcp-chatbot
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtConfigure environment variables
Create a .env file at the project root with your OpenAI API key and Supabase PostgreSQL connection details.
# .env
OPENAI_API_KEY=sk-...
SUPABASE_DB_NAME=postgres
SUPABASE_DB_USER=postgres
SUPABASE_DB_PASSWORD=your-password
SUPABASE_DB_HOST=db.your-project.supabase.co
SUPABASE_DB_PORT=5432Run locally with Uvicorn
Start the FastAPI development server locally on port 8080 to test the NL-to-SQL pipeline before deploying.
uvicorn main:app --reload --port 8080Test the /ask endpoint
Send a POST request to the /ask endpoint with a natural language question to verify the pipeline is working end to end.
curl -X POST http://localhost:8080/ask \
-H "Content-Type: application/json" \
-d '{"question": "How many users signed up last month?"}'Deploy with Docker
Build a Docker image and run the container in production mode, passing the .env file for credentials.
docker build -t mcp-chat-backend .
docker run -p 8080:8080 --env-file .env mcp-chat-backendDeploy to AWS Lambda (optional)
Use AWS SAM to package and deploy the application as a serverless Lambda function for scalable production hosting.
sam build
sam deploy --guidedMCP Chatbot Examples
Client configuration
MCP server configuration for Claude Desktop to communicate with the mcp-chatbot backend via a local HTTP wrapper. The backend must be running separately.
{
"mcpServers": {
"mcp-chatbot": {
"command": "python",
"args": ["-m", "uvicorn", "main:app", "--port", "8080"],
"env": {
"OPENAI_API_KEY": "sk-YOUR_KEY_HERE",
"SUPABASE_DB_NAME": "postgres",
"SUPABASE_DB_USER": "postgres",
"SUPABASE_DB_PASSWORD": "your-password",
"SUPABASE_DB_HOST": "db.your-project.supabase.co",
"SUPABASE_DB_PORT": "5432"
}
}
}
}Prompts to try
Example natural language questions to send to the /ask endpoint
- "How many users signed up in the last 30 days?"
- "What are the top 5 products by revenue this quarter?"
- "Show me all orders with status 'pending' from last week"
- "What is the average session duration by country?"
- "How many active subscriptions do we have by plan type?"Troubleshooting MCP Chatbot
Database connection refused or timeout
Verify SUPABASE_DB_HOST and SUPABASE_DB_PORT are correct. On Supabase, check the connection pooler settings and ensure your IP is not blocked by the Supabase project's network restrictions. For local testing, use the direct connection string rather than the pooler URL.
OpenAI API returns incorrect or invalid SQL
The SQL generation quality depends on the schema context provided to the model. Add database schema descriptions or table comments in your Postgres instance so the model has richer context. Consider switching to gpt-4o for more accurate SQL on complex schemas.
CORS errors when connecting from a frontend application
The application includes CORS support. Check main.py for the CORSMiddleware configuration and add your frontend's origin to the allowed origins list. Restart the server after making changes.
Frequently Asked Questions about MCP Chatbot
What is MCP Chatbot?
MCP Chatbot is a Model Context Protocol (MCP) server that serverless backend that enables natural language querying of a postgres database, converting user questions into sql and returning structured, ui-friendly responses. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install MCP Chatbot?
Follow the installation instructions on the MCP Chatbot GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with MCP Chatbot?
MCP Chatbot works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is MCP Chatbot free to use?
Yes, MCP Chatbot is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
MCP Chatbot Alternatives — Similar Databases Servers
Looking for alternatives to MCP Chatbot? Here are other popular databases servers you can use with Claude, Cursor, and VS Code.
Excelize
★ 20.6kGo language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
MCP Toolbox for Databases
★ 15.3kOpen source MCP server specializing in easy, fast, and secure tools for Databases.
DBHub
★ 2.8kA universal database gateway MCP server that enables AI assistants to connect to and query multiple databases (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite) with support for schema exploration, SQL execution, and secure connections via SSH tunnels.
Tabularis
★ 2.1kA lightweight, cross-platform database client for developers. Supports MySQL, PostgreSQL and SQLite. Hackable with plugins. Built for speed, security, and aesthetics.
Postgres AI Guide
★ 1.7kMCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
Anyquery
★ 1.7k🏎️ 🏠 ☁️ - Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by design.
Browse More Databases MCP Servers
Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up MCP Chatbot in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use MCP Chatbot?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.