Skip to main content
Glama

get_attachment_content

Retrieve attached files from Kaltura videos to access supplementary materials like PDFs, presentation slides, or documents. Returns file content or download URLs for specific attachment IDs.

Instructions

Download or read ATTACHED FILES from videos. USE WHEN: Accessing supplementary materials, downloading PDFs, getting presentation slides, reading attached documents. RETURNS: File content (if text) or download URL. EXAMPLE: 'Download the PDF slides', 'Read the attached notes'. Use after list_attachment_assets to get specific attachment ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attachment_asset_idYesAttachment ID from list_attachment_assets (format: '1_xyz789')

Implementation Reference

  • The core handler function implementing get_attachment_content tool. It retrieves attachment asset details using Kaltura API, generates download URL, downloads the content, base64 encodes it, and returns structured JSON with metadata and content.
    async def get_attachment_content(
        manager: KalturaClientManager,
        attachment_asset_id: str,
    ) -> str:
        """Get download URL and details for an attachment asset."""
    
        if not ATTACHMENT_AVAILABLE:
            return json.dumps(
                {
                    "error": "Attachment functionality is not available. The Attachment plugin is not installed.",
                    "attachmentAssetId": attachment_asset_id,
                },
                indent=2,
            )
    
        client = manager.get_client()
    
        try:
            # Get attachment asset details
            attachment_asset = client.attachment.attachmentAsset.get(attachment_asset_id)
    
            # Get the attachment download URL
            download_url = client.attachment.attachmentAsset.getUrl(attachment_asset_id)
    
            # Validate URL before making request
            if not download_url or not isinstance(download_url, str):
                return json.dumps(
                    {
                        "error": "Invalid or missing attachment download URL",
                        "attachmentAssetId": attachment_asset_id,
                    },
                    indent=2,
                )
            elif not download_url.startswith(("http://", "https://")):
                return json.dumps(
                    {
                        "error": "Attachment URL must use HTTP or HTTPS protocol",
                        "attachmentAssetId": attachment_asset_id,
                    },
                    indent=2,
                )
    
            # Download the actual attachment content
            attachment_content = None
            download_error = None
    
            try:
                # Create a session for downloading
                session = requests.Session()
    
                # Set headers
                headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
    
                # Download the attachment content with timeout
                response = session.get(download_url, headers=headers, timeout=30)
                response.raise_for_status()
    
                # Encode content as base64
                import base64
    
                attachment_content = base64.b64encode(response.content).decode("utf-8")
    
            except requests.exceptions.RequestException as e:
                download_error = f"Failed to download attachment content: {str(e)}"
            except Exception as e:
                download_error = f"Error processing attachment content: {str(e)}"
    
            result = {
                "attachmentAssetId": attachment_asset_id,
                "entryId": attachment_asset.entryId,
                "filename": attachment_asset.filename,
                "title": attachment_asset.title,
                "format": attachment_asset.format.value
                if hasattr(attachment_asset.format, "value")
                else str(attachment_asset.format),
                "downloadUrl": download_url,
                "size": attachment_asset.size,
                "description": attachment_asset.description,
                "tags": attachment_asset.tags,
            }
    
            if download_error:
                result["downloadError"] = download_error
                result[
                    "note"
                ] = "Failed to download content automatically. You can try the downloadUrl manually."
            else:
                result["content"] = attachment_content
                result["contentEncoding"] = "base64"
                result["note"] = "Content downloaded and encoded as base64"
    
            return json.dumps(result, indent=2)
    
        except Exception as e:
            return json.dumps(
                {
                    "error": f"Failed to get attachment content: {str(e)}",
                    "attachmentAssetId": attachment_asset_id,
                },
                indent=2,
            )
  • Tool registration in MCP server's list_tools() function, defining name, description, and input schema.
        types.Tool(
            name="get_attachment_content",
            description="Download or read ATTACHED FILES from videos. USE WHEN: Accessing supplementary materials, downloading PDFs, getting presentation slides, reading attached documents. RETURNS: File content (if text) or download URL. EXAMPLE: 'Download the PDF slides', 'Read the attached notes'. Use after list_attachment_assets to get specific attachment ID.",
            inputSchema={
                "type": "object",
                "properties": {
                    "attachment_asset_id": {
                        "type": "string",
                        "description": "Attachment ID from list_attachment_assets (format: '1_xyz789')",
                    },
                },
                "required": ["attachment_asset_id"],
            },
        ),
    ]
  • Input schema definition for the get_attachment_content tool, specifying the required attachment_asset_id parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "attachment_asset_id": {
                "type": "string",
                "description": "Attachment ID from list_attachment_assets (format: '1_xyz789')",
            },
        },
        "required": ["attachment_asset_id"],
    },
  • Dispatch/execution routing in the server's call_tool() method for invoking the get_attachment_content handler.
    elif name == "get_attachment_content":
        result = await get_attachment_content(kaltura_manager, **arguments)
  • Import and export of the get_attachment_content function in the tools module __init__.py for easy access.
        get_attachment_content,
        get_caption_content,
        list_attachment_assets,
        list_caption_assets,
    )
    
    # Import by domain for clear organization
    from .media import (
        get_download_url,
        get_media_entry,
        get_thumbnail_url,
        list_media_entries,
    )
    from .search import (
        esearch_entries,
        list_categories,
        search_entries,
        search_entries_intelligent,
    )
    from .utils import (
        handle_kaltura_error,
        safe_serialize_kaltura_field,
        validate_entry_id,
    )
    
    # Export all tools
    __all__ = [
        # Utilities
        "handle_kaltura_error",
        "safe_serialize_kaltura_field",
        "validate_entry_id",
        # Media operations
        "get_download_url",
        "get_media_entry",
        "get_thumbnail_url",
        "list_media_entries",
        # Analytics operations
        "get_analytics",
        "get_analytics_timeseries",
        "get_video_retention",
        "get_realtime_metrics",
        "get_quality_metrics",
        "get_geographic_breakdown",
        "list_analytics_capabilities",
        # Search operations
        "esearch_entries",
        "list_categories",
        "search_entries",
        "search_entries_intelligent",
        # Asset operations
        "get_attachment_content",
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 (downloads or reads attached files), mentions the return behavior ('RETURNS: File content (if text) or download URL'), and provides context about prerequisites (needs attachment ID from list_attachment_assets). However, it doesn't mention potential limitations like file size restrictions, authentication requirements, or rate limits.

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 efficiently structured with clear sections (purpose, usage guidelines, returns, examples, prerequisites), uses bullet-like formatting without actual bullets, and every sentence adds value. It's appropriately sized for the tool's complexity and front-loads the most important information.

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 (single parameter, no annotations, no output schema), the description is quite complete. It covers purpose, usage scenarios, return values, examples, and prerequisites. The main gap is the lack of output schema, so the description must describe returns, which it does adequately but could be more specific about format distinctions between text content and download URLs.

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?

Schema description coverage is 100%, so the schema already fully documents the single parameter (attachment_asset_id). The description adds minimal value beyond the schema by mentioning that the ID comes from 'list_attachment_assets' and giving a format example, but this is essentially redundant with the schema's description. Baseline 3 is appropriate when the schema does the heavy lifting.

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 specific action ('Download or read') and resource ('ATTACHED FILES from videos'), distinguishing it from siblings like get_caption_content (captions) or get_download_url (general downloads). It explicitly mentions attachment files, which differentiates it from other media-related tools.

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

Usage Guidelines5/5

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

The description provides explicit guidance with 'USE WHEN:' listing specific scenarios (accessing supplementary materials, downloading PDFs, etc.), includes an alternative tool ('Use after list_attachment_assets to get specific attachment ID'), and gives concrete examples ('Download the PDF slides', 'Read the attached notes'). This clearly tells the agent when and how to use this tool.

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/zoharbabin/kaltura-mcp'

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