Skip to main content
Glama
brandon-fryslie

elevenlabs-mcp

isolate_audio

Read-only

Isolate audio from a file by providing the input file path. The extracted audio is saved to your desktop or a custom output directory.

Instructions

Isolate audio from a file. Saves output file to directory (default: $HOME/Desktop).

⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_file_pathYes
output_directoryNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The isolate_audio tool handler function. It reads an input audio file, calls ElevenLabs' audio_isolation.convert API to isolate audio, and returns the result via handle_output_mode.
    @mcp.tool(
        annotations=ToolAnnotations(readOnlyHint=True, openWorldHint=True),
        description=f"""Isolate audio from a file. {get_output_mode_description(output_mode)}.
    
        ⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user.
        """
    )
    def isolate_audio(
        input_file_path: str, output_directory: str | None = None
    ) -> Union[TextContent, EmbeddedResource]:
        file_path = handle_input_file(input_file_path)
        output_path = make_output_path(output_directory, base_path)
        output_file_name = make_output_file("iso", file_path.name, "mp3")
        with file_path.open("rb") as f:
            audio_bytes = f.read()
        audio_data = client.audio_isolation.convert(
            audio=audio_bytes,
        )
        audio_bytes = b"".join(audio_data)
    
        # Handle different output modes
        return handle_output_mode(audio_bytes, output_path, output_file_name, output_mode)
  • The tool registration via @mcp.tool decorator with annotations and description.
    @mcp.tool(
        annotations=ToolAnnotations(readOnlyHint=True, openWorldHint=True),
        description=f"""Isolate audio from a file. {get_output_mode_description(output_mode)}.
    
        ⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user.
        """
    )
  • Helper function handle_input_file validates and resolves the input file path, used by isolate_audio.
    def handle_input_file(file_path: str, audio_content_check: bool = True) -> Path:
        if not os.path.isabs(file_path) and not os.environ.get("ELEVENLABS_MCP_BASE_PATH"):
            make_error(
                "File path must be an absolute path if ELEVENLABS_MCP_BASE_PATH is not set"
            )
        path = Path(file_path)
        if not path.exists() and path.parent.exists():
            parent_directory = path.parent
            similar_files = try_find_similar_files(path.name, parent_directory)
            similar_files_formatted = ",".join([str(file) for file in similar_files])
            if similar_files:
                make_error(
                    f"File ({path}) does not exist. Did you mean any of these files: {similar_files_formatted}?"
                )
            make_error(f"File ({path}) does not exist")
        elif not path.exists():
            make_error(f"File ({path}) does not exist")
        elif not path.is_file():
            make_error(f"File ({path}) is not a file")
    
        if audio_content_check and not check_audio_file(path):
            make_error(f"File ({path}) is not an audio or video file")
        return path
  • Helper function handle_output_mode routes the output to files/resources/both modes, used by isolate_audio.
    def handle_output_mode(
        file_data: bytes,
        output_path: Path,
        filename: str,
        output_mode: str,
        success_message: str = None,
    ) -> Union[TextContent, EmbeddedResource]:
        """
        Handle different output modes for file generation.
    
        Args:
            file_data: Raw file data as bytes
            output_path: Path where file should be saved
            filename: Name of the file
            output_mode: Output mode ('files', 'resources', or 'both')
            success_message: Custom success message for files mode (optional)
    
        Returns:
            Union[TextContent, EmbeddedResource]: TextContent for 'files' mode,
                                                EmbeddedResource for 'resources' and 'both' modes
        """
        file_extension = Path(filename).suffix.lstrip(".")
        full_file_path = output_path / filename
    
        if output_mode == "files":
            # Save to disk and return TextContent with success message
            output_path.mkdir(parents=True, exist_ok=True)
            with open(full_file_path, "wb") as f:
                f.write(file_data)
    
            if success_message and "{file_path}" in success_message:
                message = success_message.replace("{file_path}", str(full_file_path))
            else:
                message = success_message or f"Success. File saved as: {full_file_path}"
            return TextContent(type="text", text=message)
    
        elif output_mode == "resources":
            # Return as EmbeddedResource without saving to disk
            return create_resource_response(file_data, filename, file_extension, directory=output_path)
    
        elif output_mode == "both":
            # Save to disk AND return as EmbeddedResource
            output_path.mkdir(parents=True, exist_ok=True)
            with open(full_file_path, "wb") as f:
                f.write(file_data)
            return create_resource_response(file_data, filename, file_extension, directory=output_path)
    
        else:
            raise ValueError(
                f"Invalid output mode: {output_mode}. Must be 'files', 'resources', or 'both'"
            )
  • Helper function make_output_file generates the output file name with 'iso_' prefix and mp3 extension, used by isolate_audio.
    def make_output_file(
        tool: str, text: str, extension: str, full_id: bool = False
    ) -> Path:
        id = text if full_id else text[:5]
    
        output_file_name = f"{tool}_{id.replace(' ', '_')}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.{extension}"
        return Path(output_file_name)
Behavior1/5

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

The description contradicts the readOnlyHint annotation (true) by stating it saves an output file, implying a mutation. According to guidelines, this contradiction warrants a score of 1.

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 two concise sentences plus a cost warning, all of which are essential and free of filler. It is efficiently front-loaded.

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?

Despite having an output schema, the description lacks details on what 'isolate audio' means (e.g., vocal extraction), file format support, and parameter constraints. Important context is missing.

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

Parameters2/5

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

With 0% schema coverage, the description adds minimal value by only noting the default output directory. It does not explain the input_file_path parameter requirements or the output format, leaving significant gaps.

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 'Isolate audio from a file' and specifies the output destination with a default. While it doesn't detail the exact nature of isolation (e.g., vocal extraction), it is sufficiently clear and distinct from sibling tools like speech_to_text.

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 cost warning explicitly states that the tool should only be used when the user explicitly requests it, providing clear usage guidance. However, it does not mention alternative tools or scenarios where this tool should be avoided beyond the cost.

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/brandon-fryslie/vibedungeon-voice'

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