Skip to main content
Glama

write_srt

Write SRT subtitle data to file format for storing translated or processed subtitle content with preserved timing and formatting.

Instructions

Write SRT data to file format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
srtDataYesSRT data object to write

Implementation Reference

  • The main handler function for the 'write_srt' MCP tool. Extracts 'srtData' from input arguments and uses writeSRTFile to generate the SRT string content, which is returned in the tool response format.
    private async handleWriteSRT(args: any) { const { srtData } = args; const srtContent = writeSRTFile(srtData); return { content: [ { type: 'text', text: srtContent, }, ], }; }
  • Registration of the 'write_srt' tool in the ListTools response, specifying the tool name, description, and input schema.
    { name: 'write_srt', description: 'Write SRT data to file format', inputSchema: { type: 'object', properties: { srtData: { type: 'object', description: 'SRT data object to write', }, }, required: ['srtData'], }, },
  • Input schema definition for the 'write_srt' tool, requiring an 'srtData' object.
    inputSchema: { type: 'object', properties: { srtData: { type: 'object', description: 'SRT data object to write', }, }, required: ['srtData'], },
  • Core utility function that implements the SRT writing logic: formats SRTFile object (with metadata and subtitles) into standard SRT string format.
    export function writeSRTFile(srtFile: SRTFile): string { const lines: string[] = []; // Add metadata if present if (srtFile.metadata) { if (srtFile.metadata.title) lines.push(`TITLE: ${srtFile.metadata.title}`); if (srtFile.metadata.author) lines.push(`AUTHOR: ${srtFile.metadata.author}`); if (srtFile.metadata.description) lines.push(`DESCRIPTION: ${srtFile.metadata.description}`); if (lines.length > 0) lines.push(''); // Empty line after metadata } // Add subtitles for (const subtitle of srtFile.subtitles) { lines.push(subtitle.index.toString()); lines.push(`${formatSRTTime(subtitle.startTime)} --> ${formatSRTTime(subtitle.endTime)}`); lines.push(subtitle.rawText); lines.push(''); // Empty line separator } return lines.join('\n'); }

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