使用说明
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.
- Launch the UI:
cd ui python main.py - Access the Dashboard: Open http://localhost:8000 in your browser.
- Dynamic Loading: Use the path input to load the
.mcp_datafrom 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
-
Install Dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt -
Configure Environment: Create a
.envfile 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.
-
Open MCP Configuration:
- Open the Command Palette (
Cmd+Shift+Pon macOS orCtrl+Shift+Pon Windows/Linux). - Type "MCP: Open User Configuration" and press Enter.
- Open the Command Palette (
-
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" } } } } -
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.
