Skip to main content
Glama
DeveloperZo

MCP Audio Tweaker

by DeveloperZo

process_audio_file

Process audio files by adjusting volume, changing formats, and applying effects like fade or trim using FFmpeg operations.

Instructions

Apply audio processing operations to a single file using FFmpeg

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputFileYesPath to input audio file
outputFileYesPath for output file
operationsYesAudio processing operations to apply
overwriteNoWhether to overwrite existing output files

Implementation Reference

  • Main execution handler for the 'process_audio_file' tool. Parses input using Zod schema, attempts basic processor, falls back to advanced processor if validation fails, and returns JSON result.
    case 'process_audio_file': {
      try {
        const input = ProcessAudioFileInputSchema.parse(args);
        const result = await audioProcessor.processAudioFile(
          input.inputFile,
          input.outputFile,
          input.operations,
          (args as any).overwrite || false
        );
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (validationError) {
        // If validation fails, try with the advanced processor
        const result = await advancedProcessor.processAudioFile(
          (args as any).inputFile,
          (args as any).outputFile,
          (args as any).operations,
          (args as any).overwrite || false
        );
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      }
    }
  • Zod validation schema for process_audio_file inputs, including file paths, operations for volume, format, and effects.
    export const ProcessAudioFileInputSchema = z.object({
      inputFile: FilePathSchema,
      outputFile: z.string().min(1),
      operations: AudioOperationsSchema
    }).transform((data) => {
      // Transform string values to numbers for format operations
      if (data.operations.format) {
        if (data.operations.format.sampleRate && typeof data.operations.format.sampleRate === 'string') {
          data.operations.format.sampleRate = parseInt(data.operations.format.sampleRate) as any;
        }
        if (data.operations.format.channels && typeof data.operations.format.channels === 'string') {
          data.operations.format.channels = parseInt(data.operations.format.channels) as any;
        }
      }
      return data;
    });
  • MCP Tool registration object defining name, description, and JSON input schema for 'process_audio_file'.
    export const processAudioFileTool: Tool = {
      name: 'process_audio_file',
      description: 'Apply audio processing operations to a single file using FFmpeg',
      inputSchema: {
        type: 'object',
        properties: {
          inputFile: {
            type: 'string',
            description: 'Path to input audio file'
          },
          outputFile: {
            type: 'string',
            description: 'Path for output file'
          },
          operations: {
            type: 'object',
            description: 'Audio processing operations to apply',
            properties: {
              volume: {
                type: 'object',
                properties: {
                  adjust: { type: 'number', minimum: -60, maximum: 20 },
                  normalize: { type: 'boolean' },
                  targetLUFS: { type: 'number' }
                }
              },
              format: {
                type: 'object',
                properties: {
                  sampleRate: { type: 'number', enum: [8000, 16000, 22050, 44100, 48000, 96000, 192000] },
                  bitrate: { type: 'number', minimum: 64, maximum: 320 },
                  channels: { type: 'number', enum: [1, 2, 6, 8] },
                  codec: { type: 'string', enum: ['pcm', 'mp3', 'aac', 'vorbis', 'flac'] }
                }
              },
              effects: {
                type: 'object',
                properties: {
                  fadeIn: { type: 'number', minimum: 0 },
                  fadeOut: { type: 'number', minimum: 0 },
                  trim: {
                    type: 'object',
                    properties: {
                      start: { type: 'number', minimum: 0 },
                      end: { type: 'number', minimum: 0 }
                    }
                  },
                  loop: {
                    type: 'object',
                    properties: {
                      enabled: { type: 'boolean' },
                      count: { type: 'number', minimum: 1 }
                    }
                  }
                }
              }
            }
          },
          overwrite: {
            type: 'boolean',
            description: 'Whether to overwrite existing output files',
            default: false
          }
        },
        required: ['inputFile', 'outputFile', 'operations']
      }
    };
  • Base implementation of processAudioFile method that validates inputs, builds FFmpeg command with operations, executes processing, and returns result. Used by both basic and advanced processors.
    async processAudioFile(
      inputFile: string,
      outputFile: string,
      operations: AudioOperations,
      overwrite: boolean = false
    ): Promise<ProcessingResult> {
      const startTime = Date.now();
      
      try {
        // Validate input
        await validateInputFile(inputFile);
        await ensureOutputDirectory(outputFile);
        await handleExistingOutput(outputFile, overwrite);
        
        // Create FFmpeg command
        const command = createFFmpegCommand(inputFile);
        
        // Apply operations
        this.applyOperationsToCommand(command, operations);
        
        // Execute command
        await executeFFmpegCommand(command, outputFile);
        
        const processingTime = Date.now() - startTime;
        
        return {
          success: true,
          inputFile,
          outputFile,
          processingTime,
          operations
        };
        
      } catch (error) {
        const processingTime = Date.now() - startTime;
        
        return {
          success: false,
          inputFile,
          outputFile,
          processingTime,
          operations,
          error: error instanceof Error ? error.message : 'Unknown error'
        };
      }
    }
  • Overridden applyOperationsToCommand in advanced processor that adds support for advanced effects like pitch, tempo, spectral, dynamics, and spatial processing beyond base capabilities.
    protected applyOperationsToCommand(command: any, operations: AudioOperations): void {
      // Apply base operations first (volume, format, basic effects)
      super.applyOperationsToCommand(command, operations);
      
      // Apply advanced operations
      if (operations.advanced) {
        this.applyAdvancedOperations(command, operations.advanced);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Apply audio processing operations' and 'using FFmpeg', which hints at mutation and external tool usage, but doesn't specify critical behaviors like whether it modifies files in-place, requires specific permissions, handles errors, or has performance constraints. For a tool with complex operations and no annotations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Apply audio processing operations to a single file using FFmpeg'). It wastes no words and is appropriately sized for the tool's complexity, making it easy to parse quickly. Every part of the sentence contributes essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters with nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain the output format, error handling, or behavioral traits like file system interactions or FFmpeg dependencies. With rich input schema but missing critical context for a mutation tool, the description fails to provide enough information for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with detailed descriptions for parameters like 'inputFile', 'outputFile', and 'overwrite', and nested objects for 'operations'. The description adds minimal value beyond the schema, as it only vaguely references 'audio processing operations' without explaining the structure or purpose of the 'operations' object. Given the high schema coverage, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Apply audio processing operations') and resource ('to a single file using FFmpeg'), making the purpose understandable. However, it doesn't differentiate this tool from siblings like 'advanced_process', 'batch_process_audio', or 'apply_preset', which likely offer similar or overlapping functionality. The description is specific but lacks sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'advanced_process', 'batch_process_audio', and 'apply_preset', an agent needs explicit direction on choosing this tool for single-file FFmpeg processing over others. The description implies usage for audio processing but offers no context about prerequisites, limitations, or comparisons to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/DeveloperZo/mcp-audio-tweaker'

If you have feedback or need assistance with the MCP directory API, please join our Discord server