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
| Name | Required | Description | Default |
|---|---|---|---|
| cacheKey | Yes | The cache key provided in the initial changeMode response | |
| chunkIndex | Yes | Which chunk to retrieve (1-based index) |
Implementation Reference
- lib/fixed-mcp-tool.js:353-387 (handler)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}` }] }; }
- lib/fixed-mcp-tool.js:180-198 (schema)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"] } },
- lib/fixed-mcp-tool.js:217-219 (registration)Registration via ListToolsRequestSchema handler returning the tools array which includes the fetch-chunk tool definition.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- lib/fixed-geminiExecutor.js:368-391 (helper)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; } }
- lib/fixed-geminiExecutor.js:66-68 (helper)Simple cache getter utility used by getChunkedEdits.function getChunks(key) { return chunkCache.get(key) || []; }
- lib/fixed-geminiExecutor.js:62-64 (helper)Simple cache setter utility used during changeMode chunking in executeGeminiCLI.function cacheChunks(key, chunks) { chunkCache.set(key, chunks); }