Skip to main content
Glama
omd0
by omd0

parse_srt

Extract structured data from SRT subtitle files to enable translation while preserving timing and formatting information.

Instructions

Parse SRT file content and return structured data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesSRT file content to parse

Implementation Reference

  • Registration of the parse_srt tool in the MCP server's listTools response, including name, description, and input schema.
    {
      name: 'parse_srt',
      description: 'Parse SRT file content and return structured data',
      inputSchema: {
        type: 'object',
        properties: {
          content: {
            type: 'string',
            description: 'SRT file content to parse',
          },
        },
        required: ['content'],
      },
    },
  • Handler function for the parse_srt MCP tool that invokes parseSRTFile, handles errors, and returns the parsed SRT structure as JSON.
    private async handleParseSRT(args: any) {
      const { content } = args;
      const parseResult = parseSRTFile(content);
    
      if (!parseResult.success || !parseResult.file) {
        const errorDetails = parseResult.errors?.map(e => `${e.type}: ${e.message}`).join(', ') || 'Unknown parsing error';
        throw new Error(`Failed to parse SRT file: ${errorDetails}`);
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(parseResult.file, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the parse_srt tool requiring SRT content string.
    inputSchema: {
      type: 'object',
      properties: {
        content: {
          type: 'string',
          description: 'SRT file content to parse',
        },
      },
      required: ['content'],
    },
  • Core implementation of SRT parsing: splits into blocks, parses each subtitle, validates timings and styles, handles errors and metadata extraction.
    export function parseSRTFile(content: string): SRTProcessingResult {
      const errors: SRTValidationError[] = [];
      const warnings: string[] = [];
      const subtitles: SRTSubtitle[] = [];
      
      try {
        const blocks = content.trim().split(/\n\s*\n/);
        let lineNumber = 1;
        
        for (const block of blocks) {
          if (!block.trim()) continue;
          
          const lines = block.split('\n');
          const subtitle = parseSubtitleBlock(lines, lineNumber);
          
          if (subtitle) {
            subtitles.push(subtitle);
          } else {
            errors.push({
              line: lineNumber,
              message: 'Failed to parse subtitle block',
              type: 'format'
            });
          }
          
          lineNumber += lines.length + 1; // +1 for empty line separator
        }
        
        // Validate timing sequences
        validateTimingSequences(subtitles, errors);
        
        // Validate style tags
        validateAllStyleTags(subtitles, errors, warnings);
        
        return {
          success: errors.length === 0,
          file: {
            subtitles,
            metadata: extractMetadata(content)
          },
          errors: errors.length > 0 ? errors : undefined,
          warnings: warnings.length > 0 ? warnings : undefined
        };
        
      } catch (error) {
        return {
          success: false,
          errors: [{
            line: 1,
            message: `Parse error: ${error instanceof Error ? error.message : 'Unknown error'}`,
            type: 'format'
          }]
        };
      }
    }
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 states the tool 'parse[s] SRT file content and return[s] structured data,' which implies a read-only operation, but it doesn't specify error handling (e.g., for invalid input), performance characteristics, or the format of the returned structured data. This is a significant gap for a tool with no annotation coverage.

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 a single, efficient sentence that directly states the tool's function without any wasted words. It is front-loaded with the core action ('parse') and resource ('SRT file content'), making it easy to understand at a glance.

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

Completeness2/5

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

Given the tool's complexity (parsing structured data) and the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'structured data' means in the return value, how errors are handled, or any constraints on the input content. For a parsing tool with no structured output documentation, this leaves critical gaps for the agent.

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 input schema has 100% description coverage, with the 'content' parameter clearly documented as 'SRT file content to parse.' The description adds no additional meaning beyond this, as it only repeats that it parses 'SRT file content.' Given the high schema coverage, the baseline score of 3 is appropriate, as the schema already does the heavy lifting.

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 tool's purpose with a specific verb ('parse') and resource ('SRT file content'), making it immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'translate_srt' or 'write_srt' that also work with SRT files, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'translate_srt' (for translation) or 'write_srt' (for writing), nor does it specify prerequisites such as needing valid SRT content. This leaves the agent without context for tool selection.

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