instagram-analytics-mcp
Health Uyari
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 7 GitHub stars
Code Basarisiz
- rm -rf — Recursive force deletion command in package.json
- network request — Outbound network request in package.json
- process.env — Environment variable access in scripts/mock.ts
- process.env — Environment variable access in scripts/smoke-live.ts
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
A Model Context Protocol (MCP) server that provides access to Instagram analytics and insights using the Instagram Graph API. This server allows you to retrieve account-level insights, media insights, and profile information programmatically.
Social Analytics MCP Server
A Model Context Protocol (MCP) server for Meta analytics: organic performance of Facebook Pages and Instagram professional accounts, and paid performance of ad accounts (Marketing API). Read-only, 33 tools, default Graph API version v27.0.
Features
Tools are grouped in toolsets. A toolset is registered only when it is selected (META_TOOLSETS) and a token exists for it.
- meta (always on when any token exists):
meta_check_access,meta_list_assets,meta_list_metrics,meta_get_performance_summary - instagram (organic): profile, account insights, audience demographics, media and media insights, stories, comments, tagged media, hashtags, business discovery, publishing limit
- facebook (organic): Pages, Page insights, posts and post insights, videos/reels and video insights, comments
- ads (paid): ad accounts, campaigns, ad sets, ads, insights (sync and async reports) with breakdowns
Also: a metric catalog that rejects metrics Meta removed (naming the replacement) before any API call, automatic 90/30 day range chunking, pagination with cursors, Page access token handling, throttle fail-fast with retry_after_minutes, token redaction in every error, and 7 pre-built prompts.
Quick start
git clone <repository-url>
cd social-analytics-mcp
npm install
npm run build
Create a token (Graph API Explorer, or a system user token) with the permissions in the table below, then add the server to your MCP client.
Configuration
| Variable | Default | Meaning |
|---|---|---|
META_ACCESS_TOKEN |
- | Preferred single token (long-lived user token or system user token) |
INSTAGRAM_ACCESS_TOKEN, FACEBOOK_ACCESS_TOKEN |
- | Legacy, still honoured: per-platform override |
META_ADS_ACCESS_TOKEN |
- | Optional separate token for ads; falls back to META_ACCESS_TOKEN, then FACEBOOK_ACCESS_TOKEN |
META_API_VERSION |
v27.0 |
Graph API version |
INSTAGRAM_API_VERSION, FACEBOOK_API_VERSION |
META_API_VERSION |
Legacy per-platform pins. Leave unset: a v3 .env often pins an old version. The server warns on stderr at startup when one differs from META_API_VERSION, and meta_check_access shows the version each toolset uses |
INSTAGRAM_ACCOUNT_ID, FACEBOOK_PAGE_ID, META_AD_ACCOUNT_ID |
- | Optional default ids (act_ prefix optional for the ad account) |
META_TOOLSETS |
all |
instagram,facebook,ads, or organic, paid, all |
META_GRAPH_BASE_URL |
https://graph.facebook.com |
Tests and npm run mock point it at a local mock |
META_MAX_ITEMS |
500 |
Hard cap on items returned per tool call |
META_TIME_BUDGET_MS |
45000 |
Time budget per tool call. Chunked insights stop when it runs out and return paging.continuation.since (the next unfetched day) with a warning |
META_APP_SECRET |
- | Optional. When set, every request carries appsecret_proof; the secret is redacted like tokens |
DEBUG |
- | social-analytics-mcp for debug logs |
Token precedence: instagram INSTAGRAM_ACCESS_TOKEN > META_ACCESS_TOKEN; facebook FACEBOOK_ACCESS_TOKEN > META_ACCESS_TOKEN; ads META_ADS_ACCESS_TOKEN > META_ACCESS_TOKEN > FACEBOOK_ACCESS_TOKEN.
The token is sent in the Authorization: Bearer header, never in a URL.
Permissions per toolset
| Toolset | Permissions |
|---|---|
instagram_basic, instagram_manage_insights, pages_show_list, pages_read_engagement |
|
pages_show_list, pages_read_engagement, read_insights |
|
| ads | ads_read (add business_management only to list a Business Manager's client ad accounts) |
meta_check_access shows which of these your token is missing, per toolset.
MCP client setup
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"social-analytics": {
"command": "node",
"args": ["/absolute/path/to/social-analytics-mcp/dist/index.js"],
"env": {
"META_ACCESS_TOKEN": "<your-token>",
"FACEBOOK_PAGE_ID": "<optional-page-id>",
"INSTAGRAM_ACCOUNT_ID": "<optional-instagram-account-id>",
"META_AD_ACCOUNT_ID": "<optional-ad-account-id>"
}
}
}
}
Claude Code:
claude mcp add social-analytics -e META_ACCESS_TOKEN=<your-token> -- node /absolute/path/to/social-analytics-mcp/dist/index.js
Tools
Ids are optional where a default env var exists. Dates accept YYYY-MM-DD or unix seconds.
Meta (shared)
| Tool | Purpose | Main arguments |
|---|---|---|
meta_check_access |
Who each token belongs to, granted/declined permissions, what is missing per toolset | none |
meta_list_assets |
Pages, linked Instagram accounts and ad accounts the tokens can see | include |
meta_list_metrics |
Metric catalog lookup (no API call): status, periods, breakdowns, replacements | object (ig_user, ig_media, page, post, video, ads), media_kind, status, include_deprecated |
meta_get_performance_summary |
Page, Instagram and ads headline numbers side by side (default 28 days, max 90) | source (organic, paid, all), since, until, page_id, ig_account_id, ad_account_id |
| Tool | Purpose | Main arguments |
|---|---|---|
instagram_list_accounts |
Linked professional accounts | none |
instagram_get_profile |
Profile and counts | account_id |
instagram_get_account_insights |
Account metrics, time series or totals | metrics, metric_type, breakdown, since, until, allow_unknown_metrics, raw |
instagram_get_audience_demographics |
Follower or engaged audience | audience, breakdown, timeframe |
instagram_list_media |
Recent media | limit, since, until, media_product_type, include_insights, after |
instagram_get_media |
One media item | media_id |
instagram_get_media_insights |
Per-media insights | media_id, metrics, breakdown, include_paid_totals |
instagram_get_stories |
Current stories | account_id |
instagram_get_comments |
Comments and replies | media_id, include_replies |
instagram_get_tagged_media |
Media the account is tagged in | account_id, limit |
instagram_search_hashtag |
Hashtag id (30 per account per 7 days) | hashtag |
instagram_get_hashtag_media |
Top or recent media for a hashtag | hashtag_id, type |
instagram_business_discovery |
Public data of another business account | username, media_limit |
instagram_get_content_publishing_limit |
Publishing quota | account_id |
| Tool | Purpose | Main arguments |
|---|---|---|
facebook_list_pages |
Pages the token can access | none |
facebook_get_page |
Page profile | page_id |
facebook_get_page_insights |
Page metrics | metrics, period, since, until, split_paid_organic, split_followers |
facebook_list_posts |
Posts with counts | edge, limit, since, until, include_insights |
facebook_get_post_insights |
Post metrics | post_id, metrics, split_paid_organic, split_followers |
facebook_list_videos |
Videos or reels | type (videos, reels) |
facebook_get_video_insights |
Video or reel metrics | video_id, is_reel, metrics |
facebook_get_comments |
Comments on a post or video | object_id |
Ads
| Tool | Purpose | Main arguments |
|---|---|---|
ads_list_accounts |
Ad accounts (optionally a Business Manager's) | business_id, include_client_accounts |
ads_list_campaigns / ads_list_adsets / ads_list_ads |
Objects with status and budgets | ad_account_id, campaign_id / adset_id, effective_status |
ads_get_insights |
Paid insights | object_id, level, date_preset or since/until, time_increment, fields, breakdowns, action_breakdowns, filtering, sort, platform |
ads_create_insights_report |
Async report for large queries | same as ads_get_insights |
ads_get_insights_report |
Status and rows of an async report | report_run_id |
Organic vs paid
Facebook page_media_view and Instagram views already include views driven by ads. This server shows organic and paid side by side and never adds them together.
# only organic tools, or only paid tools
META_TOOLSETS=organic
META_TOOLSETS=paid
# paid share of Page views (breakdown is_from_ads, returned as true/false)
facebook_get_page_insights { "metrics": ["page_media_view"], "split_paid_organic": true }
# the same Instagram media with its paid totals
instagram_get_media_insights { "media_id": "<id>", "include_paid_totals": true }
# ads for Instagram only
ads_get_insights { "level": "campaign", "date_preset": "last_30d", "platform": "instagram" }
# everything side by side for the last 28 days
meta_get_performance_summary { "source": "all" }
Notes:
- In
meta_get_performance_summaryevery section coverssinceup to, but not including,until(the ads request stops the day beforeuntil). Inads_get_insights,untilis inclusive, as in Meta'stime_range. - Unique metrics (such as reach) are never summed across chunks: ranges longer than one chunk return per-chunk totals with a warning.
- Ads spend in insights is in major currency units; budgets are reported in the account currency's minor units.
- Meta data can lag up to 48 hours, and insights need 100+ followers or likes.
Output shapes
Every tool returns { data, paging?, warnings?, money_unit_note?, _meta: { api_version, usage_pct? } }. paging.next_cursor goes back in after; paging.continuation.since is the next unfetched day when the time budget ran out.
- Instagram insights:
datais keyed by metric name. Each metric hastotal(a single number),series([{ date, end_time, value }]),breakdown([{ dimensions, value }]) and/orchunks(per-window totals, labelled with their dates, for unique metrics over ranges longer than one window). - Facebook insights: without a split,
datais keyed by metric name, as above. Withsplit_paid_organic/split_followers,datais keyed by breakdown (is_from_ads,is_from_followers), plusunsplitfor metrics that support neither; each holds metrics keyed by name. - Ads insights:
datais a list of rows. Withnormalize(default) numeric strings become numbers (ids, names and breakdown values stay strings), and every action list (actions,action_values,purchase_roas, ...) becomes a{ action_type: value }map, with attribution windows asaction_type:7d_clickkeys.normalize: falsereturns Meta's rows as they are. raw: truealso returns Meta's responses untouched under_raw.
Prompts
analyze_instagram_performance, analyze_facebook_performance, compare_post_performance, get_audience_demographics, setup_platform, analyze_ads_performance, compare_organic_vs_paid.
Removed metrics
Meta removed many metrics (for example Instagram impressions, Page page_impressions*, page_fans*, page_engaged_users, and Reels plays). Requesting one returns a VALIDATION error naming the replacement, for example views, page_media_view or page_follows. Use meta_list_metrics with include_deprecated to see them all. See the CHANGELOG for the full list.
Testing
npm test # unit and end-to-end tests against a local mock Graph API
npm run typecheck # includes tests and scripts
npm run mock # mock Graph API on http://localhost:8787 (MOCK_PORT to change)
npm run smoke # live, read-only smoke test with your own token from .env
To click around without a real token, run npm run mock, then point a client at it:
{
"command": "node",
"args": ["/absolute/path/to/social-analytics-mcp/dist/index.js"],
"env": { "META_GRAPH_BASE_URL": "http://localhost:8787", "META_ACCESS_TOKEN": "dummy" }
}
npm run smoke calls every enabled tool with tiny limits and prints a PASS/FAIL table (tokens are never printed). It also checks each metric the catalog marks unverified, and daily page_media_view over a 100 day range to report any missing day at the chunk boundary. The hashtag search is skipped unless SMOKE_HASHTAG is set (it uses Meta's 30 hashtags per 7 days quota). It exits 1 on any failure other than PERMISSION.
Requirements
Node.js 20 or newer.
License
MIT
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi