Gemini模型连接服务

Gemini-MCP Bridge是一个高级模型上下文协议(MCP)服务器,用于将Google的Gemini模型连接到开发环境,为GitHub Copilot及其他MCP兼容工具提供强大的代码库探索和AI驱动的架构能力。

  • by HazemHassine
  • Python
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 HazemHassine/Gemini-Mcp

使用说明

Gemini-MCP Bridge

An advanced Model Context Protocol (MCP) server that connects Google's Gemini models to your development environment, providing GitHub Copilot (and other MCP-compatible tools) with powerful repository exploration and AI-driven architectural capabilities.

🚀 Key Capabilities

This MCP server exposes several high-signal tools to your AI agent:

🧠 Gemini Intelligence

  • plan_task: Generates a detailed, step-by-step implementation plan for complex coding tasks.
  • review_patch: Performs a deep review of code diffs, identifying logic bugs, security risks, and maintainability issues.
  • ask_gemini: A general-purpose technical assistant for any coding or architectural questions.

🔍 Repository Exploration & Semantic Search

  • list_repo_files / read_repo_file: Safely explore the project structure and content with smart safeguards.
  • search_repo_code: Fast, recursive grep-style search across your codebase.
  • index_repository: Indexes your files using Gemini embeddings to enable semantic search.
  • semantic_search_code: Uses a vector database (LanceDB) to find code conceptually related to your query.

📐 Architectural Mapping

  • map_architecture: Builds a high-level graph of your project. It uses AI to generate "Functional Signatures" for each file and maps their structural dependencies (imports).
  • get_graph_data: Exports the architectural graph as JSON for visualization in the built-in UI.

📊 Graph Visualization UI

The project includes a built-in web application to visualize your code's architecture.

  1. Launch the UI:
    cd ui
    python main.py
    
  2. Access the Dashboard: Open http://localhost:8000 in your browser.
  3. Dynamic Loading: Use the path input to load the .mcp_data from any project on your system.

🛡️ Security & Observability

  • Persistent Memory: A local SQLite database (.mcp_data/history.db) stores a detailed history of every tool call, request, and response for task continuity.
  • Vector Store: Uses LanceDB for high-performance, local vector storage of your repository's code.
  • Path Validation: Strict safeguards prevent path traversal attacks and access to sensitive system files.
  • Structured Logging: All activities are logged to stderr, mcp_server.log, and the SQLite database.

⚙️ Setup

  1. Install Dependencies:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    pip install -r requirements.txt
    
  2. Configure Environment: Create a .env file in the root directory:

    GEMINI_API_KEY=your_api_key_here
    

🛠️ VS Code & GitHub Copilot Integration

To use this bridge with GitHub Copilot, you must configure it via an mcp.json file.

  1. Open MCP Configuration:

    • Open the Command Palette (Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows/Linux).
    • Type "MCP: Open User Configuration" and press Enter.
  2. Add the Gemini Bridge: Add the following configuration (adjust the paths to match your local setup):

    {
      "servers": {
        "gemini-bridge": {
          "type": "stdio",
          "command": "/home/hazem/personal_dev/mcp-gemini-bridge/venv/bin/python",
          "args": ["/home/hazem/personal_dev/mcp-gemini-bridge/server.py"],
          "env": {
            "PYTHONPATH": "/home/hazem/personal_dev/mcp-gemini-bridge",
            "GEMINI_API_KEY": "your_api_key_here"
          }
        }
      }
    }
    
  3. Use in Copilot:

    • Open GitHub Copilot Chat.
    • Switch to Agent Mode.
    • Click the Tools (wrench icon) to verify "Gemini Bridge" is connected and active.

🧪 Development & Testing

Run the server locally to verify the protocol:

PYTHONPATH=. ./venv/bin/python server.py

Logs will appear in stderr and mcp_server.log.