Skip to main content
Glama

fetch-chunk

Retrieves cached data chunks from Google Gemini CLI responses to access complete analysis results when initial responses are partial.

Instructions

Retrieves cached chunks from a changeMode response. Use this to get subsequent chunks after receiving a partial changeMode response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cacheKeyYesThe cache key provided in the initial changeMode response
chunkIndexYesWhich chunk to retrieve (1-based index)

Implementation Reference

  • The main handler function for the 'fetch-chunk' tool. It retrieves cached code edit chunks using the provided cacheKey and chunkIndex, validates inputs, formats the response, and handles errors like cache misses or invalid indices.
      execute: async (args: any, onProgress?: (newOutput: string) => void): Promise<string> => {
        const { cacheKey, chunkIndex } = args;
        
        Logger.toolInvocation('fetch-chunk', args);
        Logger.debug(`Fetching chunk ${chunkIndex} with cache key: ${cacheKey}`);
        
        // Retrieve cached chunks
        const chunks = getChunks(cacheKey);
        
        if (!chunks) {
          return `❌ Cache miss: No chunks found for cache key "${cacheKey}". 
    
      Possible reasons:
      1. The cache key is incorrect, Have you ran ask-gemini with changeMode enabled?
      2. The cache has expired (10 minute TTL)
      3. The MCP server was restarted and the file-based cache was cleared
    
    Please re-run the original changeMode request to regenerate the chunks.`;
        }
        
        // Validate chunk index
        if (chunkIndex < 1 || chunkIndex > chunks.length) {
          return `❌ Invalid chunk index: ${chunkIndex}
    
    Available chunks: 1 to ${chunks.length}
    You requested: ${chunkIndex}
    
    Please use a valid chunk index.`;
        }
        
        // Get the requested chunk
        const chunk = chunks[chunkIndex - 1];
        
        // Format the response
        let result = formatChangeModeResponse(
          chunk.edits,
          { current: chunkIndex, total: chunks.length, cacheKey }
        );
        
        // Add summary for first chunk
        if (chunkIndex === 1 && chunks.length > 1) {
          const allEdits = chunks.flatMap(c => c.edits);
          result = summarizeChangeModeEdits(allEdits, true) + '\n\n' + result;
        }
        
        Logger.debug(`Returning chunk ${chunkIndex} of ${chunks.length} with ${chunk.edits.length} edits`);
        
        return result;
      }
  • Zod input schema defining the parameters for the fetch-chunk tool: cacheKey (string) and chunkIndex (number >=1). This schema is used for input validation in the tool definition.
    const inputSchema = z.object({
      cacheKey: z.string().describe("The cache key provided in the initial changeMode response"),
      chunkIndex: z.number().min(1).describe("Which chunk to retrieve (1-based index)")
    });
  • Registration of the fetchChunkTool into the central toolRegistry array, making it available for use in the MCP server.
    toolRegistry.push(
      askGeminiTool,
      pingTool,
      helpTool,
      brainstormTool,
      fetchChunkTool,
      timeoutTestTool
    );
  • src/tools/index.ts:6-6 (registration)
    Import statement that brings the fetchChunkTool definition into the index file for registration.
    import { fetchChunkTool } from './fetch-chunk.tool.js';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool retrieves cached chunks and is used after a partial response, but it doesn't disclose critical behavioral traits such as whether this is a read-only operation, potential rate limits, error conditions, or what happens if the cache expires. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences that are front-loaded and efficient. The first sentence states the core purpose, and the second provides usage context. There is no wasted language, and every sentence earns its place by adding necessary information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (2 required parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It explains the purpose and usage context adequately, but without annotations or an output schema, it fails to cover behavioral aspects like safety, performance, or return values. This makes it minimally viable but not fully comprehensive for an agent to use confidently.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, meaning the input schema fully documents both parameters ('cacheKey' and 'chunkIndex') with descriptions. The description adds minimal value beyond the schema by implying the parameters are used for retrieving subsequent chunks, but it doesn't provide additional syntax, format details, or examples. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Retrieves') and resource ('cached chunks from a changeMode response'), making the purpose understandable. It specifies that these are cached chunks from a particular source, which distinguishes it from generic retrieval tools. However, it doesn't explicitly differentiate from sibling tools like 'ask-gemini' or 'brainstorm' since they serve different functions, so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: 'after receiving a partial changeMode response' and 'to get subsequent chunks.' This gives explicit guidance on the prerequisite condition. However, it doesn't mention when NOT to use it or name specific alternatives among the sibling tools, which prevents a score of 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jamubc/gemini-mcp-tool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server