format_transcript
Convert YouTube transcript data into text, JSON, or SRT formats for accessibility and integration needs.
Instructions
Format existing transcript data into different formats
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": {
"transcript": "<transcript>",
"format": "<format>"
},
"name": "format_transcript"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| transcript | Yes | Transcript data to format | |
| format | Yes | Output format | json |
Implementation Reference
- src/server/mcp-server.ts:304-319 (handler)MCP tool handler that validates input parameters and delegates formatting to the YouTubeTranscriptService.
private async handleFormatTranscript(args: any) { const { transcript, format } = args; if (!transcript || !format) { throw new McpError(ErrorCode.InvalidParams, 'transcript and format are required'); } const result = this.transcriptService.formatTranscript(transcript, format); return { content: [{ type: 'text', text: result }] }; } - Core implementation of the transcript formatting logic, supporting 'text', 'json', and 'srt' output formats.
public formatTranscript( transcript: TranscriptItem[], format: 'text' | 'json' | 'srt' ): string { switch (format) { case 'text': return transcript.map(item => item.text).join(' '); case 'json': return JSON.stringify(transcript, null, 2); case 'srt': return transcript.map((item, index) => { const start = this.secondsToSrtTime(item.start); const end = this.secondsToSrtTime(item.start + item.duration); return `${index + 1}\n${start} --> ${end}\n${item.text}\n`; }).join('\n'); default: return JSON.stringify(transcript, null, 2); } } - src/server/mcp-server.ts:178-205 (registration)Registration of the 'format_transcript' tool in the MCP server, including description and input schema.
{ name: 'format_transcript', description: 'Format existing transcript data into different formats', inputSchema: { type: 'object', properties: { transcript: { type: 'array', items: { type: 'object', properties: { text: { type: 'string' }, start: { type: 'number' }, duration: { type: 'number' } } }, description: 'Transcript data to format' }, format: { type: 'string', enum: ['text', 'json', 'srt'], description: 'Output format', default: 'json' } }, required: ['transcript', 'format'] } }, - src/server/mcp-server.ts:182-204 (schema)Input schema defining the parameters for the format_transcript tool: transcript array and format enum.
type: 'object', properties: { transcript: { type: 'array', items: { type: 'object', properties: { text: { type: 'string' }, start: { type: 'number' }, duration: { type: 'number' } } }, description: 'Transcript data to format' }, format: { type: 'string', enum: ['text', 'json', 'srt'], description: 'Output format', default: 'json' } }, required: ['transcript', 'format'] }