Sponsored by Deepsite.site

SQLGenius - AI-Powered SQL Assistant

Created By
pawankumar94a year ago
SQLGenius is an AI-powered SQL assistant that converts natural language to SQL queries using Vertex AI's Gemini Pro. Built with MCP and Streamlit, it provides an intuitive interface for BigQuery data exploration with real-time visualization and schema management.
Content

SQLGenius - AI-Powered SQL Assistant

SQLGenius is an intelligent SQL assistant that helps you query your BigQuery database using natural language. Built with MCP (Model Context Protocol), Vertex AI's Gemini Pro, and Streamlit.

🌟 Features

  • Natural language to SQL conversion using Gemini Pro
  • Interactive Streamlit UI with multiple tabs
  • Real-time query execution and visualization
  • Database schema explorer
  • Query history tracking
  • Safe query validation
  • BigQuery integration
  • MCP-based architecture

🎥 Demo

Watch SQLGenius in action! Here's a quick demo of how to use the application:

SQLGenius Demo

In this demo, you can see:

  1. Natural language query conversion to SQL
  2. Interactive data visualization
  3. Schema exploration
  4. Query history tracking

🚀 Installation

  1. Clone the repository and navigate to the project directory:
cd sql_mcp_server
  1. Install dependencies:
pip install -r requirements.txt
  1. Copy the .env.example file to .env and fill in your configuration:
cp .env.example .env
  1. Set up your environment variables in .env:
PROJECT_ID=your-project-id
DATASET_ID=your-dataset-id
GOOGLE_APPLICATION_CREDENTIALS=path/to/your/service-account.json
VERTEX_AI_LOCATION=us-central1

🎮 Usage

  1. Start the application:
streamlit run streamlit_app.py
  1. The MCP server will start automatically when the Streamlit app launches

  2. Use the tabs to:

    • Ask natural language questions about your data
    • Write SQL queries directly
    • Explore your database schema

📊 Interface Tabs

💬 Natural Language Query

Ask questions in plain English and get SQL results:

  • "Show me the top 5 customers by revenue"
  • "What products have the highest sales in January?"
  • "How many orders were placed last month?"

📊 SQL Query

Write and execute SQL queries directly:

SELECT * FROM orders 
WHERE order_date > '2023-01-01' 
ORDER BY total_amount DESC
LIMIT 10

📋 Database Explorer

  • Browse available tables
  • View table schemas
  • See sample data from any table

🔒 Security Features

  • Only SELECT queries are permitted
  • Query validation to prevent dangerous operations
  • Secure credential management
  • Error handling and input validation

🛠️ Architecture

SQLGenius uses the Model Context Protocol (MCP) to expose tools that enable:

  1. Natural Language Processing: Convert English questions to SQL
  2. Data Exploration: Fetch schema information and sample data
  3. SQL Execution: Run validated queries against your database

The architecture consists of:

  • MCP Server: Handles DB connection and provides tools
  • Streamlit Frontend: User interface for interacting with the system
  • Vertex AI (Gemini Pro): Powers natural language understanding
  • BigQuery: Executes SQL queries on your data

📝 MCP Tools

The following MCP tools are available:

  1. execute_nl_query: Execute a natural language query
  2. execute_sql_query: Execute a raw SQL query
  3. list_tables: List all available tables
  4. get_table_schema: Get schema for a specific table

📚 Advanced Usage

To add custom tools to the MCP server:

  1. Edit the register_tools() method in sql_mcp_server.py
  2. Add your custom tool using the @self.tool() decorator
  3. Restart the server

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
WindsurfThe new purpose-built IDE to harness magic
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Tavily Mcp
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Amap Maps高德地图官方 MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Serper MCP ServerA Serper MCP Server
CursorThe AI Code Editor