Gemini Context MCP Server

Integrations

  • Provides a Node.js application interface for integrating the MCP server into custom applications, with support for context management and caching features

Gemini Context MCP 서버

Gemini의 컨텍스트 관리 및 캐싱 기능을 활용하는 강력한 MCP(Model Context Protocol) 서버 구현입니다. 이 서버는 Gemini의 2M 토큰 컨텍스트 윈도우의 가치를 극대화하는 동시에 대규모 컨텍스트의 효율적인 캐싱을 위한 도구를 제공합니다.

🚀 특징

컨텍스트 관리

  • 최대 2M 토큰 컨텍스트 창 지원 - Gemini의 광범위한 컨텍스트 기능 활용
  • 세션 기반 대화 - 여러 상호 작용에서 대화 상태 유지
  • 스마트 컨텍스트 추적 - 메타데이터를 사용하여 컨텍스트 추가, 검색 및 검색
  • 의미 검색 - 의미 유사성을 사용하여 관련 컨텍스트 찾기
  • 자동 컨텍스트 정리 - 세션 및 컨텍스트가 자동으로 만료됩니다.

API 캐싱

  • 대용량 프롬프트 캐싱 - 대용량 시스템 프롬프트 및 지침을 효율적으로 재사용
  • 비용 최적화 - 자주 사용되는 컨텍스트에 대한 토큰 사용 비용 절감
  • TTL 관리 - 캐시 만료 시간 제어
  • 자동 정리 - 만료된 캐시는 자동으로 제거됩니다.

🏁 빠른 시작

필수 조건

설치

지엑스피1

기본 사용법

# Build the server npm run build # Start the server node dist/mcp-server.js

MCP 클라이언트 통합

이 MCP 서버는 다양한 MCP 호환 클라이언트와 통합될 수 있습니다.

  • Claude Desktop - Claude 설정에서 MCP 서버로 추가
  • 커서 - 커서의 AI/MCP 설정에서 구성
  • VS Code - MCP 호환 확장 프로그램과 함께 사용

각 클라이언트와의 자세한 통합 지침은 MCP 설명서의 MCP 클라이언트 구성 가이드를 참조하세요.

빠른 클라이언트 설정

간소화된 클라이언트 설치 명령을 사용하세요.

# 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

각 명령은 적절한 구성 파일을 설정하고 통합을 완료하기 위한 지침을 제공합니다.

💻 사용 예시

초보자를 위한

서버를 직접 사용하는 경우:
  1. 서버를 시작합니다:
    node dist/mcp-server.js
  2. 제공된 테스트 스크립트를 사용하여 상호 작용하세요.
    # Test basic context management node test-gemini-context.js # Test caching features node test-gemini-api-cache.js
Node.js 애플리케이션에서 사용:
import { GeminiContextServer } from './src/gemini-context-server.js'; async function main() { // Create server instance const server = new GeminiContextServer(); // Generate a response in a session const sessionId = "user-123"; const response = await server.processMessage(sessionId, "What is machine learning?"); console.log("Response:", response); // Ask a follow-up in the same session (maintains context) const followUp = await server.processMessage(sessionId, "What are popular algorithms?"); console.log("Follow-up:", followUp); } main();

전문 사용자를 위한

사용자 정의 구성 사용:
// 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 cache for large system instructions const cacheName = await server.createCache( 'Technical Support System', 'You are a technical support assistant for a software company...', 7200 // 2 hour TTL ); // Generate content using the cache const response = await server.generateWithCache( cacheName, 'How do I reset my password?' ); // Clean up when done await server.deleteCache(cacheName);

🔌 MCP 도구(커서 등)와 함께 사용

이 서버는 MCP(모델 컨텍스트 프로토콜)를 구현하여 커서나 기타 AI 기반 개발 환경과 같은 도구와 호환됩니다.

사용 가능한 MCP 도구

  1. 컨텍스트 관리 도구:
    • generate_text - 컨텍스트를 포함한 텍스트 생성
    • get_context - 세션의 현재 컨텍스트를 가져옵니다.
    • clear_context - 세션 컨텍스트 지우기
    • add_context - 특정 컨텍스트 항목 추가
    • search_context - 의미적으로 관련 컨텍스트 찾기
  2. 캐싱 도구:
    • mcp_gemini_context_create_cache - 대규모 컨텍스트에 대한 캐시 생성
    • mcp_gemini_context_generate_with_cache - 캐시된 컨텍스트로 생성
    • mcp_gemini_context_list_caches - 사용 가능한 모든 캐시 나열
    • mcp_gemini_context_update_cache_ttl - 캐시 TTL 업데이트
    • mcp_gemini_context_delete_cache - 캐시 삭제

커서로 연결하기

Cursor 와 함께 사용하면 MCP 구성을 통해 연결할 수 있습니다.

{ "name": "gemini-context", "version": "1.0.0", "description": "Gemini context management and caching MCP server", "entrypoint": "dist/mcp-server.js", "capabilities": { "tools": true }, "manifestPath": "mcp-manifest.json", "documentation": "README-MCP.md" }

MCP 도구에 대한 자세한 사용 지침은 README-MCP.md를 참조하세요.

⚙️ 구성 옵션

환경 변수

다음 옵션을 사용하여 .env 파일을 만듭니다.

# Required GEMINI_API_KEY=your_api_key_here GEMINI_MODEL=gemini-2.0-flash # Optional - Model Settings GEMINI_TEMPERATURE=0.7 GEMINI_TOP_K=40 GEMINI_TOP_P=0.9 GEMINI_MAX_OUTPUT_TOKENS=2097152 # Optional - Server Settings MAX_SESSIONS=50 SESSION_TIMEOUT_MINUTES=120 MAX_MESSAGE_LENGTH=1000000 MAX_TOKENS_PER_SESSION=2097152 DEBUG=false

🧪 개발

# Build TypeScript files npm run build # Run in development mode with auto-reload npm run dev # Run tests npm test

📚 추가 자료

  • MCP 관련 사용법은 README-MCP.md를 참조하세요.
  • 사용 가능한 도구를 이해하려면 mcp-manifest.json 의 매니페스트를 탐색하세요.
  • 사용 패턴을 알아보려면 저장소의 예제 스크립트를 확인하세요.

📋 향후 개선 사항

  • 컨텍스트 및 캐시에 대한 데이터베이스 지속성
  • 캐시 크기 관리 및 제거 정책
  • 벡터 기반 의미 검색
  • 분석 및 메트릭 추적
  • 벡터 저장소와의 통합
  • 컨텍스트 관리를 위한 일괄 작업
  • 하이브리드 캐싱 전략
  • 자동 프롬프트 최적화

📄 라이센스

MIT

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

여러 AI 클라이언트 애플리케이션에서 효율적인 컨텍스트 관리와 캐싱을 위한 도구를 사용하여 Gemini의 2M 토큰 컨텍스트 창을 극대화하는 MCP 서버 구현입니다.

  1. 🚀 Features
    1. Context Management
    2. API Caching
  2. 🏁 Quick Start
    1. Prerequisites
    2. Installation
    3. Basic Usage
    4. MCP Client Integration
  3. 💻 Usage Examples
    1. For Beginners
    2. For Power Users
  4. 🔌 Using with MCP Tools (like Cursor)
    1. Available MCP Tools
    2. Connecting with Cursor
  5. ⚙️ Configuration Options
    1. Environment Variables
  6. 🧪 Development
    1. 📚 Further Reading
      1. 📋 Future Improvements
        1. 📄 License

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            Model Context Protocol (MCP) server implementation that enables Claude Desktop to interact with Google's Gemini AI models.
            Last updated -
            53
            TypeScript
            MIT License
            • Apple
            • Linux
          • A
            security
            F
            license
            A
            quality
            A Model Context Protocol (MCP) server that optimizes token usage by caching data during language model interactions, compatible with any language model and MCP client.
            Last updated -
            4
            JavaScript
          • -
            security
            A
            license
            -
            quality
            An MCP server implementation that standardizes how AI applications access tools and context, providing a central hub that manages tool discovery, execution, and context management with a simplified configuration system.
            Last updated -
            9
            Python
            MIT License
          • -
            security
            -
            license
            -
            quality
            An MCP server implementation that allows using Google's Gemini AI models (specifically Gemini 1.5 Pro) through Claude or other MCP clients via the Model Context Protocol.
            Last updated -
            1
            JavaScript

          View all related MCP servers

          ID: 0pj55vyt1r