npm package: @hvantoan/gemini-mcp-assistant
Description: MCP Server for Gemini file attachment functionality
Latest version: 1.0.0

# Gemini Coding Assistant MCP Server (TypeScript Version)

This is a reference version rewritten in **TypeScript** based on the original [mcp-gemini-assistant](https://github.com/peterkrueck/mcp-gemini-assistant.git) project (Python).

The original project was developed by **Peter Krueck**. You can connect with the author on [LinkedIn](https://www.linkedin.com/in/peterkrueck/).

## Introduction

This MCP Server allows Claude Code (and other MCP Clients) to consult Gemini for complex coding problems with full code context and conversation persistence.

## Key Features

- **Session Management**: Maintain conversation context across multiple queries.
- **File Attachments**: Read and include actual code files in conversations.
- **Hybrid Context**: Combine text-based `code_context` with file attachments.
- **Follow-up Questions**: Ask follow-up questions without resending code context.
- **Automatic Processing**: Files are processed and formatted automatically.
- **Session Expiry**: Automatic cleanup of inactive sessions after 1 hour.
- **Latest Model**: Uses Gemini 2.5 Pro (or the latest configured version).

## Requirements

- Node.js (v18 or higher)
- pnpm or npm
- Gemini API Key (get it at [Google AI Studio](https://aistudio.google.com/))

## Installation

### Option 1: Install via npm (Recommended)

You can use the package directly via `npx` or install it globally.

```bash
npm install -g @hvantoan/gemini-mcp-assistant
```

### Option 2: Install from Source

1.  Clone the repository:
    ```bash
    git clone <your-repo-url>
    cd mcp-gemini-assistant
    ```

2.  Install dependencies:
    ```bash
    npm install
    # or
    pnpm install
    ```

3.  Build the project:
    ```bash
    npm run build
    # or
    pnpm build
    ```

4.  Configure environment variables:
    Create a `.env` file in the root directory and add your API Key:
    ```env
    GEMINI_API_KEY=your_api_key_here
    ```

## Configuration Guide

### 1. Configuration for Claude Desktop / Claude Code

To use with Claude Desktop or Claude Code, add the configuration to your `claude_desktop_config.json` file.
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

#### If using npx (Recommended):

```json
{
  "mcpServers": {
    "gemini-assistant": {
      "command": "npx",
      "args": [
        "-y",
        "@hvantoan/gemini-mcp-assistant"
      ],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here",
        "GEMINI_MODEL": "gemini-2.5-pro"
      }
    }
  }
}
```

#### If installed from source:

```json
{
  "mcpServers": {
    "gemini-assistant": {
      "command": "node",
      "args": [
        "C:/path/to/mcp-gemini-assistant/build/index.js"
      ],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here",
        "GEMINI_MODEL": "gemini-2.5-pro"
      }
    }
  }
}
```
*Note: Replace `C:/path/to/mcp-gemini-assistant/` with the absolute path to your project directory.*

### 2. Configuration for GitHub Copilot

If you are using GitHub Copilot in an environment that supports MCP (e.g., via extension or experimental features), provide the server information as follows:

**Using npx:**
- **Command**: `npx`
- **Arguments**: `-y @hvantoan/gemini-mcp-assistant`
- **Environment Variables**: `GEMINI_API_KEY=[Your API Key]`

**Using Source:**
- **Command**: `node`
- **Arguments**: `[Absolute path to build/index.js]`
- **Environment Variables**: `GEMINI_API_KEY=[Your API Key]`

## Usage

Once configured, you can use the following tools in the Claude or Copilot chat window:

### `consult_gemini`
Start a new consultation session or continue an existing one.
- `problem_description`: Description of the problem (required for new sessions).
- `code_context`: Relevant code (text format).
- `attached_files`: List of file paths to read.
- `specific_question`: Your specific question.
- `session_id`: Session ID to continue the conversation.

### `list_sessions`
List active conversation sessions.

### `end_session`
End a session to free up memory.

## Publishing to npm

To publish this package to npm (as a scoped package):

1.  Login to npm:
    ```bash
    npm login
    ```
2.  Publish the package (use `--access public` for the first publish if using a free account):
    ```bash
    npm publish --access public
    ```

---
*This project is a TypeScript reference version, rewritten based on the structure and concepts of [mcp-gemini-assistant](https://github.com/peterkrueck/mcp-gemini-assistant.git).*