Skip to main content
Glama
omd0
by omd0

get_next_chunk

Retrieves the next subtitle chunk for sequential translation processing after conversation detection, enabling chunk-by-chunk handling of large SRT files.

Instructions

📦 CHUNK RETRIEVAL FOR TRANSLATION WORKFLOW 📦

🎯 PURPOSE: Retrieves the next chunk from memory for sequential processing. Use this after detect_conversations with storeInMemory=true.

🔄 HOW IT WORKS:

  • Automatically tracks which chunk to return next

  • Returns actual chunk data with subtitle text content

  • Advances to next chunk automatically

  • Returns null when all chunks processed

📥 PARAMETERS:

  • sessionId: Session ID from detect_conversations response

📤 RETURNS:

  • chunk: Complete chunk data with subtitle text (or null if done)

  • chunkIndex: Current chunk number (0-based)

  • totalChunks: Total chunks available

  • hasMore: Boolean indicating if more chunks exist

  • message: Status message

💡 USAGE PATTERN:

  1. Call detect_conversations with storeInMemory=true

  2. Get sessionId from response

  3. Call get_next_chunk repeatedly until hasMore=false

  4. Process each chunk for translation

  5. Use translate_srt() on individual chunks

📋 EXAMPLE: {"sessionId": "srt-session-123456789"}

⚠️ NOTE:

  • Each call advances to the next chunk automatically

  • Store sessionId from detect_conversations response

  • Use this for chunk-by-chunk processing of large files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID from detect_conversations with storeInMemory=true

Implementation Reference

  • The core handler function that implements the get_next_chunk MCP tool. It retrieves the next SRT chunk from session-specific memory, returns chunk data or null if done, updates the current index, and provides status information.
    private async handleGetNextChunk(args: any) {
      const { sessionId } = args;
      
      if (!this.chunkMemory.has(sessionId)) {
        throw new Error(`Session ${sessionId} not found in memory`);
      }
    
      const chunks = this.chunkMemory.get(sessionId);
      const currentIndex = this.chunkIndex.get(sessionId) || 0;
      
      if (currentIndex >= chunks.length) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: true,
                chunk: null,
                chunkIndex: currentIndex,
                totalChunks: chunks.length,
                hasMore: false,
                message: 'All chunks have been processed'
              }, null, 2),
            },
          ],
        };
      }
    
      const currentChunk = chunks[currentIndex];
      this.chunkIndex.set(sessionId, currentIndex + 1);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              chunk: currentChunk,
              chunkIndex: currentIndex,
              totalChunks: chunks.length,
              hasMore: currentIndex + 1 < chunks.length,
              message: `Retrieved chunk ${currentIndex + 1} of ${chunks.length}`,
              nextInstruction: currentIndex + 1 < chunks.length 
                ? `Call get_next_chunk again to get chunk ${currentIndex + 2}`
                : 'All chunks have been retrieved'
            }, null, 2),
          },
        ],
      };
    }
  • Registration of the get_next_chunk tool in the MCP server's tool list, including name, detailed description, and input schema definition.
              {
                name: 'get_next_chunk',
                description: `📦 CHUNK RETRIEVAL FOR TRANSLATION WORKFLOW 📦
    
    🎯 PURPOSE:
    Retrieves the next chunk from memory for sequential processing.
    Use this after detect_conversations with storeInMemory=true.
    
    🔄 HOW IT WORKS:
    - Automatically tracks which chunk to return next
    - Returns actual chunk data with subtitle text content
    - Advances to next chunk automatically
    - Returns null when all chunks processed
    
    📥 PARAMETERS:
    - sessionId: Session ID from detect_conversations response
    
    📤 RETURNS:
    - chunk: Complete chunk data with subtitle text (or null if done)
    - chunkIndex: Current chunk number (0-based)
    - totalChunks: Total chunks available
    - hasMore: Boolean indicating if more chunks exist
    - message: Status message
    
    💡 USAGE PATTERN:
    1. Call detect_conversations with storeInMemory=true
    2. Get sessionId from response
    3. Call get_next_chunk repeatedly until hasMore=false
    4. Process each chunk for translation
    5. Use translate_srt() on individual chunks
    
    📋 EXAMPLE:
    {"sessionId": "srt-session-123456789"}
    
    ⚠️ NOTE:
    - Each call advances to the next chunk automatically
    - Store sessionId from detect_conversations response
    - Use this for chunk-by-chunk processing of large files`,
                inputSchema: {
                  type: 'object',
                  properties: {
                    sessionId: {
                      type: 'string',
                      description: 'Session ID from detect_conversations with storeInMemory=true',
                    },
                  },
                  required: ['sessionId'],
                },
              },
  • Dispatch routing in the CallToolRequestSchema handler that maps the 'get_next_chunk' tool call to the handleGetNextChunk method.
    case 'get_next_chunk':
      return await this.handleGetNextChunk(args);
  • Class properties used by the handler to store chunks per session and track the current chunk index.
    private chunkMemory = new Map<string, any>(); // Store chunks by session ID
    private chunkIndex = new Map<string, number>(); // Track current chunk index per session
Behavior4/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 effectively describes key behaviors: automatic tracking of chunk sequence, advancement to the next chunk on each call, and returning null when processing is complete. It also notes prerequisites like storing the sessionId. However, it lacks details on error handling or performance aspects like rate limits.

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

Conciseness4/5

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

The description is well-structured with clear sections (PURPOSE, HOW IT WORKS, etc.) and uses emojis for visual organization, making it easy to scan. However, it includes some redundant information, such as repeating the sessionId parameter details that are already in the schema, slightly reducing efficiency. Overall, it is appropriately sized and front-loaded with key information.

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

Completeness5/5

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

Given the tool's complexity (sequential retrieval with state tracking), no annotations, and no output schema, the description provides comprehensive context. It explains the workflow, return values (chunk, chunkIndex, etc.), usage patterns, and notes on behavior like automatic advancement. This compensates well for the lack of structured data, making it complete for agent understanding.

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%, with the schema fully documenting the single parameter sessionId. The description adds minimal value beyond the schema by repeating the parameter name and its source, but does not provide additional semantic context or usage nuances. This meets the baseline of 3 when schema coverage is high.

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 explicitly states the tool's purpose as 'Retrieves the next chunk from memory for sequential processing,' specifying both the verb (retrieves) and resource (chunk from memory). It clearly distinguishes from sibling tools like detect_conversations, parse_srt, and translate_srt by focusing on sequential retrieval rather than detection, parsing, or translation.

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?

The description provides explicit guidance on when to use this tool: 'Use this after detect_conversations with storeInMemory=true' and includes a detailed usage pattern with numbered steps. It also specifies alternatives indirectly by naming other tools in the workflow, such as using translate_srt() on individual chunks after retrieval.

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/omd0/srt-mcp'

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