Instagram MCP Server
A professional MCP server for managing and posting Instagram content, including PDF-to-image conversion, carousel batches, auto-posting, and Cloudinary hosting.
README
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 config
Installation
# 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=false
Running 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-mcp
CLI 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.py
Testing
pip install -e ".[dev]"
pytest
MCP Tools
| Tool | Purpose |
|---|---|
list_content |
List local images in content dir |
get_content |
Get file metadata (mime, size) |
manage_content |
list / delete / archive content |
manage_metadata |
Update / view / clear captions & hashtags |
test_instagram_connection |
Test Graph API connection |
debug_instagram_token |
Debug token expiry + scopes |
post_to_instagram |
Post single image (direct upload) |
test_cloudinary_upload |
Upload to Cloudinary, verify URL |
cleanup_cloudinary_asset |
Delete a Cloudinary asset |
publish_image |
Publish via Cloudinary HTTPS URL |
convert_pdf_to_images |
PDF ā PNG images |
create_carousel_batch |
Group images into carousels |
post_carousel_to_instagram |
Post a carousel + auto-cleanup |
list_carousel_batches |
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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.