Skip to main content
Glama
KaiQin04

Instagram Download MCP Server

by KaiQin04

download_instagram_highlights

Download Instagram highlights from any user's profile by providing login credentials and specifying the target username, with optional filters for specific highlight titles.

Instructions

Download Instagram highlights for a target user.

Note: This feature requires login.

Args: username_target: Target Instagram username. highlight_title: Optional highlight title filter. username: Instagram username for authenticated access. password: Instagram password for authenticated access. download_root: Optional override for download directory.

Returns: A JSON-serializable dict containing download results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
username_targetYes
highlight_titleNo
usernameNo
passwordNo
download_rootNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'download_instagram_highlights' tool. It logs into Instagram using provided credentials, retrieves highlights for the target user (optionally filtered by title), downloads the story items from each highlight, and returns a structured result with paths to downloaded files.
    @mcp.tool()
    def download_instagram_highlights(
        username_target: str,
        highlight_title: str | None = None,
        username: str | None = None,
        password: str | None = None,
        download_root: str | None = None,
    ) -> dict[str, Any]:
        """Download Instagram highlights for a target user.
    
        Note: This feature requires login.
    
        Args:
            username_target: Target Instagram username.
            highlight_title: Optional highlight title filter.
            username: Instagram username for authenticated access.
            password: Instagram password for authenticated access.
            download_root: Optional override for download directory.
    
        Returns:
            A JSON-serializable dict containing download results.
        """
        try:
            target_username = username_target.strip()
            if not target_username:
                raise ValueError("username_target must not be empty.")
    
            title_filter = highlight_title.strip() if highlight_title else None
    
            target_root = _resolve_download_root(download_root)
            loader = _build_instaloader(
                target_root,
                download_pictures=True,
                download_videos=True,
                save_metadata=False,
                save_caption=False,
            )
            user, pwd = _resolve_credentials(username, password)
            _require_login(user, pwd, "highlights")
            _login_if_needed(loader, user, pwd)
    
            base_username = target_username.lower()
            profile = instaloader.Profile.from_username(
                loader.context,
                base_username,
            )
    
            results: list[dict[str, Any]] = []
            for highlight in loader.get_highlights(profile):
                if title_filter and (
                    highlight.title.strip().casefold()
                    != title_filter.casefold()
                ):
                    continue
    
                safe_title = _sanitize_target_component(highlight.title)
                highlight_dirname = (
                    f"{base_username}_highlight_{safe_title}_{highlight.unique_id}"
                )
                download_dir = target_root / highlight_dirname
                before = _snapshot_files(download_dir)
    
                num_items = 0
                num_downloaded = 0
                for item in highlight.get_items():
                    num_items += 1
                    if loader.download_storyitem(item, target=highlight_dirname):
                        num_downloaded += 1
    
                after = _snapshot_files(download_dir)
                downloaded_files = (after - before) or after
                results.append(
                    {
                        "title": highlight.title,
                        "unique_id": highlight.unique_id,
                        "download_dir": str(download_dir),
                        "num_items": num_items,
                        "num_downloaded": num_downloaded,
                        "image_files": _collect_paths_by_suffixes(
                            downloaded_files,
                            {".jpg", ".jpeg", ".png", ".webp"},
                        ),
                        "video_files": _collect_paths_by_suffixes(
                            downloaded_files,
                            {".mp4"},
                        ),
                    }
                )
    
            if title_filter and not results:
                raise ValueError(
                    "No highlights matched the given highlight_title."
                )
    
            return {
                "success": True,
                "username_target": target_username,
                "highlight_title": title_filter,
                "highlights": results,
            }
        except instaloader.exceptions.InstaloaderException as exc:
            return {
                "success": False,
                "error": f"Instaloader error: {exc.__class__.__name__}: {exc}",
            }
        except Exception as exc:
            return {"success": False, "error": str(exc)}
  • Registers the 'download_instagram_highlights' tool with the FastMCP server instance using the @mcp.tool() decorator.
    @mcp.tool()
  • Helper function to resolve the download root directory, defaulting to ~/Downloads/instagram if not provided.
    def _resolve_download_root(download_root: str | None) -> Path:
        if download_root is None:
            return DEFAULT_DOWNLOAD_ROOT
        cleaned = download_root.strip()
        if not cleaned:
            return DEFAULT_DOWNLOAD_ROOT
        return Path(cleaned).expanduser()
  • Helper to create and configure an Instaloader instance for downloading.
    def _build_instaloader(
        download_root: Path,
        download_pictures: bool = False,
        download_videos: bool = True,
        save_metadata: bool = False,
        save_caption: bool = False,
    ) -> instaloader.Instaloader:
        dirname_pattern = str(download_root / "{target}")
        post_metadata_txt_pattern = "{caption}" if save_caption else ""
        return instaloader.Instaloader(
            quiet=True,
            dirname_pattern=dirname_pattern,
            download_pictures=download_pictures,
            download_videos=download_videos,
            download_video_thumbnails=False,
            download_geotags=False,
            download_comments=False,
            save_metadata=save_metadata,
            compress_json=False,
            post_metadata_txt_pattern=post_metadata_txt_pattern,
        )
  • Helper to normalize credential strings, stripping whitespace.
    def _normalize_credential(value: str | None) -> str | None:
        if value is None:
            return None
        stripped = value.strip()
        return stripped if stripped else None
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. It mentions authentication requirements ('requires login'), which is helpful, but doesn't disclose other behavioral traits such as rate limits, potential for account blocking, file formats downloaded, or error handling. For a tool that likely involves web scraping and authentication, this is a significant gap.

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 a clear purpose statement, a note, and sections for Args and Returns. It's appropriately sized, though the parameter explanations are very brief. Every sentence serves a purpose, with no redundant information.

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

Completeness3/5

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

Given 5 parameters with 0% schema coverage and no annotations, the description is incomplete. It covers authentication needs and lists parameters but lacks details on behavior, constraints, and error cases. The presence of an output schema helps by documenting return values, but overall, it's only minimally adequate for a tool with this complexity.

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?

Schema description coverage is 0%, so the description must compensate. It lists parameters with brief explanations (e.g., 'Target Instagram username'), but these add minimal semantic value beyond what the parameter names imply. It doesn't explain format constraints (e.g., valid usernames), the effect of optional filters, or how authentication works with null defaults.

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 tool's purpose: 'Download Instagram highlights for a target user.' It specifies the verb (download) and resource (Instagram highlights), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools like download_instagram_stories, which serves a similar purpose but for different content types.

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?

The description provides some usage context with 'Note: This feature requires login,' indicating authentication is needed. It doesn't explicitly state when to use this tool versus alternatives like download_instagram_stories or download_instagram_post, leaving the agent to infer based on content type (highlights vs. stories vs. posts).

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/KaiQin04/ig-download-mcp'

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