Skip to main content
Glama

write_srt

Save SRT subtitle data to a file format for storage or distribution. This tool writes processed subtitle content while maintaining timing and formatting.

Instructions

Write SRT data to file format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
srtDataYesSRT data object to write

Implementation Reference

  • Handler function for the 'write_srt' tool that extracts SRT data from arguments, calls writeSRTFile to generate SRT content, and returns it as text content.
    private async handleWriteSRT(args: any) { const { srtData } = args; const srtContent = writeSRTFile(srtData); return { content: [ { type: 'text', text: srtContent, }, ], }; }
  • Input schema definition for the 'write_srt' tool, specifying the required 'srtData' object.
    inputSchema: { type: 'object', properties: { srtData: { type: 'object', description: 'SRT data object to write', }, }, required: ['srtData'], },
  • Registration of the 'write_srt' tool in the MCP server's tool list, including 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'], }, },
  • Core helper function that converts SRTFile object back to SRT string format, handling metadata and subtitles with proper formatting.
    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