Social Analytics MCP Server
Enables Instagram and Facebook analytics via the Meta Graph API, offering account insights, media analytics, and post engagement data.
README
Social Analytics MCP Server
A Model Context Protocol (MCP) server for Instagram and Facebook analytics via the Meta Graph API.
Features
- Account discovery and profile information
- Account-level insights with demographic breakdowns
- Media listing with engagement data
- Per-post insights (images, videos, reels, carousels)
- Stories retrieval
- Hashtag search and media discovery
- Content publishing rate limits
- Mentioned/tagged media
- Page discovery and detailed page info
- Page-level insights (impressions, engagement, fans, views)
- Post-level insights
- Posts with inline metrics
- Page feed with reactions/comments/shares
- Known metrics reference
- Access token validation
Shared
- Pre-built analysis prompts for common workflows
- Retry with exponential backoff on 429/5xx errors
- Structured error handling across both platforms
- Debug logging via
DEBUG=social-analytics-mcp
Quick Start
-
Install and build
git clone <repository-url> cd social-analytics-mcp npm install npm run build -
Get an access token from the Graph API Explorer with permissions:
- Instagram:
instagram_basic,instagram_manage_insights,pages_read_engagement - Facebook:
read_insights,pages_read_engagement
- Instagram:
-
Add to your MCP client (see configuration below)
Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
INSTAGRAM_ACCESS_TOKEN |
For Instagram | — | Facebook User Access Token with Instagram permissions |
INSTAGRAM_ACCOUNT_ID |
No | Auto-detected | Instagram Business Account ID |
INSTAGRAM_API_VERSION |
No | v23.0 |
Instagram Graph API version |
FACEBOOK_ACCESS_TOKEN |
For Facebook | — | Facebook User/Page Access Token |
FACEBOOK_PAGE_ID |
No | Use discovery tool | Facebook Page ID |
FACEBOOK_API_VERSION |
No | v22.0 |
Facebook Graph API version |
DEBUG |
No | — | Set to social-analytics-mcp for debug logs |
You only need to configure access tokens for the platforms you want to use. Account and page IDs can be discovered using the built-in tools.
MCP Client Setup
Claude Desktop
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"social-analytics": {
"command": "node",
"args": ["/absolute/path/to/social-analytics-mcp/dist/index.js"],
"env": {
"INSTAGRAM_ACCESS_TOKEN": "your_token_here",
"FACEBOOK_ACCESS_TOKEN": "your_token_here"
}
}
}
}
Claude Code
claude mcp add social-analytics node /absolute/path/to/social-analytics-mcp/dist/index.js \
-e INSTAGRAM_ACCESS_TOKEN=your_token_here \
-e FACEBOOK_ACCESS_TOKEN=your_token_here
Available Tools
Instagram Tools
| Tool | Description | Required Params |
|---|---|---|
instagram_list_accounts |
List available Instagram Business accounts | — |
instagram_get_profile |
Get account profile info | — |
instagram_get_account_insights |
Get account-level analytics | metrics, metric_type, period |
instagram_list_media |
List recent media posts | — |
instagram_get_media_details |
Get details for a specific post | media_id |
instagram_get_media_insights |
Get insights for a specific post | media_id, metrics |
instagram_get_stories |
Get recent stories | — |
instagram_get_hashtag_search |
Search for a hashtag ID | hashtag |
instagram_get_hashtag_media |
Get media for a hashtag | hashtag_id |
instagram_get_content_publishing_limit |
Check publishing rate limits | — |
instagram_get_mentioned_media |
Get media where account is tagged | — |
Facebook Tools
| Tool | Description | Required Params |
|---|---|---|
facebook_list_pages |
List accessible Facebook Pages | — |
facebook_get_page_details |
Get page profile information | — |
facebook_get_page_insights |
Get page-level insights | metrics |
facebook_get_post_insights |
Get insights for a specific post | post_id, metrics |
facebook_list_posts_with_insights |
List posts with inline metrics | post_metrics |
facebook_get_page_feed |
Get page feed with engagement data | — |
facebook_list_known_metrics |
List supported metrics reference | — |
facebook_validate_token |
Validate an access token | access_token |
Common Parameters
Most Instagram tools accept an optional account_id parameter. If not provided, the account is auto-detected from the INSTAGRAM_ACCOUNT_ID environment variable or discovered automatically if only one account exists.
Most Facebook tools accept an optional page_id parameter with similar auto-detection behavior via FACEBOOK_PAGE_ID.
Available Prompts
| Prompt | Description |
|---|---|
analyze_instagram_performance |
Comprehensive Instagram account analysis |
analyze_facebook_performance |
Comprehensive Facebook Page analysis |
compare_post_performance |
Compare recent posts on either platform |
get_audience_demographics |
Audience demographic breakdown |
setup_platform |
Interactive setup guide |
Programmatic Usage
import { InstagramClient, FacebookClient, createServer } from 'social-analytics-mcp';
// Use clients directly
const instagram = new InstagramClient({
accessToken: 'your_token',
accountId: 'optional_account_id',
});
const profile = await instagram.getUserProfile();
// Or create an MCP server programmatically
const server = createServer();
Troubleshooting
"Access token is invalid"
- Ensure your token has the required permissions
- Short-lived tokens expire in 1 hour — generate a long-lived token
"No Instagram Business account found"
- Your Instagram account must be a Business or Creator account
- It must be connected to a Facebook Page
"Unsupported metric"
- Some metrics are media-type specific (e.g.,
avg_time_watchedonly works for videos/reels) - Use
facebook_list_known_metricsto see supported Facebook metrics
Rate limits
- Instagram: 200 calls/hour per user token
- The server automatically retries on 429/5xx with exponential backoff
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
MIT
Note: This is an unofficial tool and is not affiliated with Meta, Facebook, or Instagram.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。