Gemini Context MCP Server

by MCP-Mirror

322 downloads Not rated yet
GitHub

About

An MCP server that leverages Gemini’s capabilities for context management and caching. It maximizes Gemini’s 2M token context window while providing tools for efficient reuse of large prompts and session-based conversation state.

Explore

- Up to 2M token context window support
- Session-based conversations with automatic context cleanup
- Semantic search for finding relevant context
- Large prompt caching with TTL management
- Cost optimization for frequently used contexts
- Easy integration with Claude Desktop, Cursor, and VS Code

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Gemini Context MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Node.js 18+ installed
- Gemini API key (Get one here)

npm install

cp .env.example .env


Use our simplified client installation commands:

bash

npm run install:claude

npm run install:cursor

npm run install:vscode


Each command sets up the appropriate configuration files and provides instructions for completing the integration.

javascript
// Custom configuration
const config = {
gemini: {
apiKey: process.env.GEMINI_API_KEY,
model: 'gemini-2.0-pro',
temperature: 0.2,
maxOutputTokens: 1024,
},
server: {
sessionTimeoutMinutes: 30,
maxTokensPerSession: 1000000
}
};

const server = new GeminiContextServer(config);


Create a .env file with these options:

bash

generate_text

Generate text with context

get_context

Get current context for a session

clear_context

Clear session context

add_context

Add specific context entries

search_context

Find relevant context semantically

mcp_gemini_context_create_cache

Create a cache for large contexts

mcp_gemini_context_generate_with_cache

Generate with cached context

mcp_gemini_context_list_caches

List all available caches

mcp_gemini_context_update_cache_ttl

Update cache TTL

mcp_gemini_context_delete_cache

Delete a cache

This server implements the Model Context Protocol (MCP), making it compatible with tools like Cursor or other AI-enhanced development environments.

1. Context Management Tools:
- generate_text - Generate text with context
- get_context - Get current context for a session
- clear_context - Clear session context
- add_context - Add specific context entries
- search_context - Find relevant context semantically

2. Caching Tools:
- mcp_gemini_context_create_cache - Create a cache for large contexts
- mcp_gemini_context_generate_with_cache - Generate with cached context
- mcp_gemini_context_list_caches - List all available caches
- mcp_gemini_context_update_cache_ttl - Update cache TTL
- mcp_gemini_context_delete_cache - Delete a cache

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "gemini context mcp server": {
            "ogoldberg_gemini-context-mcp-server": {
                "command": "node",
                "args": [
                    "dist/mcp-server.js"
                ]
            }
        }
    }
}

McpServers

{
    "ogoldberg_gemini-context-mcp-server": {
        "command": "node",
        "args": [
            "dist/mcp-server.js"
        ]
    }
}

A powerful MCP (Model Context Protocol) server implementation that leverages Gemini's capabilities for context management and caching. This server maximizes the value of Gemini's 2M token context window while providing tools for efficient caching of large contexts.

🚀 Features

Context Management

- Up to 2M token context window support - Leverage Gemini's extensive context capabilities - Session-based conversations - Maintain conversational state across multiple interactions - Smart context tracking - Add, retrieve, and search context with metadata - Semantic search - Find relevant context using semantic similarity - Automatic context cleanup - Sessions and context expire automatically

API Caching

- Large prompt caching - Efficiently reuse large system prompts and instructions - Cost optimization - Reduce token usage costs for frequently used contexts - TTL management - Control cache expiration times - Automatic cleanup - Expired caches are removed automatically

🏁 Quick Start

Prerequisites

- Node.js 18+ installed - Gemini API key (Get one here)

Installation

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.