MCP Chatbot

v1.0.0Databasesstable

A serverless backend that enables natural language querying of a Postgres database, converting user questions into SQL and returning structured, UI-friendly responses.

chatbotmcpmcp-hostmcp-serverpython
Share:
250
Stars
0
Downloads
0
Weekly
0/5

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

Query Postgres databases in natural language.
Convert user questions into SQL automatically.
Return structured, UI-friendly responses to queries.
rick-noya

Maintainer

LicenseMIT
Languagepython
Versionv1.0.0
UpdatedMay 11, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-chatbot

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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.txt
2

Configure 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=5432
3

Run 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 8080
4

Test 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?"}'
5

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-backend
6

Deploy 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 --guided

MCP 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.

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.

Quick Config Preview

{ "mcpServers": { "mcp-chatbot": { "command": "npx", "args": ["-y", "mcp-chatbot"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides