Enables listing and managing Facebook pages connected to Instagram accounts, facilitating account configuration and authentication through the Graph API.
Provides tools for programmatically managing Instagram Business accounts, including media publishing, engagement analytics, profile management, and direct messaging.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Instagram MCP ServerShow me the engagement metrics for my last 5 posts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.

Instagram MCP Server
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
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):
Step 7: Set Up Environment Variables
Create a .env file in your project root:
Step 8: Test Your Setup
Run the validation script to test your credentials:
Or test manually:
šØ 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:
š 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:
Install dependencies:
Set up environment variables:
Configure the MCP server:
Configuration
Environment Variables (.env)
MCP Client Configuration
Add this to your MCP client configuration (e.g., Claude Desktop):
Usage Examples
Using with Claude Desktop
Get Profile Information:
Analyze Recent Posts:
Publish Content:
Using with Python MCP Client
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
Running Tests
Contributing
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:
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