A modern, AI-powered natural language interface for SQL databases. This project uses the Model Context Protocol (MCP) to decouple data access from AI reasoning, enabling a secure and scalable "Chat-with-Data" experience.
The system uses a Hub-and-Spoke model where the Agent (Client) discovers database capabilities through a standardized MCP Server.
graph TD
User([User]) --> Agent[Agent Client: CLI/Web]
subgraph "MCP Ecosystem"
Agent <--> Server[MCP Server: SQLite Explorer]
Server <--> DB[(SQLite Database)]
end
Agent <--> Claude[Claude 3.5/Haiku 4.5]
- Natural Language to SQL: Ask complex questions in plain English.
- Auto-Discovery: The agent explore table schemas automatically via MCP.
- Relational Awareness: Handles complex JOINs across
users,products, andorders. - Premium Web UI: A beautiful, glassmorphic chat interface powered by FastAPI.
- CLI Mode: Interactive terminal interface for power users.
Ensure you have uv installed (recommended) and Python 3.11+.
Clone the repository and install dependencies:
uv syncCreate a .env file with your Anthropic API Key:
ANTHROPIC_API_KEY=your_key_hereRun the setup script to create data.db with sample e-commerce data:
uv run python3 setup_db.pyStart the FastAPI server:
uv run python3 app.py👉 Access the UI at http://localhost:8000
Run the interactive terminal agent:
uv run python3 agent.pyserver.py: The MCP Server usingFastMCP. Exposes tools for schema discovery and SQL execution.app.py: The FastAPI backend managing the MCP lifecycle and Web UI.agent.py: An interactive CLI implementation of the MCP client.static/: The frontend assets (HTML/CSS/JS) for the premium web UI.
- Read-Only: The MCP server is configured for
SELECTqueries only. - Safety: The
.gitignoreensures that.envanddata.dbare never committed to your remote repository. - Decoupled Logic: Your database credentials stay with the Server, and the AI only sees what the tools expose.
Powered by Claude & the Model Context Protocol.