Skip to main content
Glama

audio_analyze

Analyze audio files by extracting fingerprints, tracking pitch, generating spectrograms, and comparing audio iterations. Supports batch operations for multiple files.

Instructions

Analyze audio. ops: fingerprint|formants|compare|diff|spectrogram|waveform|waterfall|pitch|onsets|batch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAudio file path (or array for batch)
opYesOperation to perform
path2NoSecond file for compare/diff

Implementation Reference

  • Registration of the 'audio_analyze' MCP tool via @server.list_tools() decorator, defining the tool name, description, and input schema.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        return [
            Tool(
                name="audio_analyze",
                description="Analyze audio. ops: fingerprint|formants|compare|diff|spectrogram|waveform|waterfall|pitch|onsets|batch",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "path": {
                            "type": ["string", "array"],
                            "description": "Audio file path (or array for batch)",
                        },
                        "op": {
                            "type": "string",
                            "enum": list(OPERATIONS.keys()),
                            "description": "Operation to perform",
                        },
                        "path2": {
                            "type": "string",
                            "description": "Second file for compare/diff",
                        },
                    },
                    "required": ["path", "op"],
                },
            )
        ]
  • Handler function that executes the 'audio_analyze' tool logic via @server.call_tool(), dispatching to OPERATIONS based on the 'op' argument.
    @server.call_tool()
    async def call_tool(name: str, arguments: dict) -> list[TextContent]:
        if name != "audio_analyze":
            return [TextContent(type="text", text=json.dumps({"error": f"unknown tool: {name}"}))]
    
        path = arguments.get("path")
        op = arguments.get("op")
        path2 = arguments.get("path2")
    
        if op not in OPERATIONS:
            return [TextContent(type="text", text=json.dumps({"error": f"unknown op: {op}"}))]
    
        try:
            result = OPERATIONS[op](path, path2)
            return [TextContent(type="text", text=json.dumps(result))]
        except Exception as e:
            return [TextContent(type="text", text=json.dumps({"error": str(e)}))]
  • Input schema for the audio_analyze tool, defining path (string|array), op (enum of operations), and optional path2 parameters.
    inputSchema={
        "type": "object",
        "properties": {
            "path": {
                "type": ["string", "array"],
                "description": "Audio file path (or array for batch)",
            },
            "op": {
                "type": "string",
                "enum": list(OPERATIONS.keys()),
                "description": "Operation to perform",
            },
            "path2": {
                "type": "string",
                "description": "Second file for compare/diff",
            },
        },
        "required": ["path", "op"],
    },
  • OPERATIONS dictionary that maps operation names to lambda functions dispatching to the actual analysis functions (fingerprint, formants, compare, diff, spectrogram, waveform, waterfall, pitch, onsets, batch).
    OPERATIONS = {
        "fingerprint": lambda p, p2: fingerprint(p),
        "formants": lambda p, p2: formants(p),
        "compare": lambda p, p2: compare(p, p2),
        "diff": lambda p, p2: diff(p, p2),
        "spectrogram": lambda p, p2: save_spectrogram(p),
        "waveform": lambda p, p2: save_waveform(p),
        "waterfall": lambda p, p2: save_waterfall(p),
        "pitch": lambda p, p2: pitch_track(p),
        "onsets": lambda p, p2: detect_onsets(p),
        "batch": lambda p, p2: batch_analyze(p if isinstance(p, list) else [p]),
    }
  • The 'fingerprint' helper function - one of the core analysis functions dispatched by the OPERATIONS dict when op='fingerprint'.
    def fingerprint(path: str) -> dict:
        """Compute numerical fingerprint of audio file."""
        y, sr = librosa.load(path, sr=None)
        return {
            "rms": round(float(np.sqrt(np.mean(y**2))), 4),
            "peak": round(float(np.max(np.abs(y))), 4),
            "zcr": round(float(np.mean(librosa.feature.zero_crossing_rate(y))), 4),
            "centroid": round(float(np.mean(librosa.feature.spectral_centroid(y=y, sr=sr))), 1),
            "bandwidth": round(float(np.mean(librosa.feature.spectral_bandwidth(y=y, sr=sr))), 1),
            "rolloff": round(float(np.mean(librosa.feature.spectral_rolloff(y=y, sr=sr))), 1),
            "duration": round(len(y) / sr, 3),
        }
Behavior3/5

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

The description indicates the tool performs analysis, which implies read-only behavior, but does not explicitly state side effects, error conditions, or performance characteristics. With no annotations, more detail would be beneficial.

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 extremely concise—one short sentence and a clear list of operations. No wasted words, and the structure is easy to parse.

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?

The description does not explain what each operation returns, how errors are handled, or the role of the optional 'path2' parameter. For a tool with multiple complex operations and no output schema, this is insufficient.

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 already provides descriptions for all three parameters (100% coverage). The description only repeats the enum values for 'op' and adds no new meaning beyond what the schema offers. Baseline score of 3 is appropriate.

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 'Analyze audio' and lists all supported operations, making the tool's purpose specific and unambiguous. The verb+resource pattern is effective.

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

Usage Guidelines3/5

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

While the list of operations is provided, there is no guidance on when to use each operation or how to choose between them (e.g., compare vs diff). The description implies the tool is for general audio analysis but lacks explicit usage context.

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/zachswift615/audio-analysis-mcp'

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