Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Claude-Gemini Collaborative IntegrationAsk Gemini to brainstorm some edge cases for this auth logic"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Claude-Gemini Collaborative Integration
This project enables seamless collaboration between Claude Code and Gemini CLI, allowing them to work together on tasks, discuss ideas, and refine solutions in real-time. This integration leverages the Model Context Protocol (MCP) to facilitate communication and tool usage between the two AI agents.
Features
Start Collaborative Sessions: Initiate a new discussion with Gemini on a specific topic.
Consult Gemini: Ask questions or provide context to Gemini within an ongoing collaboration.
Retrieve Conversation History: Access the full transcript of a collaborative session.
Context Preservation: Gemini remembers previous interactions within a session, allowing for iterative discussions.
Rate Limiting Handling: The collaborative server automatically manages rate limits for Gemini API calls.
Prerequisites
Before you begin, ensure you have the following installed:
Python 3.8+: The project is built with Python.
pip: Python package installer.Claude Desktop: The application that hosts Claude Code.
Gemini CLI: Ensure the Gemini CLI is installed and configured with your API key. You can verify its installation by running
gemini --versionin your terminal.
Setup Guide
Follow these steps to set up the Claude-Gemini collaborative integration:
1. Clone the Repository
First, clone this repository to your local machine:
(Replace
2. Create and Activate a Python Virtual Environment
It's recommended to use a virtual environment to manage dependencies:
3. Install Dependencies
Install the required Python packages using pip:
4. Start the Collaborative Server
The collaborative server acts as an intermediary between Claude Code and Gemini. It needs to be running in the background.
You can verify the server is running by checking its health endpoint:
You should see a response like {"status": "ok"}.
5. Configure Claude Desktop for MCP
You need to tell Claude Desktop about the new MCP server. This involves adding a configuration snippet to your claude_desktop_config.json file.
Locate your
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add the following JSON snippet to the mcpServers section of your claude_desktop_config.json file. If the mcpServers section doesn't exist, you can create it.
Important: Ensure the args path points to the absolute path of mcp_server.py on your system.
6. Restart Claude Desktop
For the configuration changes to take effect, you must close and reopen the Claude Desktop application.
7. Verify MCP Tools are Available
After restarting Claude Desktop, in a new Claude Code session, you should see these tools available:
start_gemini_collaboration: Start a new collaborative conversation with Gemini.consult_gemini: Ask Gemini a question in the current collaboration context.get_collaboration_history: Get the full conversation history with Gemini.
Usage
Once set up, you can interact with Gemini directly through Claude Code using natural language.
Starting a Collaboration
To begin a new collaborative session with Gemini, simply tell Claude Code:
Claude Code will automatically use the start_gemini_collaboration tool.
Having a Discussion
Once a collaboration is active, you can ask Gemini questions or provide further context:
Claude Code will use the consult_gemini tool to get Gemini's input, maintaining the conversation context.
Getting History
To review the entire conversation history of the current collaboration:
This will use the get_collaboration_history tool.
Example Workflow
Here's a typical interaction flow:
You: "I need to design a database schema for an e-commerce site. Start a collaboration with Gemini."
Claude: (Uses
start_gemini_collaborationtool, confirms collaboration started)You: "Ask Gemini about the best approach for handling product variants (e.g., size, color)."
Claude: (Uses
consult_geminitool, displays Gemini's response)You: "What does Gemini think about our payment table design, specifically regarding PCI compliance?"
Claude: (Continues the collaboration, building on previous context, and provides Gemini's insights)
You: "Show me the full collaboration history."
Claude: (Displays the entire conversation transcript)
Troubleshooting
Tools Not Available in Claude Code
Ensure Claude Desktop was fully restarted after modifying
claude_desktop_config.json.Verify that the
claude_desktop_config.jsonfile exists at the correct path for your operating system and that the JSON is valid.Double-check that the
commandandargspaths inclaude_desktop_config.jsonare absolute and correct.
Collaborative Server Connection Issues
Check if the server is running:
curl http://localhost:8080/healthIf it's not running, restart it as described in Step 4.
Check for port conflicts: Ensure no other application is using port
8080.
Gemini CLI Issues
Verify Gemini CLI installation: Run
gemini --versionin your terminal.Check API key configuration: Ensure your Gemini API key is correctly set up and accessible by the Gemini CLI.
Testing
You can run the provided test script to verify the MCP client and server functionality:
Benefits of Collaboration
This integration provides significant benefits for complex software engineering tasks:
Real-time Discussion: Engage in actual back-and-forth conversations with Gemini, not just one-off queries.
Contextual Understanding: Gemini maintains context throughout the conversation, leading to more relevant and insightful responses.
Iterative Problem Solving: Work through problems step-by-step, refining ideas and solutions collaboratively.
Enhanced Problem Solving: Leverage the strengths of both Claude and Gemini to tackle challenging problems more effectively.
Seamless Workflow: Integrate collaborative AI assistance directly into your Claude Code environment.