Skip to main content
Glama
cexll
by cexll

fetch-chunk

Retrieves cached data chunks from partial responses in the Codex MCP Server, enabling sequential access to large code analysis results for AI-assisted programming tasks.

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 execute function that handles the tool invocation: parses args, fetches chunks from cache using getChunks, validates chunkIndex, formats the response with formatChangeModeResponse, adds summary if first chunk, and returns formatted output or error messages.
      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. Did you run ask-codex 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 required parameters: cacheKey (string) and chunkIndex (number >=1).
    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)'),
    });
  • The fetchChunkTool is imported (line 8) and registered by pushing it to the toolRegistry array alongside other tools.
    toolRegistry.push(
      askCodexTool,
      batchCodexTool,
      // reviewCodexTool,
      pingTool,
      helpTool,
      versionTool,
      brainstormTool,
      fetchChunkTool,
      timeoutTestTool
    );
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that this is a retrieval operation for cached data, implying read-only behavior, but doesn't mention potential limitations like cache expiration, rate limits, or error conditions. The description adds some context about the tool's role in a multi-step process but lacks comprehensive behavioral details.

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?

Two sentences with zero waste - the first states the purpose, the second provides usage guidance. Every word earns its place, and the information is front-loaded with the core function stated immediately.

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

Completeness4/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 required parameters, no output schema, no annotations), the description is reasonably complete. It explains the tool's purpose, when to use it, and its relationship to changeMode responses. However, without annotations or output schema, it could benefit from more detail about what the retrieved chunks contain or potential limitations.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description adds minimal value beyond what the schema provides - it mentions 'cache key provided in the initial changeMode response' which slightly clarifies the cacheKey parameter's origin, but doesn't add significant semantic context beyond the schema's descriptions.

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

Purpose5/5

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

The description clearly states the specific action ('Retrieves cached chunks') and resource ('from a changeMode response'), distinguishing it from sibling tools like ask-codex or brainstorm. It precisely defines the tool's function as fetching subsequent data chunks after an initial partial response.

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

Usage Guidelines5/5

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

Explicitly states when to use this tool ('Use this to get subsequent chunks after receiving a partial changeMode response'), providing clear context and timing guidance. It distinguishes this from initial retrieval tools, though it doesn't name specific alternatives among siblings.

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/cexll/codex-mcp-server'

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