list_output_files
Retrieve saved audio files and associated metadata from the output directory for organized access and management of text-to-speech synthesis results.
Instructions
List saved audio files in the output directory with metadata
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/typescript/index.ts:499-535 (handler)The handler function in AdvancedTTSServer class that executes the tool logic: reads the output directory, filters for supported audio formats (wav, mp3, flac, ogg), retrieves file stats, and returns sorted list with metadata.async listOutputFiles() { try { const files = await fs.readdir(this.outputDir); const audioFiles = files.filter(file => AudioFormats.some(format => file.endsWith(`.${format}`)) ); const fileInfo = await Promise.all( audioFiles.map(async (file) => { const filePath = join(this.outputDir, file); const stats = await fs.stat(filePath); return { filename: file, path: filePath, size: stats.size, created: stats.birthtime.toISOString(), modified: stats.mtime.toISOString(), format: file.split('.').pop() }; }) ); return { success: true, files: fileInfo.sort((a, b) => new Date(b.modified).getTime() - new Date(a.modified).getTime() ), totalFiles: fileInfo.length, outputDirectory: this.outputDir }; } catch (error) { return { success: false, error: `Failed to list files: ${error}` }; } }
- src/typescript/index.ts:722-728 (registration)Registers the 'list_output_files' tool in the server's listTools response, including name, description, and input schema (no required parameters).name: 'list_output_files', description: 'List saved audio files in the output directory with metadata', inputSchema: { type: 'object', properties: {}, }, },
- src/typescript/index.ts:725-727 (schema)Defines the input schema for the tool: an empty object since no parameters are required.type: 'object', properties: {}, },
- src/typescript/index.ts:820-846 (helper)MCP server request handler that calls the listOutputFiles method and formats the response content for the tool call, including error handling and rich text formatting.case 'list_output_files': const fileList = await ttsServer.listOutputFiles(); if (fileList.success) { const files = fileList.files?.map(f => `**${f.filename}** (${(f.size / 1024).toFixed(1)}KB) - ${f.format?.toUpperCase()}` ).join('\n'); return { content: [ { type: 'text', text: `🎙️ **Output Files (${fileList.totalFiles})**\n\n` + `**Directory:** ${fileList.outputDirectory}\n\n` + `${files || 'No audio files found'}`, }, ], }; } else { return { content: [ { type: 'text', text: `❌ **Error:** ${fileList.error}`, }, ], }; }