instagram-mcp
This MCP server enables AI applications to programmatically interact with Instagram Business accounts via the Instagram Graph API, covering content management, analytics, messaging, and discovery.
Profile & Account Management
Retrieve business profile info (bio, followers, media count)
List connected Facebook pages
Get account-level insights (reach, profile views, website clicks)
Validate access tokens and check permissions
Media Publishing
Publish images, videos, carousels (2ā10 items), and Reels with captions and optional location tagging
Check daily publishing limits
Media Retrieval & Insights
Fetch recent posts with engagement metrics
Get detailed post-level analytics (reach, likes, comments, shares, saves, video views)
Comment Management
Get, post, reply to, delete, and hide/unhide comments on posts
Direct Messaging (requires Advanced Access approval from Meta)
List DM conversations, read messages, and send direct messages (within 24-hour reply window)
Discovery & Content
Search for hashtags and retrieve top/recent associated media
View current active Stories
Find posts where your account is mentioned or tagged
Look up other public Business/Creator account profiles
Prerequisites: An Instagram Business account linked to a Facebook Page, a Facebook Developer App, and a long-lived access token with appropriate permissions.
Allows listing and managing Facebook Pages that are connected to Instagram accounts, which is a prerequisite for utilizing the Instagram Graph API.
Provides a comprehensive set of 23 tools for managing Instagram Business and Creator accounts, including publishing media (posts, reels, carousels), managing comments and direct messages, tracking engagement analytics, and performing hashtag discovery.
Interfaces with Meta's Graph API and developer platform to manage access tokens, account permissions, and business insights for Instagram-connected applications.

@mcpware/instagram-mcp
A Model Context Protocol (MCP) server that provides seamless integration with Instagram's Graph API, enabling AI applications to interact with Instagram Business accounts programmatically.
Features
š§ Tools (Model-controlled)
Get Profile Info: Retrieve Instagram business profile details
Get Media Posts: Fetch recent posts from an Instagram account
Get Media Insights: Retrieve engagement metrics for specific posts
Publish Media: Upload and publish images/videos to Instagram
Get Account Pages: List Facebook pages connected to the account
Get Conversations: List Instagram DM conversations (requires Advanced Access)
Get Conversation Messages: Read messages from specific conversations (requires Advanced Access)
Send DM: Reply to Instagram direct messages (requires Advanced Access)
š Resources (Application-controlled)
Profile Data: Access to profile information including follower counts, bio, etc.
Media Feed: Recent posts with engagement metrics
Insights Data: Detailed analytics for posts and account performance
š¬ Prompts (User-controlled)
Analyze Engagement: Pre-built prompt for analyzing post performance
Content Strategy: Template for generating content recommendations
Hashtag Analysis: Prompt for hashtag performance evaluation
Related MCP server: instagram-mcp
Prerequisites
Instagram Business Account: Must be connected to a Facebook Page
Facebook Developer Account: Required for API access
Access Token: Long-lived access token with appropriate permissions
Python 3.10+: For running the MCP server (required by MCP dependencies)
Required Instagram API Permissions
Standard Access (available immediately):
instagram_basicinstagram_content_publishinstagram_manage_insightsinstagram_manage_commentspages_show_listpages_read_engagementpages_manage_metadatapages_read_user_contentbusiness_management
Advanced Access (requires Meta App Review):
instagram_manage_messages- Required for Direct Messaging features
ā ļø Instagram DM Features: Reading and sending Instagram direct messages requires Advanced Access approval from Meta. See INSTAGRAM_DM_SETUP.md for the App Review process.
š How to Get Instagram API Credentials
š Quick Start: See AUTHENTICATION_GUIDE.md for a 5-minute setup guide!
This section provides a step-by-step guide to obtain the necessary credentials for the Instagram MCP server.
Step 1: Set Up Instagram Business Account
Convert to Business Account (if not already):
Open Instagram app ā Settings ā Account ā Switch to Professional Account
Choose "Business" ā Select a category ā Complete setup
Connect to Facebook Page:
Go to Instagram Settings ā Account ā Linked Accounts ā Facebook
Connect to an existing Facebook Page or create a new one
Important: The Facebook Page must be owned by you
Step 2: Create Facebook App
Go to Facebook Developers:
Visit developers.facebook.com
Log in with your Facebook account
Create New App:
Click "Create App" ā Choose "Business" ā Click "Next"
Fill in app details:
App Name: Choose a descriptive name (e.g., "My Instagram MCP Server")
App Contact Email: Your email address
Click "Create App"
Add Instagram Basic Display Product:
In your app dashboard, click "Add Product"
Find "Instagram Basic Display" ā Click "Set Up"
Configure Instagram Basic Display:
Go to Instagram Basic Display ā Basic Display
Click "Create New App" in the Instagram App section
Accept the terms and create the app
Step 3: Get App Credentials
Get App ID and Secret:
In your Facebook app dashboard, go to Settings ā Basic
Copy your App ID and App Secret
Important: Keep the App Secret secure and never share it publicly
Step 4: Set Up Instagram Business API Access
Add Instagram Graph API Product:
In your app dashboard, click "Add Product"
Find "Instagram Graph API" ā Click "Set Up"
Configure Permissions:
Go to Instagram Graph API ā Permissions
Request the following permissions:
instagram_basicinstagram_content_publishinstagram_manage_insightspages_show_listpages_read_engagement
Step 5: Generate Access Token
Option A: Using Facebook Graph API Explorer (Recommended for Testing)
Go to Graph API Explorer:
Configure Explorer:
Select your app from the dropdown
Click "Generate Access Token"
Select required permissions when prompted
Get Page Access Token:
In the explorer, make a GET request to:
/me/accountsFind your Facebook Page in the response
Copy the
access_tokenfor your page
Get Instagram Business Account ID:
Use the page access token to make a GET request to:
/{page-id}?fields=instagram_business_accountCopy the Instagram Business Account ID from the response
Option B: Using Facebook Login Flow (Recommended for Production)
Set Up Facebook Login:
In your app dashboard, add "Facebook Login" product
Configure Valid OAuth Redirect URIs
Implement OAuth Flow:
# Example OAuth URL oauth_url = f"https://www.facebook.com/v19.0/dialog/oauth?client_id={app_id}&redirect_uri={redirect_uri}&scope=pages_show_list,instagram_basic,instagram_content_publish,instagram_manage_insights"Exchange Code for Token:
# Exchange authorization code for access token token_url = f"https://graph.facebook.com/v19.0/oauth/access_token?client_id={app_id}&redirect_uri={redirect_uri}&client_secret={app_secret}&code={auth_code}"
Step 6: Get Long-Lived Access Token
Short-lived tokens expire in 1 hour. Convert to long-lived token (60 days):
curl -X GET "https://graph.facebook.com/v19.0/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id}&client_secret={app_secret}&fb_exchange_token={short_lived_token}"Step 7: Set Up Environment Variables
Create a .env file in your project root:
# Facebook App Credentials
FACEBOOK_APP_ID=your_app_id_here
FACEBOOK_APP_SECRET=your_app_secret_here
# Instagram Access Token (long-lived)
INSTAGRAM_ACCESS_TOKEN=your_long_lived_access_token_here
# Instagram Business Account ID
INSTAGRAM_BUSINESS_ACCOUNT_ID=your_instagram_business_account_id_here
# Optional: API Configuration
INSTAGRAM_API_VERSION=v19.0
RATE_LIMIT_REQUESTS_PER_HOUR=200
CACHE_ENABLED=true
LOG_LEVEL=INFOStep 8: Test Your Setup
Run the validation script to test your credentials:
python scripts/setup.pyOr test manually:
import os
import requests
# Test access token
access_token = os.getenv('INSTAGRAM_ACCESS_TOKEN')
response = requests.get(f'https://graph.facebook.com/v19.0/me?access_token={access_token}')
print(response.json())šØ Important Security Notes
Never commit credentials to version control
Use environment variables or secure secret management
Regularly rotate access tokens
Monitor token expiration dates
Use HTTPS only in production
Implement proper error handling for expired tokens
š Token Refresh Strategy
Long-lived tokens expire after 60 days. Implement automatic refresh:
# Check token validity
def check_token_validity(access_token):
url = f"https://graph.facebook.com/v19.0/me?access_token={access_token}"
response = requests.get(url)
return response.status_code == 200
# Refresh token before expiration
def refresh_long_lived_token(access_token, app_id, app_secret):
url = f"https://graph.facebook.com/v19.0/oauth/access_token"
params = {
'grant_type': 'fb_exchange_token',
'client_id': app_id,
'client_secret': app_secret,
'fb_exchange_token': access_token
}
response = requests.get(url, params=params)
return response.json().get('access_token')š Troubleshooting Common Issues
Error: "Invalid OAuth access token"
Check if token has expired
Verify token has required permissions
Ensure Instagram account is connected to Facebook Page
Error: "Instagram account not found"
Verify Instagram Business Account ID is correct
Check if Instagram account is properly linked to Facebook Page
Ensure account is a Business account, not Personal
Error: "Insufficient permissions"
Review required permissions in Facebook App
Re-generate access token with correct scopes
Check if app is in Development vs Live mode
Rate Limiting Issues
Implement exponential backoff
Cache responses when possible
Monitor rate limit headers in API responses
Installation
Clone the repository:
git clone <repository-url>
cd ig-mcpInstall dependencies:
pip install -r requirements.txtSet up environment variables:
cp .env.example .env
# Edit .env with your Instagram API credentialsConfigure the MCP server:
# Edit config.json with your specific settingsConfiguration
Environment Variables (.env)
INSTAGRAM_ACCESS_TOKEN=your_long_lived_access_token
FACEBOOK_APP_ID=your_facebook_app_id
FACEBOOK_APP_SECRET=your_facebook_app_secret
INSTAGRAM_BUSINESS_ACCOUNT_ID=your_instagram_business_account_idMCP Client Configuration
Add this to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"instagram": {
"command": "python",
"args": ["/path/to/ig-mcp/src/instagram_mcp_server.py"],
"env": {
"INSTAGRAM_ACCESS_TOKEN": "your_access_token"
}
}
}
}Usage Examples
Using with Claude Desktop
Get Profile Information:
Can you get my Instagram profile information?Analyze Recent Posts:
Show me my last 5 Instagram posts and their engagement metricsPublish Content:
Upload this image to my Instagram account with the caption "Beautiful sunset! #photography #nature"Using with Python MCP Client
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
# Connect to the Instagram MCP server
server_params = StdioServerParameters(
command="python",
args=["src/instagram_mcp_server.py"]
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# Get profile information
result = await session.call_tool("get_profile_info", {})
print(result)API Endpoints Covered
Profile Management
Get business profile information
Update profile details (future feature)
Media Management
Retrieve recent posts
Get specific media details
Upload and publish new content
Delete media (future feature)
Analytics & Insights
Post engagement metrics (likes, comments, shares)
Account insights (reach, impressions)
Hashtag performance analysis
Account Management
List connected Facebook pages
Switch between business accounts
Rate Limiting & Best Practices
The server implements intelligent rate limiting to comply with Instagram's API limits:
Profile requests: 200 calls per hour
Media requests: 200 calls per hour
Publishing: 25 posts per day
Insights: 200 calls per hour
Best Practices
Cache frequently accessed data
Use batch requests when possible
Implement exponential backoff for retries
Monitor rate limit headers
Error Handling
The server provides comprehensive error handling for common scenarios:
Authentication errors: Invalid or expired tokens
Permission errors: Missing required permissions
Rate limiting: Automatic retry with backoff
Network errors: Connection timeouts and retries
API errors: Instagram-specific error responses
Security Considerations
Token Security: Store access tokens securely
Environment Variables: Never commit tokens to version control
HTTPS Only: All API calls use HTTPS
Token Refresh: Implement automatic token refresh
Audit Logging: Log all API interactions
Development
Project Structure
ig-mcp/
āāā src/
ā āāā instagram_mcp_server.py # Main MCP server
ā āāā instagram_client.py # Instagram API client
ā āāā models/ # Data models
ā āāā tools/ # MCP tools implementation
ā āāā resources/ # MCP resources implementation
ā āāā prompts/ # MCP prompts implementation
āāā tests/ # Unit and integration tests
āāā config/ # Configuration files
āāā requirements.txt # Python dependencies
āāā .env.example # Environment variables template
āāā README.md # This fileRunning Tests
# Run all tests
python -m pytest tests/
# Run with coverage
python -m pytest tests/ --cov=src/
# Run specific test file
python -m pytest tests/test_instagram_client.pyContributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Troubleshooting
Common Issues
"Invalid Access Token"
Verify token is not expired
Check token permissions
Regenerate long-lived token
"Rate Limit Exceeded"
Wait for rate limit reset
Implement request queuing
Use batch requests
"Permission Denied"
Verify Instagram Business account setup
Check Facebook page connection
Review API permissions
Debug Mode
Enable debug logging by setting:
LOG_LEVEL=DEBUGTroubleshooting
Problem | Cause | Fix |
| IG not connected to a Facebook Page, or you're not Page admin | Do Step 1 |
Graph API Explorer says "No configuration available" | Permissions not added to app | Do Step 3 |
"Generate Access Token" is disabled | Need to select "Get User Access Token" first | Click "Get Token" dropdown |
App name rejected (contains "IG", "Insta", etc.) | Meta blocks trademarked words | Use a generic name |
Token expired | Short-lived tokens last 1 hour | Do Step 6 for 60-day token |
| IG account is Personal, not Business | Switch to Business/Creator in IG settings |
Environment Variables
Variable | Required | Default | Description |
| Yes | ā | Meta long-lived access token |
| Yes | ā | Instagram business account ID |
| No |
| Graph API version |
Tools (23)
Profile & Account
Tool | Description |
| Get profile info (bio, followers, media count) |
| List connected Facebook pages |
| Account-level analytics (reach, profile views) |
| Check if token is valid |
Media & Publishing
Tool | Description |
| Get recent posts with engagement metrics |
| Detailed analytics for a specific post |
| Publish image or video |
| Publish carousel (2-10 images/videos) |
| Publish a Reel |
| Check daily publishing quota |
Comments
Tool | Description |
| Get comments on a post |
| Post a comment |
| Reply to a comment |
| Delete a comment |
| Hide/unhide a comment |
Direct Messages
Tool | Description |
| List DM conversations |
| Read messages in a conversation |
| Send a direct message |
Discovery & Content
Tool | Description |
| Search for a hashtag ID |
| Get top/recent media for a hashtag |
| Get current active stories |
| Get posts you're tagged in |
| Look up another business account |
Limitations
These are Instagram Graph API limitations, not this tool's:
Business/Creator accounts only ā personal accounts are not supported
Long-lived tokens expire after 60 days ā refresh before expiry
200 API calls per hour rate limit
25 posts per day publishing limit
DMs require Advanced Access ā Meta app review required
Hashtag search: 30 unique hashtags per 7 days
Credits
TypeScript rewrite of jlbadano/ig-mcp (Python).
More from @mcpware
Project | What it does | Install |
Visual dashboard for Claude Code memories, skills, MCP servers, hooks |
| |
Hover labels on any web page ā AI references elements by name |
| |
Record browser sessions as GIF or video via MCP |
| |
AI logo design ā SVG ā full brand kit export |
|
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
š§ Email: support@example.com
š Issues: GitHub Issues
š Documentation: Wiki
Acknowledgments
Model Context Protocol by Anthropic
Instagram Graph API by Meta
FastMCP for rapid MCP development
Available Tools
23 toolsbusiness_discoveryB
Look up another public Business or Creator account's profile. Returns bio, follower count, media count, etc.
Inputs: target_username (required).
delete_commentA
Delete a comment on your Instagram post. Can only delete comments on your own media.
Inputs: comment_id (required).
get_account_insightsC
Get account-level insights and analytics for Instagram business account
Inputs: account_id, metrics, period.
get_account_pagesB
Get Facebook pages connected to the account and their Instagram business accounts
Inputs: no named parameters.
get_commentsB
Get comments on an Instagram post. Returns comment text, username, timestamp, and like count.
Inputs: media_id (required), limit.
get_content_publishing_limitA
Check how many posts you can still publish today. Instagram limits content publishing per 24-hour period.
Inputs: no named parameters.
get_conversation_messagesA
Get messages from a specific Instagram DM conversation. Requires instagram_manage_messages permission.
Inputs: conversation_id (required), limit.
get_conversationsA
Get Instagram DM conversations. Requires instagram_manage_messages permission.
Inputs: page_id, limit.
get_hashtag_mediaA
Get top or recent media for a hashtag. Use search_hashtag first to get the hashtag ID.
Inputs: hashtag_id (required), media_type, limit.
get_media_insightsC
Get detailed insights and analytics for a specific Instagram post
Inputs: media_id (required), metrics.
get_media_postsC
Get recent media posts from Instagram account with engagement metrics
Inputs: account_id, limit, after.
get_mentionsB
Get posts where your account has been tagged or @mentioned. Useful for tracking UGC.
Inputs: limit.
get_profile_infoC
Get Instagram business profile information including followers, bio, and account details
Inputs: account_id.
get_storiesC
Get current active stories on your Instagram account. Stories expire after 24 hours.
Inputs: account_id.
hide_commentA
Hide or unhide a comment on your Instagram post. Hidden comments are not visible to the public.
Inputs: comment_id (required), hide.
post_commentA
Post a top-level comment on an Instagram post. Requires instagram_manage_comments permission.
Inputs: media_id (required), message (required).
publish_carouselB
Publish a carousel (album) post with 2-10 images or videos. All media must be publicly accessible URLs.
Inputs: image_urls (required), caption.
publish_mediaB
Upload and publish an image or video to Instagram with caption and optional location
Inputs: image_url, video_url, caption, location_id.
publish_reelC
Publish a Reel (short-form video) to Instagram. Video must be publicly accessible URL, MP4 format.
Inputs: video_url (required), caption, share_to_feed.
reply_to_commentA
Reply to a specific comment on an Instagram post. Requires instagram_manage_comments permission.
Inputs: comment_id (required), message (required).
search_hashtagA
Search for an Instagram hashtag and get its ID. Use the returned ID with get_hashtag_media.
Inputs: hashtag_name (required).
send_dmA
Send Instagram direct message. Requires instagram_manage_messages with Advanced Access. Can only reply within 24 hours.
Inputs: recipient_id (required), message (required).
validate_access_tokenB
Validate the Instagram API access token and check permissions
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 23 tools
Most tools have distinct purposes, but there is some overlap between get_profile_info and business_discovery (both retrieve profile data) and between get_media_posts and get_hashtag_media (both fetch media). The descriptions help clarify the differences, but an agent might occasionally confuse these pairs.
Tool names follow a highly consistent verb_noun pattern throughout, such as get_comments, delete_comment, publish_media, and search_hashtag. This predictability makes it easy for agents to understand and navigate the toolset.
With 23 tools, the count is borderline high for an Instagram-focused server, potentially feeling heavy. While it covers many features, it might overwhelm agents, suggesting some consolidation could improve usability without losing functionality.
The toolset provides comprehensive coverage for Instagram business and creator workflows, including profile management, content publishing (media, carousel, reel), engagement (comments, DMs), analytics (insights), and hashtag/search operations. No significant gaps are apparent for the domain.
Maintenance
Related MCP Connectors
Instagram MCP for DM and comment automation, AI Agent and content publishing via Meta's official API
Hosted MCP server for DataLikers ā Instagram & TikTok data API. 51 tools: Instagram user search by demographics (gender/age/race/country/city), profiles, bulk lookup, engagement, posts & reels, comments, hashtags, locations, stories, highlights, music, business accounts, top users; TikTok users, videos, comments, hashtags, playlists and top charts. Streamable HTTP, Bearer API key. Free tier: 100 requests on signup at https://datalikers.com/p/1by27bwg
Hosted Instagram MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Public Instagram data via MCP: profiles, posts, reels, ads, transcripts. $5/1k credits; 25 free.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that integrates with Instagram's Graph API to enable AI-driven management of Instagram Business accounts. It provides tools for fetching profile data, publishing media, analyzing engagement metrics, and managing direct messages.209MIT
- AlicenseNot gradedqualityCmaintenanceMCP server providing seamless integration with Instagram's Graph API for business account management, content publishing, and analytics.MIT
- AlicenseBqualityBmaintenanceAn MCP server for the official Instagram Graph API, enabling read, publish, comment, and analytics across Instagram Business/Creator accounts.29134 PyPI21MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for Instagram Graph API providing 25 tools for publishing photos, reels, carousels, and stories, managing comments, viewing insights, and searching hashtags.1MIT