MCP cover image
See in Github
2025-03-26

SQLGenius是AI驱动的SQL助手,它使用Vertex AI的Gemini Pro将自然语言转换为SQL查询。它是由MCP和简化建立的,它为通过实时可视化和模式管理提供了一个直观的界面。

1

Github Watches

2

Github Forks

4

Github Stars

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.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Contraband Interactive
  • Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.

  • rustassistant.com
  • Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • modelcontextprotocol
  • 模型上下文协议服务器

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • n8n-io
  • 具有本机AI功能的公平代码工作流程自动化平台。将视觉构建与自定义代码,自宿主或云相结合,400+集成。

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • open-webui
  • 用户友好的AI接口(支持Ollama,OpenAi API,...)

    Reviews

    3 (1)
    Avatar
    user_Oer0FUDC
    2025-04-17

    SQL_MCP_Server is a fantastic tool for managing SQL databases with ease. The robust features provided by pawankumar94 make it an indispensable resource for any developer. Highly recommend for those seeking efficiency and seamless database management solutions. Check it out here: https://github.com/pawankumar94/SQL_MCP_Server