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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"srtData": "<srtData>"
},
"name": "write_srt"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| srtData | Yes | SRT data object to write |
Implementation Reference
- src/mcp/server.ts:441-453 (handler)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, }, ], }; } - src/mcp/server.ts:111-120 (schema)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'], }, - src/mcp/server.ts:108-121 (registration)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'], }, }, - src/parsers/srt-parser.ts:287-307 (helper)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'); }