IG Data analyze with Claude Code (Instagram MCP)

如果你說的是 IG stats / analytics,匯出位置分三種:

  1. 自然流量 / 內容表現
    Meta Business Suite。官方說明把 Facebook 與 Instagram 的 Audience Insights 放在 Meta Business Suite → Insights,而 Business Suite 的 Insights 可從 Export 下拉選單下載報表。(Facebook)

  2. 廣告數據
    Meta Ads Manager / Meta Ads Reporting。Meta 官方說可以把報表匯出成 CSV / Excel / XLSX。(Facebook)

  3. 整個 IG 帳號原始資料
    Instagram App → Profile → Accounts Center → Your information and permissions → Export / Download your information。這類匯出偏向帳號資料備份,包含你可下載的 Instagram 資訊;比較不像乾淨的分析報表。(Instagram Help Center)

最實用的做法:

  • 要分析 內容表現:匯出 Meta Business Suite 的 CSV
  • 要分析 廣告成效:匯出 Ads Manager / Ads Reporting 的 CSV
  • 要分析 留言、貼文、私訊、帳號活動:匯出 Accounts Center 的資料包

丟給 Claude Code 的方式:

mkdir ig-analysis
# 把你下載的 csv / xlsx / json / zip 放進這個資料夾
cd ig-analysis
claude

Anthropic 官方文件寫的是:先在你的專案資料夾啟動 claude,Claude Code 會按需要讀取該目錄中的檔案。(Claude API Docs)

直接下這種指令就夠了:

Analyze all Instagram export files in this folder.
Create:
1. an executive summary
2. top-performing content patterns
3. audience growth and engagement trends
4. posting frequency analysis
5. content recommendations
6. a final report in markdown

你要的是 可分析的數字資料,優先拿 CSV
你要的是 帳號原始紀錄,再拿 Accounts Center 匯出的 ZIP / JSON / HTML
如果你手上只有截圖,Claude 也支援圖片分析,但那比較適合 Claude app / web 的上傳流程,不是最佳的 Claude Code 資料分析路線。(Claude API Docs)

Do it like this:

1. Use this architecture

Instagram API / Graph API → your MCP server → Claude Code

Claude Code can connect to external tools and APIs through MCP. Anthropic supports adding MCP servers by CLI, JSON config, project-level .mcp.json, or remote HTTP MCP servers. (Claude API Docs)

2. Pick the right Instagram API path

There are two official paths:

A. Instagram API with Instagram Login

Use this if you want to access your own Instagram professional account and you do not want to depend on a Facebook Page link. Meta says this path is for Instagram Professionals — Business and Creator accounts, and it does not require the Instagram professional account to be linked to a Facebook Page. (Facebook Developers)

B. Instagram API with Facebook Login

Use this if your workflow already sits inside Meta Business / Facebook Page infrastructure. In this path, Meta says the Instagram professional account must be connected to a Facebook Page. (Facebook Developers)

Important: this is for professional accounts. Meta’s IG User / IG Media docs are for Business or Creator accounts, not normal personal accounts. (Facebook Developers)

3. What data you can expose to Claude Code through MCP

Meta’s official Instagram Platform supports pulling account/media insights and managing comments. The platform docs say it can get and publish media, manage and reply to comments, and access insights for professional accounts. The IG User object includes fields like followers_count and media_count; media insights include metrics such as likes, saves, comments, shares, reach, and views depending on media type. (Facebook Developers)

For analysis, the core MCP tools should be:

  • get_account_profile
  • get_account_insights
  • list_media
  • get_media_insights
  • list_comments
  • get_comment_threads

Meta’s permissions differ by auth path. For media insights, Meta lists instagram_basic, instagram_manage_insights, and related page permissions for the Facebook Login path; for comments, Meta lists instagram_manage_comments plus related page permissions. For Instagram Login, the corresponding business scopes are instagram_business_basic, instagram_business_manage_insights, and instagram_business_manage_comments. (Facebook Developers)

4. Best implementation for Claude Code

Build a small custom MCP server that wraps the Instagram endpoints you actually need. Use the official MCP TypeScript SDK package @modelcontextprotocol/server, or another official MCP SDK. The official TypeScript SDK is published by the MCP project and supports building MCP servers. (GitHub)

Minimal flow:

  1. Create a Meta app.
  2. Enable the Instagram API path you chose.
  3. Complete OAuth and store the access token securely.
  4. Build an MCP server with a few tools that call Meta endpoints.
  5. Add that MCP server to Claude Code.
  6. Ask Claude Code to analyze the returned data and write reports.

If you plan to use this only for your own account in dev/testing, setup is much lighter. If you want to use it for broader production users, Meta says advanced permissions/features require App Review. (Facebook Developers)

5. Claude Code connection methods

Claude Code officially supports:

claude mcp add --transport http <name> <url>

for remote HTTP MCP servers, and project-scoped MCP config in .mcp.json. It also supports adding MCP servers from JSON with claude mcp add-json. (Claude API Docs)

6. Recommended project layout

ig-mcp/
├─ server/
│  ├─ src/
│  │  ├─ auth.ts
│  │  ├─ meta-client.ts
│  │  ├─ tools/
│  │  │  ├─ get-account-insights.ts
│  │  │  ├─ list-media.ts
│  │  │  ├─ get-media-insights.ts
│  │  │  └─ list-comments.ts
│  │  └─ index.ts
│  ├─ package.json
│  └─ .env
└─ analysis/
   └─ .mcp.json

7. Example .mcp.json for Claude Code

Use a project-scoped config so Claude Code can load the MCP server from the repo root. Anthropic says project-scope MCP servers are stored in .mcp.json in the project root. (Claude API Docs)

{
  "mcpServers": {
    "instagram-data": {
      "command": "node",
      "args": ["../server/dist/index.js"],
      "env": {
        "META_APP_ID": "${META_APP_ID}",
        "META_APP_SECRET": "${META_APP_SECRET}",
        "META_ACCESS_TOKEN": "${META_ACCESS_TOKEN}",
        "IG_USER_ID": "${IG_USER_ID}"
      }
    }
  }
}

Or add it by JSON:

claude mcp add-json instagram-data '{
  "type":"stdio",
  "command":"node",
  "args":["../server/dist/index.js"],
  "env":{
    "META_ACCESS_TOKEN":"your-token",
    "IG_USER_ID":"your-ig-user-id"
  }
}'

That command format is directly supported by Claude Code. (Claude API Docs)

8. MCP tool design you should expose

Your MCP server should expose tools like this:

get_account_profile()
get_account_insights(metrics, period, since, until)
list_media(limit, since, until)
get_media_insights(media_id, metrics)
list_comments(media_id, limit)

Each tool should call the matching Meta endpoint and return clean JSON, not raw API dumps. That matters because Claude Code warns on large MCP outputs and has MCP output token limits. Anthropic documents a default MCP output cap and warns when output gets large. (Claude API Docs)

9. What to tell Claude Code

Once the MCP server is connected:

Use the instagram-data MCP tools to analyze my Instagram account.

Tasks:
1. Pull account-level insights for the last 90 days
2. Pull all media posted in the last 90 days
3. Compute engagement rate by post type
4. Compare reels vs feed posts vs carousels
5. Identify top 20 posts by reach, saves, shares, comments
6. Cluster top-performing content patterns
7. Find weak-performing themes and posting windows
8. Output:
   - executive summary
   - markdown report
   - CSV tables
   - content strategy recommendations

10. Critical limits you need to know

Meta documents several constraints for insights:

  • media insights can return empty data instead of 0
  • metrics can be delayed by up to 48 hours
  • media metrics are stored for up to 2 years
  • the API reports organic interaction metrics only
  • Story metrics are only available for a limited window, and story handling has extra caveats (Facebook Developers)

11. Best practical route

For your use case, the cleanest route is:

Fastest

  • use Instagram API with Instagram Login
  • build a custom MCP server
  • connect that server to Claude Code with .mcp.json
  • let Claude Code analyze via MCP tools

Only use Facebook Login path if

  • your IG is already deeply tied to Meta Business / Page workflows
  • you need page-backed permissions and business-manager style access (Facebook Developers)

12. Bottom line

You do not “send IG data to Claude Code” directly.

You:

  1. authenticate against Meta,
  2. expose the needed IG data through an MCP server,
  3. connect that MCP server to Claude Code,
  4. let Claude Code call tools and analyze the returned JSON. (Claude API Docs)

正確入口是:

桌機瀏覽器 → 登入 Meta Business Suite → 左側 Insights
看受眾資料就點 Audience。Meta 官方對 Audience Insights 的路徑寫的是:Meta Business Suite → Insights → Audience。(Facebook)

下載位置不是在 IG App 裡。
Meta 官方對 Business Suite Insights 的說法是:報表可從 Export 下拉選單下載;而 Creator Studio 的這些工具已搬到 Meta Business Suite。(Facebook)

你現在應該這樣找:

  1. 用電腦開 business.facebook.com。Meta 官方也寫到專業帳號可用桌機登入 Meta Business Suite。(Instagram Help Center)

  2. 左側選單找 Insights。Meta 官方明確有 About Insights in Meta Business Suite on Desktop。(Facebook)

  3. 在 Insights 裡切到:

    • Audience:看粉絲 / 受眾
    • Content / Results / Overview:看貼文、Reels、互動表現
      受眾頁的官方入口是 Insights → Audience。(Facebook)
  4. 右上角找 Export 下拉選單下載。Meta 官方寫的是可從 Export dropdown menu 下載報表。(Facebook)

如果還是沒有 Export,通常是這三個原因:

  • 你在 Instagram App 的 Insights,不是桌面版 Business Suite。IG App 官方只強調可以在帳號內查看 Insights 與時間範圍,沒有把它描述成 CSV 匯出入口。(Instagram Help Center)
  • 你的 IG 不是 Professional account。官方說要有 professional account 才有這些專業儀表板與 insights。(Instagram Help Center)
  • 你沒有該 IG / Page 的 view insights 權限。Meta 官方明確寫:要在 Meta Business Suite 看 Insights,必須有對應 Facebook Page 或 Instagram account 的 insights 權限。(Facebook)

如果你只是要「把資料丟給 Claude Code 分析」,其實有兩條路:

A. 要分析成效數據
桌面版 Meta Business Suite → Insights → Export 下載報表。(Facebook)

B. 要匯出整個 IG 帳號資料包
Instagram 官方入口是:Profile → Accounts Center → Your information and permissions → Export your information。這是帳號資料備份,不是乾淨的 insights 報表。(Instagram Help Center)

結論:

  • 你要找的不是 IG App 內頁
  • 桌機版 Meta Business Suite
  • 路徑是 Insights → Audience / 其他 Insights 分頁
  • Export 在桌面版 Insights 頁面右上角
  • 沒看到的主因通常是 非專業帳號沒有 insights 權限 (Facebook)