npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

delegate-to-gemini

v1.1.0

Published

An MCP server that delegates large conversation contexts from Claude to Gemini

Readme

DelegateToGemini MCP Server

An MCP (Model Context Protocol) server that delegates large conversation contexts from Claude to Gemini when approaching token limits.

Overview

This project provides a solution for managing context windows in AI conversations by:

  1. Detecting when Claude's context window is nearly full
  2. Sending the large context to Gemini (which has 1-2M token capacity)
  3. Having Gemini process and summarize the context
  4. Returning the condensed information to Claude
  5. Continuing the conversation without the "context too long" error

Features

  • Context Size Checking: Detects when the context is approaching Claude's token limit
  • Context Delegation: Sends large contexts to Gemini for processing
  • Customizable Summarization: Supports parameters for controlling how Gemini summarizes the context
  • JSON Response Format: Returns structured data for easy integration
  • Clipboard Helper: Automatically detects large contexts on your clipboard

Installation

# Clone the repository
git clone https://github.com/yourusername/delegate-to-gemini.git
cd delegate-to-gemini

# Install dependencies
pnpm install

# Build the project
pnpm build

# Set up the clipboard helper
pnpm run setup-helper

Configuration

Set your Gemini API key as an environment variable:

export GEMINI_API_KEY="your-api-key-here"

Usage

Running the Server

pnpm start

The server runs as an MCP server that communicates via stdin/stdout.

Using the Clipboard Helper for Cursor

The clipboard helper makes delegation more automatic by proactively monitoring for context issues:

  1. Start the clipboard helper:

    pnpm run helper
  2. The helper will automatically detect:

    • "Your conversation is too long" error messages
    • Warning phrases about context limits
    • Conversations exceeding token thresholds
    • Long Claude conversations
  3. When detected, it will:

    • Automatically process the content on your clipboard
    • Summarize it with Gemini
    • Put the summarized context back on your clipboard
    • Display a desktop notification when ready
  4. Just paste the summarized context into a new conversation and continue

Pro tip: Copy your conversation (Ctrl+A, Ctrl+C) whenever you feel it's getting long, even before hitting the limit. The helper will proactively summarize it if needed.

Note: The helper temporarily modifies the source code to include your context, rebuilds the project, and then runs the MCP server. This approach was chosen due to limitations in parameter passing with the MCP SDK.

Available Tools

The MCP server provides the following tools:

1. check_context_size

Checks if the conversation context is approaching Claude's token limit.

Response Example:

{
  "isApproachingLimit": true,
  "estimatedTokens": 95000,
  "maxTokens": 100000,
  "percentUsed": 95
}

2. delegate_to_gemini

Delegates the conversation context to Gemini for processing and summarization.

Response Example:

{
  "summarizedContent": "This is the summarized content...",
  "topicsCovered": ["Topic 1", "Topic 2"],
  "keyPoints": ["Key point 1", "Key point 2"],
  "tokensReduced": "Original: ~95,000 tokens → Summarized: ~10,000 tokens",
  "originalTokens": 95000,
  "summarizedTokens": 10000
}

3. delegate_context

Delegates a specific context to Gemini with parameters (sample implementation).

Integration

To integrate with Claude or other AI systems, you'll need to:

  1. Set up an MCP client to communicate with this server
  2. Monitor the context size using check_context_size
  3. When approaching the limit, call delegate_to_gemini to get a summarized context
  4. Use the summarized context to continue the conversation

Development

# Run in development mode with auto-reload
pnpm dev

License

MIT

Using DelegateToGemini in Cursor

When you see the "Your conversation is too long" warning in Cursor, follow these steps:

  1. Copy your conversation:

    • Press Ctrl+A (or Cmd+A on Mac) to select all text
    • Press Ctrl+C (or Cmd+C on Mac) to copy it to clipboard
  2. Tell Claude to use the tool (choose one method):

    • Type in the chat input: <ctrl+/> delegate-to-gemini
    • Ask naturally: "Please use the delegate-to-gemini tool to summarize this conversation"
    • Use the quick invoke shortcut: Run pnpm invoke in your terminal, then paste in Cursor
  3. Review the summarized result:

    • Claude will invoke the MCP tool
    • The tool reads your clipboard content
    • Gemini summarizes it
    • Claude shows you the result

Quick Invoke Helper

To make invocation even easier, use the included quick invoke script:

# Run the invoke helper
pnpm invoke

This script:

  1. Copies the exact invocation syntax to your clipboard
  2. Preserves your previous clipboard content (restores after 10 seconds)
  3. Just paste in Cursor to invoke the tool

Troubleshooting

If the tool isn't working:

  1. Check MCP server configuration in Cursor:

    • Go to Settings > Features > MCP Servers
    • Add or edit the server with:
      • Name: DelegateToGemini
      • Command: node /path/to/DelegateToGemini/dist/main.js
    • Make sure the server is enabled
  2. Restart Cursor if you've just added the server

Project Structure

// ... existing content ...