OG

ogoldberg/gemini-context-mcp-server

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

30 stars 10 forks 质量 55 趋势 0

利用 Gemini 更大的上下文窗口来增强 AI 工具的能力,为 Cursor 提供 MCP 服务器

概览

一个强大的MCP(模型上下文协议)服务器实现,利用Gemini在上下文管理和缓存方面的能力。该服务器最大化了Gemini 2M令牌上下文窗口的价值,同时提供高效缓存大型上下文的工具。 - - 利用Gemini广泛的上下文功能 - - 在多次交互中保持对话状态 - - 添加、检索和搜索元数据上下文 - - 利用语义相似性查找相关上下文 - - 会话和上下文自动过期 - - 高效重用大型系统提示和指令 - - 降低频繁使用上下文的令牌使用成本 - - 控制缓存过期时间 - - 自动移除过期缓存 - 节点。

概述(AI 翻译)

一个强大的MCP(模型上下文协议)服务器实现,利用Gemini在上下文管理和缓存方面的能力。该服务器最大化了Gemini 2M令牌上下文窗口的价值,同时提供高效缓存大型上下文的工具。

🚀 特色

情境管理

  • 支持最多200万令牌上下文窗口 - 利用Gemini丰富的上下文功能
  • 基于会话的对话 - 在多次互动中保持对话状态
  • 智能上下文追踪 - 添加、检索和搜索上下文,包含元数据
  • 语义搜索 - 利用语义相似性查找相关上下文
  • 自动上下文清理 - 会话和上下文自动过期

API 缓存

  • 大型提示缓存 - 高效重用大型系统提示和指令
  • 成本优化 - 降低频繁使用上下文的令牌使用成本
  • TTL 管理 - 控制缓存过期时间
  • 自动清理 - 过期缓存会自动移除

🏁 快速启动

先决条件

  • Node.js 18+ 安装
  • Gemini API 密钥(点击此处获取)

安装

基本用法

MCP 客户端集成

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Gemini Context MCP Server

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

Installation

# Clone the repository
git clone https://github.com/ogoldberg/gemini-context-mcp-server
cd gemini-context-mcp-server

# Install dependencies
npm install

# Copy environment variables example
cp .env.example .env

# Add your Gemini API key to .env file
# GEMINI_API_KEY=your_api_key_here

Basic Usage

# Build the server
npm run build

# Start the server
node dist/mcp-server.js

MCP Client Integration

This MCP server can be integrated with various MCP-compatible clients:

  • Claude Desktop - Add as an MCP server in Claude settings
  • Cursor - Configure in Cursor’s AI/MCP settings
  • VS Code - Use with MCP-compatible extensions

For detailed integration instructions with each client, see the MCP Client Configuration Guide in the MCP documentation.

Quick Client Setup

Use our simplified client installation commands:

# Install and configure for Claude Desktop
npm run install:claude

# Install and configure for Cursor
npm run install:cursor

# Install and configure for VS Code
npm run install:vscode

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

💻 Usage Examples

For Beginners

Directly using the server:

  1. Start the server:

    node dist/mcp-server.js
    
  2. Interact using the provided test scripts:

    # Test basic context management
    node test-gemini-context.js
    
    # Test caching features
    node test-gemini-api-cache.js
    

Using in your Node.js application:

import { GeminiContextServer } from './src/gemini-context-server.js';

async function main() {
  // Create server instance
  const server = new GeminiContextServer();
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →