Sage (Gemini 2.5 Pro) MCP server

Provides tools for sending prompts to Gemini 2.5 Pro with full file context, enabling second opinions and expert code reviews with gitignore-aware directory traversal.
Back to servers
Setup instructions
Provider
Joshua Lehman
Release date
Apr 19, 2025
Language
TypeScript
Stats
6 stars

An MCP (Model Context Protocol) server that enables sending prompts to Gemini 2.5 Pro with embedded file contents. This tool helps get second opinions or detailed code reviews by leveraging Gemini's large context window, allowing you to include entire folders of code for analysis while continuing to use other LLMs as your primary development tools.

Installation and Setup

Prerequisites

  • Node.js (v18 or later)
  • A Google Gemini API key

Installation Steps

# Clone the repository
git clone https://github.com/your-username/mcp-sage.git
cd mcp-sage

# Install dependencies
npm install

# Build the project
npm run build

Environment Configuration

Set the following environment variable:

GEMINI_API_KEY=your_api_key_here

Usage

Starting the Server

After building the project, start the MCP server:

GEMINI_API_KEY=XXX node /path/to/this/repo/dist/index.js

Available Tools

The server provides two main tools:

Second Opinion Tool

This tool helps you get a second opinion from Gemini on your code or other content.

Parameters:

  • prompt (string, required): The prompt to send to Gemini
  • paths (array of strings, required): List of file paths to include as context

Example JSON-RPC call:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "second-opinion",
    "arguments": {
      "prompt": "Explain how this code works",
      "paths": ["path/to/file1.js", "path/to/file2.js"]
    }
  }
}

Expert Review Tool

This tool provides detailed code review with specific change suggestions formatted as SEARCH/REPLACE blocks.

Parameters:

  • instruction (string, required): The specific changes or improvements needed
  • paths (array of strings, required): List of file paths to include as context

Example JSON-RPC call:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "expert-review",
    "arguments": {
      "instruction": "Add error handling to the function",
      "paths": ["path/to/file1.js", "path/to/file2.js"]
    }
  }
}

Example response format:

<<<<<<< SEARCH
function getData() {
  return fetch('/api/data')
    .then(res => res.json());
}
=======
function getData() {
  return fetch('/api/data')
    .then(res => {
      if (!res.ok) {
        throw new Error(`HTTP error! Status: ${res.status}`);
      }
      return res.json();
    })
    .catch(error => {
      console.error('Error fetching data:', error);
      throw error;
    });
}
>>>>>>> REPLACE

Testing

Test the functionality with the provided test scripts:

# Test the second-opinion tool
GEMINI_API_KEY=your_api_key_here node test/run-test.js

# Test the expert-review tool
GEMINI_API_KEY=your_api_key_here node test/test-expert.js

Monitoring and Debugging

The server provides detailed monitoring information via MCP logging, including:

  • Token usage statistics (tokens used vs. token limit)
  • Number of files and documents included in the request
  • Request processing time metrics
  • Error information when token limits are exceeded

Example log entries:

  • Token usage: 1,234 / 1,000,000 tokens (0.12%)
  • Files included: 3, Document count: 3
  • Sending request to Gemini with 1,234 tokens...
  • Received response from Gemini in 982ms

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-sage" '{"command":"node","args":["/path/to/this/repo/dist/index.js"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp-sage": {
            "command": "node",
            "args": [
                "/path/to/this/repo/dist/index.js"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-sage": {
            "command": "node",
            "args": [
                "/path/to/this/repo/dist/index.js"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later