Skip to content
Conduit

skill

instagram-lyr

Instagram MCP server using direct httpx API (no browser)

ishan-parihar/instagram-lyrcommunitylistedunreviewed

Set up

Skills are installed by placing their folder where your agent loads skills.

The download comes from github.com/ishan-parihar/instagram-lyr itself, not from our server, so what you get is exactly what its author published.

Install instructions come from the README

Skills do not use an MCP config. Follow the steps in the README below.

README

synced Oct 26, 2026

Instagram HTTPX MCP Server

  • Page index — every active doc and the question it owns.

Model Context Protocol server that lets AI assistants interact with Instagram through intelligent automation.

Access profiles, posts, reels, Business/Creator insights, direct messages, and full-scope content creation with smart aspect ratio processing, modern Instagram specifications, multi-account management, and agent-optimized CLI interface.

Quick Install

One-line installation:

curl -fsSL https://raw.githubusercontent.com/ishan-parihar/instagram-lyr/main/install.sh | bash

What It Does

  • Smart Content Processing: Automatic aspect ratio detection and conversion (4:5, 1:1, 1.91:1, 9:16) with letterbox/crop modes
  • Modern Instagram Specs: Extended video durations (180s feed/reels, 60s stories) and latest format support
  • Multi-Account Management: Switch between multiple Instagram accounts with posting limits and cooldowns
  • Comment-Based DM Automation: Trigger system for automated responses to post comments
  • Feed Browsing: Home feed, discover feed, and user timeline access
  • Full Content Creation: Photos, videos, carousels, stories, and reels with location/tagging
  • Agent-Optimized CLI: AXI-compliant interface with TOON output and session integrations
  • Production Ready: Systemd persistence, error handling, and comprehensive validation

Quick Start

1. Install

curl -fsSL https://raw.githubusercontent.com/ishan-parihar/instagram-lyr/main/install.sh | bash

2. Configure your MCP client

Add to your client's MCP config:

{
  "mcpServers": {
    "instagram": {
      "command": "uvx",
      "args": ["instagram-lyr"]
    }
  }
}

3. First tool call

Restart your MCP client. On the first Instagram tool call, a login window opens if no session exists. Log in once, and cookies persist across restarts.

Smart Processing

The server automatically handles Instagram's complex media specifications:

  • Auto Aspect Ratio Detection: Converts any media to the closest valid Instagram ratio
  • Media-Type-Aware Processing: Uses letterbox for stories/reels (preserves content), crop for feed (clean aesthetic)
  • Extended Duration Support: 180s for feed/reels, 60s for stories (vs old 60s/15s limits)
  • Landscape Format Support: 1.91:1 cinematic format for feed posts
  • Flexible Processing Modes: Auto, fit (letterbox), and crop (center crop) options

Example:

# Auto-detect best ratio and processing mode
result = await upload_photo(
    image_path="photo.jpg",
    caption="Smart processed",
    aspect_ratio="auto",  # Auto-detect closest valid ratio
    fit_mode="auto",  # Auto-select best processing mode
)

AI Agent Setup

AI coding agents in headless environments can authenticate by providing Instagram session cookies directly.

Option A: Set INSTAGRAM_COOKIES environment variable (recommended)

{
  "sessionid": "your_session_id_value",
  "csrftoken": "your_csrf_token_value"
}

Linux/macOS:

export INSTAGRAM_COOKIES='{"sessionid":"your_session_id_value","csrftoken":"your_csrf_token_value"}'
uvx instagram-lyr

Windows (PowerShell):

$env:INSTAGRAM_COOKIES='{"sessionid":"your_session_id_value","csrftoken":"your_csrf_token_value"}'
uvx instagram-lyr

Option B: Pass cookies via file

uvx instagram-lyr --cookies-file /path/to/cookies.json

How to get cookies

  1. Open Instagram in a browser and log in
  2. Use browser DevTools (F12 → Application → Cookies → instagram.com)
  3. Export cookies as JSON (required: sessionid, csrftoken)
  4. Pass to server via env var or file

Note: Instagram session cookies expire periodically. Refresh cookies when tools return session expired errors.

CLI Interface (AXI-Compliant)

The CLI provides agent-optimized interaction with TOON output and session integrations:

# Show home view with live state
instagram-lyr

# List available tools
instagram-lyr --list-tools

# Tool details
instagram-lyr --tool-info ias_get_user_profile

# Session management
instagram-lyr --login
instagram-lyr --status
instagram-lyr --logout

# Agent integrations
instagram-lyr --install-hook    # Session hooks for Claude Code/Codex
instagram-lyr --install-skill   # Agent skill for auto-discovery

Session Integration:

$ instagram-lyr --install-hook
status: success
target: claude_code
hook: SessionStart -> ~/instagram-lyr/instagram_mcp_server/__main__.py
help: Session will now show Instagram MCP state on startup

How It Works

The server uses a hybrid approach:

  • Scraping: Fast httpx-based web scraping for reading content via Instagram's internal API
  • Posting: instagrapi library for robust media uploads via Instagram's private API
  • Smart Processing: Automatic aspect ratio detection and media optimization
  • Multi-Account: Centralized account management with separate sessions and posting limits
  • Validation: Comprehensive input validation and Instagram spec compliance
  • Error Handling: Instagram-specific error detection and user-friendly messages

MCP Client Configuration

Claude Desktop

{
  "mcpServers": {
    "instagram": {
      "command": "uvx",
      "args": ["instagram-lyr"]
    }
  }
}

Cursor

{
  "mcpServers": {
    "instagram": {
      "command": "uvx",
      "args": ["instagram-lyr"]
    }
  }
}

Windsurf

{
  "mcpServers": {
    "instagram": {
      "command": "uvx",
      "args": ["instagram-lyr"]
    }
  }
}

Generic MCP Client

{
  "mcpServers": {
    "instagram": {
      "command": "uv",
      "args": ["run", "-m", "instagram_mcp_server"]
    }
  }
}

Tools

Multi-Account Management

ToolDescription
list_instagram_accountsList all configured Instagram accounts
add_instagram_accountAdd a new Instagram account with session cookies
import_account_from_browserImport Instagram account cookies directly from browser
switch_active_accountSwitch the active Instagram account for operations
get_active_account_infoGet information about the currently active account
remove_instagram_accountRemove an Instagram account configuration
update_account_cookiesUpdate cookies for an existing Instagram account

Feed Browsing

ToolDescription
get_home_feedGet the home feed (posts from followed accounts)
get_discover_feedGet the discover/explore feed with trending content
get_user_timelineGet recent posts from a specific user's timeline

Comment-Based DM Automation

ToolDescription
create_dm_triggerCreate an automated DM trigger for post comments
list_dm_triggersList DM triggers with optional filtering
get_dm_triggerGet details of a specific DM trigger
update_dm_triggerUpdate an existing DM trigger
pause_dm_triggerPause a DM trigger (temporarily disable)
resume_dm_triggerResume a paused DM trigger
delete_dm_triggerDelete a DM trigger
check_comment_for_triggersCheck if a comment matches any active triggers
execute_trigger_dmExecute the DM action for a matched trigger
get_trigger_executions_logGet execution history for a specific trigger

Content Posting (Smart Processing)

ToolDescription
upload_photoUpload photo with smart aspect ratio processing (4:5, 1:1, 1.91:1)
upload_videoUpload video with smart processing (180s duration, auto aspect ratio)
upload_carouselUpload carousel (2-10 images) with consistent smart processing
upload_storyUpload story with letterbox processing (60s duration, 9:16 format)
upload_reelUpload reel with smart vertical processing (180s duration, 9:16 format)

Smart Processing Parameters:

  • aspect_ratio: "auto", "4:5", "1:1", "1.91:1" (feed), "9:16" (stories/reels)
  • fit_mode: "auto" (media-type-aware), "fit" (letterbox), "crop" (center crop)
  • max_duration: Custom duration limits (up to 180s feed/reels, 60s stories)

Profile & Content

ToolDescription
get_user_profileGet profile info with optional sections (posts, reels, stories, highlights, followers, following)
get_user_postsGet structured post data (ID, shortcode, URL, thumbnail, media type, caption, engagement)
get_user_reelsGet reels with engagement metrics (plays, likes, comments) and audio metadata
get_user_storiesGet active stories with media URLs, viewer counts, and expiry timestamps
get_user_highlightsGet story highlights with titles, cover URLs, and highlight IDs
get_post_detailsGet detailed post/reel info including caption, engagement, audio, location, and carousel children

Search & Discovery

ToolDescription
search_usersSearch for users by name or keywords
search_hashtagsSearch for hashtags by keywords
search_locationsSearch for Instagram locations
get_hashtag_postsGet posts for a given hashtag
get_location_postsGet posts tagged at a specific location

Messaging & Actions

ToolDescription
get_direct_inboxList recent DM conversations
get_dm_conversationRead a specific DM conversation
send_dmSend a direct message to a user
follow_userFollow a user (sends follow request for private accounts)
unfollow_userUnfollow a user
like_postLike a post or reel
unlike_postUnlike a post or reel
save_postSave a post or reel to a collection
comment_on_postPost a comment on a post or reel

Business/Creator Insights

ToolDescription
get_account_insightsGet account-level insights (impressions, reach, engagement, growth)
get_content_insightsGet insights for specific posts/reels (impressions, reach, engagement)
get_stories_insightsGet insights for stories (impressions, reach, navigation)
get_audience_insightsGet audience demographics (age, gender, location, activity)

Utility Tools

ToolDescription
close_sessionClose the current Instagram browser session and clean up resources

Content Posting Features

Smart Aspect Ratio Processing

  • Auto Detection: Automatically finds closest valid Instagram ratio for any input
  • Media-Type-Aware: Stories/reels use letterbox (preserve content), feed uses crop (clean aesthetic)
  • Flexible Modes: Auto, fit (letterbox/pillarbox), crop (center crop) options
  • Instagram Ratios: 4:5 (feed standard), 1:1 (square), 1.91:1 (landscape), 9:16 (stories/reels)

Extended Video Support

  • Feed/Reels: Up to 180 seconds (vs old 60s limit)
  • Stories: Up to 60 seconds (vs old 15s limit)
  • Auto Processing: Smart aspect ratio conversion and thumbnail generation
  • Quality Preservation: Optimized compression while maintaining quality

Advanced Posting Features

  • Multi-Account Support: Specify account_id to post from any configured account
  • Location Tagging: Add Instagram location IDs to posts
  • User Tagging: Tag users in posts and stories
  • Cross-Posting: Share to Facebook and Threads automatically
  • Scheduling: Schedule posts for future times (ISO 8601 timestamps)
  • Posting Limits: Built-in daily limits and cooldowns to prevent account restrictions
  • History Tracking: All posting attempts logged for audit and analysis

Posting Limitations

  • All posting operations require valid Instagram session cookies
  • Daily posting limits enforced (default: 10 posts per account per day)
  • 30-minute cooldown between posts to prevent rate limiting
  • Media files automatically processed to meet Instagram specifications
  • Stories have stricter duration limits (60s vs 180s for feed videos)

Known Issues

  • Two separate cookie stores. Posting + DMs use a multi-account store (~/.instagram-lyr/accounts/<name>/cookies.json); follow/like/comment tools gate on a legacy default profile (~/.instagram-lyr/profile/). On installs without the legacy profile dir present, posting works but every follow/like/comment tool reports "session expired" even with valid cookies — a deployment gap, not a poisoned session.
  • Rate limiting: Instagram rate-limits test accounts (PhotoNotUpload, DM throttling); the tool surfaces this cleanly rather than crashing.
  • Runs the browser-based scraping extractor (chromedriver, separate auth from the posting client) for profile/feed reads.

Authentication

ScenarioWhat happens
First runCookie extraction window opens. Complete sign-in (including 2FA if needed). Session saved.
Subsequent runsCookies loaded from ~/.instagram-mcp/profile/ automatically.
Session expiredRe-run uvx instagram-lyr --login to re-authenticate.
Clear sessionRun uvx instagram-lyr --logout to remove stored cookies.

Instagram may request login confirmation on your mobile app for new sessions. If you encounter a captcha, use --login to solve it manually in the opened browser.

Development

# Install dependencies
uv sync

# Run linting
uv run ruff check .
uv run ruff format .

# Type checking
uv run ty check

# Run tests
uv run pytest

# Run server locally
uv run -m instagram_mcp_server --no-headless

# Install browser for cookie extraction
uv run patchright install chromium

Architecture

The server uses a hybrid approach:

  • Scraping: Fast httpx-based web scraping for reading content
  • Posting: instagrapi library for robust media uploads via Instagram's private API
  • Smart Processing: Automatic aspect ratio detection and media optimization
  • Multi-Account: Centralized account management with separate sessions
  • Validation: Comprehensive input validation and media processing
  • Error Handling: Instagram-specific error detection and user-friendly messages
  • AXI Compliance: Agent-optimized CLI with TOON output and session integrations

Production Readiness

This server is production-ready for:

  • Multi-account AI agent workflows
  • Automated content scheduling and posting
  • Comment-based DM automation
  • Feed analysis and trend detection
  • Business/Creator insight collection
  • Systemd persistence and deployment

For systemd persistence and production deployment, see the production documentation in the docs/ directory.

Related CLI Tools

This project is part of a family of agent-friendly CLI tools for social platforms:

ToolCLIRepo
Instagraminstagram-lyrishan-parihar/instagram-lyr
Redditreddit-lyrishan-parihar/reddit-lyr
LinkedInlinkedin-lyrishan-parihar/linkedin-lyr
Twitter/Xtwitter-lyrishan-parihar/twitter-lyr
Discorddiscordishan-parihar/discord-cli
Telegramtgishan-parihar/tg-cli

License

MIT


☕ Support & Sponsorship

If you find this project useful, consider supporting ongoing development:

Sponsor Donate

Your support funds new features, releases, and infrastructure for the whole ecosystem.

↑↓ navigate openesc close