Skip to content
Back to search

mcp-gemini-assistant

MCP Gemini - Coding Assistant for Claude Code

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/peterkrueck--mcp-gemini-assistant/badge.svg)](/listings/peterkrueck--mcp-gemini-assistant)

HTML

<a href="/listings/peterkrueck--mcp-gemini-assistant"><img src="/api/listings/peterkrueck--mcp-gemini-assistant/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. Clone this repository 2. Create a Python virtual environment:

   python3 -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install dependencies:

   pip install -r requirements.txt

4. Copy `.env.example` to `.env` and add your Gemini API key:

   cp .env.example .env
   # Edit .env file and set your GEMINI_API_KEY

5. Add to Claude Code:

   claude mcp add gemini-coding -s user -- /path/to/gemini-mcp/start_server.sh

Replace `/path/to/gemini-mcp/` with the actual path to this directory.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 214 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Gemini Coding Assistant MCP Server
  2. A powerful MCP server that allows Claude Code to consult Gemini for complex coding problems with full code context and conversation persistence.
  3. > **Note**: This server works standalone but is highly recommended to use with the [Claude Code Development Kit](https://github.com/peterkrueck/Claude-Code-Development-Kit) for enhanced automation and context management.
  4. ## Key Features
  5. - **Session Management**: Maintain conversation context across multiple queries
  6. - **File Attachments**: Read and include actual code files in conversations
  7. - **Hybrid Context**: Combine text-based `code_context` with file attachments
  8. - **Follow-up Questions**: Ask follow-up questions without resending code context
  9. - **Context Caching**: Code context and file content are cached per session
  10. - **Automatic Processing**: Files are processed and formatted automatically
  11. - **Multiple Sessions**: Run multiple parallel conversations for different problems
  12. - **Session Expiry**: Automatic cleanup of inactive sessions after 1 hour
  13. - **Latest Model**: Uses Gemini 2.5 Pro (stable) by default
  14. ## Integration with Claude Code Development Kit
  15. While this MCP server works standalone, it is **highly recommended and optimized** to use with the [Claude Code Development Kit](https://github.com/peterkrueck/Claude-Code-Development-Kit).
  16. ### Enhanced Features with Development Kit
  17. The Development Kit transforms Claude Code into an orchestrated development environment that seamlessly integrates with this Gemini MCP server:
  18. 1. **Automated Context Injection**: The `gemini-context-injector.sh` hook automatically attaches project-specific context files (MCP-ASSISTANT-RULES.md, project-structure.md) to new Gemini sessions
  19. 2. **Multi-Agent Orchestration**: Complex commands spawn specialized agents that can consult Gemini for architectural decisions and design patterns
  20. 3. **Enhanced System Prompt**: The MCP server's system prompt is designed to work with the Development Kit's context injection system
  21. 4. **Security Scanning**: The `mcp-security-scan.sh` hook prevents sensitive data from being sent to external AI services
  22. 5. **Seamless Integration**: Commands like `/full-context` automatically leverage Gemini for complex problems
  23. ### Quick Setup with Development Kit
  24. 1. Install the [Claude Code Development Kit](https://github.com/peterkrueck/Claude-Code-Development-Kit)
  25. 2. Configure this MCP server as described in the installation section below
  26. 3. The Development Kit's hooks will automatically enhance your Gemini interactions
  27. ## Purpose
  28. When Claude Code encounters difficult problems or needs a second opinion, it can:
  29. - Send complete code files by reading them from the local filesystem
  30. - Include text-based code context alongside file attachments
  31. - Have multi-turn conversations about the same problem
  32. - Get different perspectives without repeating context
  33. - Work on multiple problems in parallel sessions
  34. - Process files locally and include content in conversations
  35. ## Installation
  36. 1. Clone this repository
  37. 2. Create a Python virtual environment:
  38. ```bash
  39. python3 -m venv venv
  40. source venv/bin/activate # On Windows: venv\Scripts\activate
  41. ```
  42. 3. Install dependencies:
  43. ```bash
  44. pip install -r requirements.txt
  45. ```
  46. 4. Copy `.env.example` to `.env` and add your Gemini API key:
  47. ```bash
  48. cp .env.example .env
  49. # Edit .env file and set your GEMINI_API_KEY
  50. ```
  51. 5. Add to Claude Code:
  52. ```bash
  53. claude mcp add gemini-coding -s user -- /path/to/gemini-mcp/start_server.sh
  54. ```
  55. Replace `/path/to/gemini-mcp/` with the actual path to this directory.
  56. ## Tools Available
  57. ### 1. `consult_gemini`
  58. Start or continue a conversation with Gemini about complex coding problems.
  59. **Parameters:**
  60. - `session_id` (optional): Continue a previous conversation
  61. - `problem_description`: Description of the problem (required for new sessions)
  62. - `code_context`: All relevant code (required for new sessions, cached afterward)
  63. - `attached_files` (optional): Array of file paths to read and include in the conversation
  64. - `file_descriptions` (optional): Object mapping file paths to descriptions
  65. - `specific_question`: The question you want answered
  66. - `additional_context` (optional): Updates or changes since last question
  67. - `preferred_approach`: Type of help needed (solution/review/debug/optimize/explain/follow-up)
  68. ### 2. `list_sessions`
  69. List all active Gemini consultation sessions.
  70. ### 3. `end_session`
  71. End a specific session to free up memory.
  72. ## Usage Examples
  73. ### Starting a New Conversation (with text code)
  74. ```
  75. /consult_gemini
  76. problem_description: "I need to implement efficient caching for a React application"
  77. code_context: "[paste entire relevant codebase]"
  78. specific_question: "What's the best approach for implementing LRU cache with React Query?"
  79. preferred_approach: "solution"
  80. ```
  81. ### Starting a New Conversation (with file attachments)
  82. ```
  83. /consult_gemini
  84. problem_description: "I need to optimize this React component for performance"
  85. attached_files: ["/absolute/path/to/src/components/Dashboard.jsx", "/absolute/path/to/src/hooks/useData.js", "/absolute/path/to/package.json"]
  86. file_descriptions: {
  87. "/absolute/path/to/src/components/Dashboard.jsx": "Main dashboard component with performance issues",
  88. "/absolute/path/to/src/hooks/useData.js": "Custom hook for data fetching",
  89. "/absolute/path/to/package.json": "Project dependencies"
  90. }
  91. specific_question: "How can I improve the rendering performance of this dashboard?"
  92. preferred_approach: "optimize"
  93. ```
  94. ### Combining Both Approaches
  95. ```
  96. /consult_gemini
  97. problem_description: "Complex authentication flow needs debugging"
  98. code_context: "// Additional context or pseudocode here"
  99. attached_files: ["/absolute/path/to/auth/login.js", "/absolute/path/to/middleware/auth.js"]
  100. specific_question: "Why is the token refresh failing?"
  101. preferred_approach: "debug"
  102. ```
  103. Response includes a session ID for follow-ups.
  104. ### Follow-up Question
  105. ```
  106. /consult_gemini
  107. session_id: "abc123..."
  108. specific_question: "I implemented your suggestion but getting stale data issues. How do I handle cache invalidation?"
  109. additional_context: "Added the LRU cache as suggested, but users see old data after updates"
  110. preferred_approach: "follow-up"
  111. ```
  112. ### Managing Sessions
  113. ```
  114. /list_sessions
  115. # Shows all active sessions with IDs and summaries
  116. /end_session
  117. session_id: "abc123..."
  118. # Frees up memory for completed conversations
  119. ```
  120. ## Best Practices
  121. 1. **Initial Context**: Include ALL relevant code via `code_context` or `attached_files`
  122. 2. **File Organization**: Use `attached_files` for multiple files, `code_context` for snippets
  123. 3. **File Descriptions**: Provide clear descriptions for each attached file
  124. 4. **Follow-ups**: Use the session ID to continue conversations
  125. 5. **Additional Context**: When asking follow-ups, explain what changed
  126. 6. **Session Management**: End sessions when done to free memory and clean up files
  127. 7. **Multiple Problems**: Use different sessions for unrelated problems
  128. 8. **File Types**: Supports JavaScript, Python, TypeScript, JSON, and other text-based files
  129. ## Testing the Server
  130. You can test the server directly before adding it to Claude Code:
  131. ```bash
  132. # Make sure your .env file has a valid GEMINI_API_KEY
  133. ./start_server.sh
  134. ```
  135. The server will start and display:
  136. ```
  137. Gemini Coding Assistant MCP Server v3.0 running (Python)
  138. Features: Session management, file attachments, context persistence, follow-up questions
  139. Ready to help with complex coding problems!
  140. ```
  141. ## Context Limits
  142. - Maximum combined input: ~50,000 characters per message
  143. - Maximum response: 8,192 tokens (~16,000 characters)
  144. - Session timeout: 1 hour of inactivity
  145. - Rate limiting: 1 second between requests
  146. ## How It Works
  147. 1. **First Message**: Creates a new session, caches code context
  148. 2. **Follow-ups**: Reuses cached context, maintains conversation history
  149. 3. **Session Storage**: In-memory storage (use Redis for production)
  150. 4. **Cleanup**: Automatic expiry after 1 hour of inactivity
  151. ## Advantages Over Stateless Design
  152. - **Efficiency**: Code context sent only once per session
  153. - **Context**: Gemini remembers previous questions and answers
  154. - **Natural Flow**: Have real conversations about complex problems
  155. - **Cost Savings**: Reduced token usage for follow-up questions
  156. ## Security
  157. - API key is never exposed
  158. - Rate limiting prevents abuse
  159. - Sessions expire automatically
  160. - No persistent storage of code
  161. - When used with Claude Code Development Kit, additional security scanning prevents sensitive data leakage
  162. ## Version History
  163. - v3.0.0: Enhanced system prompt for Claude Code Development Kit integration
  164. - v2.1.0: Added file attachment system with automatic cleanup
  165. - v2.0.0: Added session management and follow-up support
  166. - v1.0.0: Initial stateless implementation
  167. ## Connect
  168. Feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/peterkrueck/) if you have questions, need clarification, or wish to provide feedback.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.