Instagram MCP Server
Instagram MCP Server
A professional, well-structured MCP (Model Context Protocol) server for managing and posting Instagram content ā PDF to images, carousel batches, auto-posting, and Cloudinary hosting.
Features
šø Content management ā list, view, delete, archive local images
āļø Metadata ā captions & hashtags per content item
š± Post to Instagram ā single image or carousel posts via Graph API
š¼ļø PDF ā Images ā convert PDF pages to PNGs (poppler)
š Carousel batches ā group images into 2-10 image carousels
āļø Cloudinary ā temporary image hosting + auto-cleanup
š Token diagnostics ā debug token expiry, scopes, and meta error codes
Project Structure
instagram-mcp/
āāā src/instagram_mcp/ # Main package
ā āāā config.py # Env, constants, paths
ā āāā logging_setup.py # Console + file logging
ā āāā errors.py # Meta error parsing + guidance
ā āāā server.py # FastMCP registration (thin)
ā āāā __main__.py # python -m instagram_mcp
ā āāā services/ # External integrations
ā ā āāā instagram.py # Graph API client
ā ā āāā cloudinary.py # Upload/delete/verify
ā ā āāā pdf.py # PDF ā images
ā āāā storage/ # Local data access
ā ā āāā content.py # File resolution
ā ā āāā metadata.py # JSON load/save
ā āāā tools/ # MCP tool implementations
ā āāā content_tools.py
ā āāā metadata_tools.py
ā āāā instagram_tools.py
ā āāā cloudinary_tools.py
ā āāā carousel_tools.py
āāā scripts/ # CLI utilities
ā āāā check_token.py # Validate token + scopes
ā āāā refresh_token.py # Extend long-lived token
āāā tests/ # pytest suite (mocked HTTP)
āāā content/ # Your media files (unchanged)
āāā archive/ # Archived content
āāā logs/ # Log files
āāā server.py # Backward-compatible entry point
āāā pyproject.toml # Package configInstallation
# Create & activate venv (Windows)
python -m venv .venv
.\.venv\Scripts\Activate.ps1
# Install package (editable)
pip install -e .Configuration
Copy .env.example ā .env and fill in:
# Instagram (required for posting)
INSTAGRAM_ACCESS_TOKEN=your_token_here
INSTAGRAM_BUSINESS_ACCOUNT_ID=your_account_id_here
# Cloudinary (required for publish_image / carousels)
CLOUDINARY_CLOUD_NAME=...
CLOUDINARY_API_KEY=...
CLOUDINARY_API_SECRET=...
# Optional
INSTAGRAM_API_VERSION=v23.0
LOG_LEVEL=INFO
DELETE_LOCAL_AFTER_PUBLISH=falseRunning the Server
# Option 1: Backward-compatible (Claude Desktop config)
python server.py
# Option 2: As a package
python -m instagram_mcp
# Option 3: Console script (after pip install -e .)
instagram-mcpCLI Utilities
# Check your token's validity, expiry, and scopes
python scripts/check_token.py
# Info on refreshing a long-lived token (60 days)
python scripts/refresh_token.pyTesting
pip install -e ".[dev]"
pytestMCP Tools
Tool | Purpose |
| List local images in content dir |
| Get file metadata (mime, size) |
| list / delete / archive content |
| Update / view / clear captions & hashtags |
| Test Graph API connection |
| Debug token expiry + scopes |
| Post single image (direct upload) |
| Upload to Cloudinary, verify URL |
| Delete a Cloudinary asset |
| Publish via Cloudinary HTTPS URL |
| PDF ā PNG images |
| Group images into carousels |
| Post a carousel + auto-cleanup |
| List carousels + status |
Resource
instagram://content/{filename}ā access images as base64 blobs for visual analysis.
Troubleshooting: Daily "API access blocked (code 200)"
Run test_instagram_connection and debug_instagram_token to diagnose.
Common causes & fixes:
App in Development Mode ā switch to Live in Meta Developer dashboard.
Missing approved permissions ā submit App Review for
instagram_basic+instagram_content_publish.Token expired/revoked (60 days) ā generate a fresh long-lived token.
App flagged by Meta ā check the app review status / appeal.
Logs are written to logs/instagram_mcp.log for diagnosis.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/anas7272/Instagram-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server