Skip to main content
Glama
orzcls

Gemini CLI MCP Server

by orzcls

fetch-chunk

Retrieves cached chunks from a changeMode response to access subsequent data after receiving partial responses.

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

  • MCP CallTool handler for 'fetch-chunk': destructures args, calls getChunkedEdits helper, formats chunk response with progress info and instructions for fetching more chunks if available.
    case "fetch-chunk":
        const { cacheKey, chunkIndex: fetchChunkIndex } = args;
        console.error('[GMCPT] fetch-chunk tool called with cacheKey: ' + cacheKey + ', chunkIndex: ' + fetchChunkIndex);
        
        try {
            const chunkResult = getChunkedEdits(cacheKey, parseInt(fetchChunkIndex));
            
            // Format the chunk information
            const chunkInfo = `CHUNK ${chunkResult.chunk}/${chunkResult.totalChunks} (Cache Key: ${chunkResult.cacheKey})\n\n${chunkResult.content}`;
            
            if (chunkResult.hasMore) {
                const nextChunk = chunkResult.chunk + 1;
                const remainingChunks = chunkResult.totalChunks - chunkResult.chunk;
                return {
                    content: [{
                        type: "text",
                        text: chunkInfo + `\n\n[Use fetch-chunk tool with cacheKey "${chunkResult.cacheKey}" and chunkIndex ${nextChunk}-${chunkResult.totalChunks} to get remaining ${remainingChunks} chunks]`
                    }]
                };
            } else {
                return {
                    content: [{
                        type: "text",
                        text: chunkInfo + "\n\n[This is the final chunk]" 
                    }]
                };
            }
        } catch (error) {
            return {
                content: [{
                    type: "text",
                    text: `Error retrieving chunk: ${error.message}`
                }]
            };
        }
  • Input schema definition for the fetch-chunk tool, specifying required cacheKey (string) and chunkIndex (number >=1).
    {
        name: "fetch-chunk",
        description: "Retrieves cached chunks from a changeMode response. Use this to get subsequent chunks after receiving a partial changeMode response.",
        inputSchema: {
            type: "object",
            properties: {
                cacheKey: {
                    type: "string",
                    description: "The cache key provided in the initial changeMode response"
                },
                chunkIndex: {
                    type: "number",
                    minimum: 1,
                    description: "Which chunk to retrieve (1-based index)"
                }
            },
            required: ["cacheKey", "chunkIndex"]
        }
    },
  • Registration via ListToolsRequestSchema handler returning the tools array which includes the fetch-chunk tool definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
        return { tools };
    });
  • Core helper function implementing chunk retrieval logic from in-memory Map cache, validates existence and index, returns chunk metadata including hasMore flag.
    export function getChunkedEdits(cacheKey, chunkIndex) {
        try {
            const chunks = getChunks(cacheKey);
            if (!chunks || chunks.length === 0) {
                throw new Error('No cached chunks found for the provided cache key');
            }
            
            const chunk = chunks[chunkIndex - 1]; // Convert to 0-based index
            if (!chunk) {
                throw new Error(`Chunk ${chunkIndex} not found. Available chunks: 1-${chunks.length}`);
            }
            
            return {
                content: chunk,
                chunk: chunkIndex,
                totalChunks: chunks.length,
                cacheKey: cacheKey,
                hasMore: chunkIndex < chunks.length
            };
        } catch (error) {
            console.error(`Failed to retrieve chunk: ${error.message}`);
            throw error;
        }
    }
  • Simple cache getter utility used by getChunkedEdits.
    function getChunks(key) {
        return chunkCache.get(key) || [];
    }
  • Simple cache setter utility used during changeMode chunking in executeGeminiCLI.
    function cacheChunks(key, chunks) {
        chunkCache.set(key, chunks);
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that this retrieves 'cached chunks' and is for 'subsequent chunks,' implying it's a read operation without side effects, but lacks details on error handling, caching behavior, or response format. This is adequate but has gaps.

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 with zero waste, front-loading the purpose and following with usage guidance. Every word earns its place, making it highly efficient and well-structured.

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 moderate complexity (2 parameters, no output schema, no annotations), the description is complete enough for basic understanding but lacks details on output (e.g., what the chunks contain) and error cases. It's minimally viable but could be more comprehensive.

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%, so the schema already documents both parameters ('cacheKey' and 'chunkIndex') fully. The description adds minimal value by referencing 'cache key provided in the initial changeMode response' and 'which chunk to retrieve,' but doesn't provide additional syntax or format details beyond the schema.

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 action ('Retrieves cached chunks') and resource ('from a changeMode response'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from its siblings (like 'ask-gemini' or 'brainstorm'), which would require a 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'), which helps guide usage. It doesn't specify when not to use it or name explicit alternatives among siblings, preventing 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/orzcls/gemini-mcp-tool-windows-fixed'

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