Skip to main content
Glama
dandeliongold

Decent-Sampler Drums MCP Server

analyze_wav_samples

Analyze WAV files to detect drum sample issues like header problems, metadata inconsistencies, and compatibility errors for DecentSampler drum kits.

Instructions

Analyze WAV files to detect common issues in drum kit samples.

This tool checks for:

  • Non-standard WAV headers that may cause playback issues

  • Metadata inconsistencies that could affect multi-mic setups

  • Sample rate and bit depth compatibility

  • Channel configuration issues

  • File size and format validation

Error Handling:

  • Reports detailed header format issues

  • Identifies metadata inconsistencies between related samples

  • Flags potential playback compatibility problems

  • Returns specific error messages for each issue type

Success Response: Returns detailed analysis including:

  • WAV header information

  • Sample metadata

  • Potential compatibility issues

  • Recommendations for fixes

IMPORTANT: Always use absolute paths (e.g., 'C:/Users/username/Documents/Samples/kick.wav') rather than relative paths.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYesArray of absolute paths to WAV files to analyze (e.g., ['C:/Users/username/Documents/Samples/kick.wav'])

Implementation Reference

  • Core implementation of WAV file analysis: reads file, parses and validates WAV header, calculates sample length, extracts metadata (sampleRate, channels, bitDepth), returns WavAnalysis object.
    export async function analyzeWavFile(path: string): Promise<WavAnalysis> {
      try {
        const buffer = await fs.readFile(path);
        if (buffer.length < 44) { // Minimum size for WAV header
          throw new McpError(
            ErrorCode.InvalidRequest,
            'File too small to be a valid WAV file'
          );
        }
    
        const header = await parseWavHeader(buffer);
        
        // Calculate sample length from data chunk size
        const bytesPerSample = header.bitsPerSample / 8;
        const samplesPerChannel = header.dataSize! / (bytesPerSample * header.numChannels);
    
        return {
          path,
          sampleLength: Math.round(samplesPerChannel),
          sampleRate: header.sampleRate,
          channels: header.numChannels,
          bitDepth: header.bitsPerSample
        };
      } catch (error: unknown) {
        if (error instanceof McpError) {
          throw error; // Re-throw validation errors
        }
        // Handle unexpected errors
        console.error('WAV analysis error:', error instanceof Error ? error.message : error);
        const message = error instanceof Error ? error.message : JSON.stringify(error);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to analyze WAV file ${path}: ${message}`
        );
      }
    }
  • TypeScript interface defining the output format of the WAV analysis results.
    export interface WavAnalysis {
      path: string;
      sampleLength: number;  // For end marker
      sampleRate: number;
      channels: number;
      bitDepth: number;
    }
  • src/index.ts:248-283 (registration)
    Tool registration in ListTools handler: defines name, detailed description, and input schema requiring array of absolute WAV file paths.
            name: "analyze_wav_samples",
            description: `Analyze WAV files to detect common issues in drum kit samples.
    
    This tool checks for:
    - Non-standard WAV headers that may cause playback issues
    - Metadata inconsistencies that could affect multi-mic setups
    - Sample rate and bit depth compatibility
    - Channel configuration issues
    - File size and format validation
    
    Error Handling:
    - Reports detailed header format issues
    - Identifies metadata inconsistencies between related samples
    - Flags potential playback compatibility problems
    - Returns specific error messages for each issue type
    
    Success Response:
    Returns detailed analysis including:
    - WAV header information
    - Sample metadata
    - Potential compatibility issues
    - Recommendations for fixes
    
    IMPORTANT: Always use absolute paths (e.g., 'C:/Users/username/Documents/Samples/kick.wav') rather than relative paths.`,
            inputSchema: {
              type: "object",
              properties: {
                paths: {
                  type: "array",
                  items: { type: "string" },
                  description: "Array of absolute paths to WAV files to analyze (e.g., ['C:/Users/username/Documents/Samples/kick.wav'])"
                }
              },
              required: ["paths"]
            }
          },
  • MCP CallTool handler: validates input, calls analyzeWavFile on each path in parallel, serializes results as JSON text response.
    case "analyze_wav_samples": {
      const args = request.params.arguments;
      if (!args || !Array.isArray(args.paths)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Invalid arguments: expected array of paths"
        );
      }
    
      try {
        const analyses = await Promise.all(
          args.paths.map(path => analyzeWavFile(path))
        );
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(analyses, null, 2)
          }]
        };
      } catch (error: unknown) {
        if (error instanceof McpError) throw error;
        const message = error instanceof Error ? error.message : String(error);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to analyze WAV files: ${message}`
        );
      }
    }
  • Helper function to parse and validate WAV header fields from file buffer.
    async function parseWavHeader(buffer: Buffer): Promise<WavHeader> {
      const invalidReasons: string[] = [];
    
      // RIFF header
      const riffHeader = buffer.toString('ascii', 0, 4);
      if (riffHeader !== 'RIFF') {
        invalidReasons.push('Missing RIFF header');
      }
    
      // File size
      const fileSize = buffer.readUInt32LE(4);
    
      // WAVE header
      const waveHeader = buffer.toString('ascii', 8, 12);
      if (waveHeader !== 'WAVE') {
        invalidReasons.push('Missing WAVE format marker');
      }
    
      // fmt chunk
      const fmtHeader = buffer.toString('ascii', 12, 16);
      if (fmtHeader !== 'fmt ') {
        invalidReasons.push('Missing fmt chunk');
      }
    
      const fmtChunkSize = buffer.readUInt32LE(16);
      const audioFormat = buffer.readUInt16LE(20);
      if (audioFormat !== 1) {
        invalidReasons.push(`Unsupported audio format: ${audioFormat} (only PCM supported)`);
      }
    
      const numChannels = buffer.readUInt16LE(22);
      const sampleRate = buffer.readUInt32LE(24);
      const byteRate = buffer.readUInt32LE(28);
      const blockAlign = buffer.readUInt16LE(32);
      const bitsPerSample = buffer.readUInt16LE(34);
    
      // Validate format values
      if (numChannels === 0) {
        invalidReasons.push('Invalid number of channels: 0');
      }
      if (sampleRate === 0) {
        invalidReasons.push('Invalid sample rate: 0');
      }
      if (bitsPerSample === 0) {
        invalidReasons.push('Invalid bits per sample: 0');
      }
    
      // Look for data chunk
      let dataHeader: string | undefined;
      let dataSize: number | undefined;
      let offset = 36;
    
      // Skip any non-data chunks
      while (offset < buffer.length - 8) {
        const chunkHeader = buffer.toString('ascii', offset, offset + 4);
        const chunkSize = buffer.readUInt32LE(offset + 4);
        
        if (chunkHeader === 'data') {
          dataHeader = chunkHeader;
          dataSize = chunkSize;
          break;
        }
        offset += 8 + chunkSize;
      }
    
      if (!dataHeader || !dataSize) {
        invalidReasons.push('Missing data chunk');
      }
    
      if (invalidReasons.length > 0) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          `WAV file validation failed: ${invalidReasons.join(', ')}`
        );
      }
    
      return {
        riffHeader,
        fileSize,
        waveHeader,
        fmtHeader,
        fmtChunkSize,
        audioFormat,
        numChannels,
        sampleRate,
        byteRate,
        blockAlign,
        bitsPerSample,
        dataHeader,
        dataSize
      };
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool does: checks for specific issues (e.g., non-standard headers, metadata inconsistencies), handles errors with detailed reports, and returns success responses with analysis details. It also specifies the requirement for absolute paths, adding operational context. However, it lacks information on potential side effects, rate limits, or authentication needs, which are minor gaps.

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

Conciseness4/5

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

The description is well-structured with sections (e.g., 'This tool checks for:', 'Error Handling:', 'Success Response:', 'IMPORTANT:'), making it easy to scan. It is appropriately sized for the tool's complexity, but some redundancy exists (e.g., repeating path guidance in the description and schema), and the bullet points could be more concise without losing clarity.

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

Completeness4/5

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

Given the tool's moderate complexity (analyzing WAV files for issues), no annotations, and no output schema, the description is largely complete. It covers purpose, checks, error handling, success response, and path requirements. However, it does not detail the format of the analysis output (e.g., structure of returned data), which is a minor gap since there's no output schema to compensate.

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 input schema has 100% description coverage, clearly documenting the 'paths' parameter as an array of absolute paths. The description reinforces this with an 'IMPORTANT' note about using absolute paths and provides an example, but does not add significant meaning beyond what the schema already states. This meets the baseline score of 3 for high schema coverage.

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

Purpose5/5

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

The description clearly states the tool's purpose: 'Analyze WAV files to detect common issues in drum kit samples.' It specifies the verb ('analyze'), resource ('WAV files'), and scope ('drum kit samples'), distinguishing it from sibling tools like configure_drum_controls or generate_drum_groups, which focus on configuration and generation rather than analysis.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: for analyzing WAV files to detect issues in drum kit samples. It includes an 'IMPORTANT' note about using absolute paths, which adds practical guidance. However, it does not explicitly state when not to use it or name alternatives among sibling tools, such as whether to use this for general audio files vs. drum-specific samples.

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/dandeliongold/mcp-decent-sampler-drums'

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