Instagram Mcp

io.github.mcpware由 GitHub 账号 mcpware 发布v1.0.4更新于 Oct 27, 2026

Instagram MCP — 23 tools for Instagram Graph API: posts, DMs, stories, reels, analytics.

概览

AI 生成的概览

本地运行的 MCP 服务器,提供 23 个 Instagram Graph API 工具,让助手读取主页、帖子、评论和私信数据,并发布帖子、Reels 和轮播内容。

可以做什么
  • 读取主页与账号数据:主页信息、关联的 Facebook 主页、账号洞察、令牌有效性校验
  • 获取媒体与数据分析:近期帖子、单帖洞察、快拍、被提及内容、话题标签搜索与标签媒体、其他商业账号查询
  • 发布内容:单图或视频、轮播、Reel,并查询每日发布配额
  • 管理评论:列出、发表、回复、删除、隐藏或取消隐藏评论
  • 处理私信:列出会话、读取消息、发送私信(需 Meta 高级访问权限)
适用场景
适合管理 Instagram 商业或创作者账号、希望助手在聊天客户端内起草并发布内容、查看互动数据、管理评论或回复私信的场景。
运行要求
以本地进程方式运行(npm 包,stdio)。需要一个已关联 Facebook 主页的 Instagram 商业或创作者账号、一个具备所列 Instagram 与 Pages 权限的 Facebook 开发者应用,以及环境变量 INSTAGRAM_ACCESS_TOKEN 和 INSTAGRAM_ACCOUNT_ID;INSTAGRAM_API_VERSION 可选。需要访问 Graph API 的网络连接。
安装前请注意
该访问令牌赋予在真实账号上发布内容、删除评论和发送私信的权限,应把 INSTAGRAM_ACCESS_TOKEN 视为高价值密钥,并在 60 天过期前轮换。相关工具会发布帖子、发送私信、发表或删除评论、隐藏评论,会改变公开内容。私信工具需通过 Meta 应用审核。账号数据会发送至 Meta 的 Graph API。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Instagram Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[Verified on MseeP]

[MSeeP.ai Security Assessment Badge]

@mcpware/instagram-mcp

[npm version] [npm downloads] [license] [GitHub stars] [GitHub forks]

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

  1. Instagram Business Account: Must be connected to a Facebook Page
  2. Facebook Developer Account: Required for API access
  3. Access Token: Long-lived access token with appropriate permissions
  4. Python 3.10+: For running the MCP server (required by MCP dependencies)

Required Instagram API Permissions

Standard Access (available immediately):

  • instagram_basic
  • instagram_content_publish
  • instagram_manage_insights
  • instagram_manage_comments
  • pages_show_list
  • pages_read_engagement
  • pages_manage_metadata
  • pages_read_user_content
  • business_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

  1. Convert to Business Account (if not already):

    • Open Instagram app → Settings → Account → Switch to Professional Account
    • Choose "Business" → Select a category → Complete setup
  2. 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

  1. Go to Facebook Developers:

  2. 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"
  3. Add Instagram Basic Display Product:

    • In your app dashboard, click "Add Product"
    • Find "Instagram Basic Display" → Click "Set Up"
  4. 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

  1. 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

  1. Add Instagram Graph API Product:

    • In your app dashboard, click "Add Product"
    • Find "Instagram Graph API" → Click "Set Up"
  2. Configure Permissions:

    • Go to Instagram Graph API → Permissions
    • Request the following permissions:
      • instagram_basic
      • instagram_content_publish
      • instagram_manage_insights
      • pages_show_list
      • pages_read_engagement

Step 5: Generate Access Token

Option A: Using Facebook Graph API Explorer (Recommended for Testing)
  1. Go to Graph API Explorer:

  2. Configure Explorer:

    • Select your app from the dropdown
    • Click "Generate Access Token"
    • Select required permissions when prompted
  3. Get Page Access Token:

    • In the explorer, make a GET request to: /me/accounts
    • Find your Facebook Page in the response
    • Copy the access_token for your page
  4. Get Instagram Business Account ID:

    • Use the page access token to make a GET request to: /{page-id}?fields=instagram_business_account
    • Copy the Instagram Business Account ID from the response
Option B: Using Facebook Login Flow (Recommended for Production)
  1. Set Up Facebook Login:

    • In your app dashboard, add "Facebook Login" product
    • Configure Valid OAuth Redirect URIs
  2. Implement OAuth Flow:

    python
    # Example OAuth URLoauth_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"
  3. Exchange Code for Token:

    python
    # Exchange authorization code for access tokentoken_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):

bash
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:

env
# Facebook App CredentialsFACEBOOK_APP_ID=your_app_id_hereFACEBOOK_APP_SECRET=your_app_secret_here
# Instagram Access Token (long-lived)INSTAGRAM_ACCESS_TOKEN=your_long_lived_access_token_here
# Instagram Business Account IDINSTAGRAM_BUSINESS_ACCOUNT_ID=your_instagram_business_account_id_here
# Optional: API ConfigurationINSTAGRAM_API_VERSION=v19.0RATE_LIMIT_REQUESTS_PER_HOUR=200CACHE_ENABLED=trueLOG_LEVEL=INFO

Step 8: Test Your Setup

Run the validation script to test your credentials:

bash
python scripts/setup.py

Or test manually:

python
import osimport requests
# Test access tokenaccess_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

  1. Never commit credentials to version control
  2. Use environment variables or secure secret management
  3. Regularly rotate access tokens
  4. Monitor token expiration dates
  5. Use HTTPS only in production
  6. Implement proper error handling for expired tokens

🔄 Token Refresh Strategy

Long-lived tokens expire after 60 days. Implement automatic refresh:

python
# Check token validitydef 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 expirationdef 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

  1. Clone the repository:
bash
git clone <repository-url>cd ig-mcp
  1. Install dependencies:
bash
pip install -r requirements.txt
  1. Set up environment variables:
bash
cp .env.example .env# Edit .env with your Instagram API credentials
  1. Configure the MCP server:
bash
# Edit config.json with your specific settings

Configuration

Environment Variables (.env)

env
INSTAGRAM_ACCESS_TOKEN=your_long_lived_access_tokenFACEBOOK_APP_ID=your_facebook_app_idFACEBOOK_APP_SECRET=your_facebook_app_secretINSTAGRAM_BUSINESS_ACCOUNT_ID=your_instagram_business_account_id

MCP Client Configuration

Add this to your MCP client configuration (e.g., Claude Desktop):

json
{  "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

  1. Get Profile Information:
Can you get my Instagram profile information?
  1. Analyze Recent Posts:
Show me my last 5 Instagram posts and their engagement metrics
  1. Publish Content:
Upload this image to my Instagram account with the caption "Beautiful sunset! #photography #nature"

Using with Python MCP Client

python
from mcp import ClientSession, StdioServerParametersfrom mcp.client.stdio import stdio_client
# Connect to the Instagram MCP serverserver_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

  1. Cache frequently accessed data
  2. Use batch requests when possible
  3. Implement exponential backoff for retries
  4. 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

  1. Token Security: Store access tokens securely
  2. Environment Variables: Never commit tokens to version control
  3. HTTPS Only: All API calls use HTTPS
  4. Token Refresh: Implement automatic token refresh
  5. 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 file

Running Tests

bash
# Run all testspython -m pytest tests/
# Run with coveragepython -m pytest tests/ --cov=src/
# Run specific test filepython -m pytest tests/test_instagram_client.py

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Troubleshooting

Common Issues

  1. "Invalid Access Token"

    • Verify token is not expired
    • Check token permissions
    • Regenerate long-lived token
  2. "Rate Limit Exceeded"

    • Wait for rate limit reset
    • Implement request queuing
    • Use batch requests
  3. "Permission Denied"

    • Verify Instagram Business account setup
    • Check Facebook page connection
    • Review API permissions

Debug Mode

Enable debug logging by setting:

env
LOG_LEVEL=DEBUG

Troubleshooting

ProblemCauseFix
me/accounts returns empty []IG not connected to a Facebook Page, or you're not Page adminDo Step 1
Graph API Explorer says "No configuration available"Permissions not added to appDo Step 3
"Generate Access Token" is disabledNeed to select "Get User Access Token" firstClick "Get Token" dropdown
App name rejected (contains "IG", "Insta", etc.)Meta blocks trademarked wordsUse a generic name
Token expiredShort-lived tokens last 1 hourDo Step 6 for 60-day token
(#10) To use Instagram Graph API...IG account is Personal, not BusinessSwitch to Business/Creator in IG settings

Environment Variables

VariableRequiredDefaultDescription
INSTAGRAM_ACCESS_TOKENYes—Meta long-lived access token
INSTAGRAM_ACCOUNT_IDYes—Instagram business account ID
INSTAGRAM_API_VERSIONNov19.0Graph API version

Tools (23)

Profile & Account

ToolDescription
get_profile_infoGet profile info (bio, followers, media count)
get_account_pagesList connected Facebook pages
get_account_insightsAccount-level analytics (reach, profile views)
validate_access_tokenCheck if token is valid

Media & Publishing

ToolDescription
get_media_postsGet recent posts with engagement metrics
get_media_insightsDetailed analytics for a specific post
publish_mediaPublish image or video
publish_carouselPublish carousel (2-10 images/videos)
publish_reelPublish a Reel
get_content_publishing_limitCheck daily publishing quota

Comments

ToolDescription
get_commentsGet comments on a post
post_commentPost a comment
reply_to_commentReply to a comment
delete_commentDelete a comment
hide_commentHide/unhide a comment

Direct Messages

ToolDescription
get_conversationsList DM conversations
get_conversation_messagesRead messages in a conversation
send_dmSend a direct message

Discovery & Content

ToolDescription
search_hashtagSearch for a hashtag ID
get_hashtag_mediaGet top/recent media for a hashtag
get_storiesGet current active stories
get_mentionsGet posts you're tagged in
business_discoveryLook 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

ProjectWhat it doesInstall
Claude Code OrganizerVisual dashboard for Claude Code memories, skills, MCP servers, hooksnpx @mcpware/claude-code-organizer
UI AnnotatorHover labels on any web page — AI references elements by namenpx @mcpware/ui-annotator
PagecastRecord browser sessions as GIF or video via MCPnpx @mcpware/pagecast
LogoLoomAI logo design → SVG → full brand kit exportnpx @mcpware/logoloom

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Acknowledgments

来源:README.md,提交 c6b7992

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.4最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分