instagram-claude-mcp
Connects Claude to the official Meta Instagram Graph API (read-only) for retrieving Instagram profile, media, insights, and comments as MCP tools over Streamable HTTP.
README
instagram-claude-mcp
Remote MCP server that connects Claude to the official Meta Instagram Graph API (read-only).
Exposes Instagram profile, media, insights, and comments as MCP tools over Streamable HTTP, so Claude can call them via an HTTPS MCP URL.
Features
| Tool | Description |
|---|---|
get_instagram_profile |
Connected Instagram professional account profile |
list_instagram_media |
Recent posts / reels / carousels |
get_instagram_media |
Details for a specific media item |
get_instagram_insights |
Account-level or media-level insights |
get_instagram_comments |
Comments (and replies when available) on a media item |
Not implemented (by design): publishing, deleting, messaging, comment replies, or any write operations.
Requirements
- Node.js 20+
- An Instagram professional account (Business or Creator)
- A Meta app with Instagram Graph API access
- A long-lived access token with read permissions for the account
- The Instagram account ID (
IG User ID)
Environment variables
Copy .env.example to .env and fill in values locally. Never commit .env.
| Variable | Required | Description |
|---|---|---|
INSTAGRAM_ACCESS_TOKEN |
Yes | Instagram User access token (prefer long-lived) |
INSTAGRAM_ACCOUNT_ID |
Conditional | Optional for Instagram Login (graph.instagram.com) — IG ID is resolved from /me.user_id. Required for graph.facebook.com |
INSTAGRAM_GRAPH_API_BASE |
No* | Default https://graph.facebook.com. *Use https://graph.instagram.com for Instagram Login tokens |
INSTAGRAM_API_VERSION |
No | Default v22.0 |
INSTAGRAM_APP_SECRET |
No | App secret — only for short→long-lived token exchange |
PORT |
No | HTTP port (default 3000) |
MCP_AUTH_TOKEN |
No | If set, /mcp and /exchange-instagram-token require Authorization: Bearer <token> |
Local development
npm install
cp .env.example .env
# Edit .env with INSTAGRAM_ACCESS_TOKEN and INSTAGRAM_ACCOUNT_ID
npm run dev
# or
npm run build && npm start
Endpoints:
- Health:
GET http://localhost:3000/health - Auth debug (safe):
GET http://localhost:3000/debug-instagram-auth - Profile tool debug:
GET http://localhost:3000/debug-instagram-profile - Media list debug:
GET http://localhost:3000/debug-instagram-media - MCP (Streamable HTTP):
http://localhost:3000/mcp
Instagram Login id vs user_id
On graph.instagram.com, GET /me returns:
id— app-scoped ID (not used for/media)user_id— Instagram professional account ID (<IG_ID>) used for/{user_id}/media, insights, etc.
This server resolves user_id from /me for Instagram Login and does not blindly trust INSTAGRAM_ACCOUNT_ID (which is often mistakenly set to id).
Instagram Login tokens (short vs long-lived)
-
App Dashboard → Generate token: already long-lived (~60 days). Put it in
INSTAGRAM_ACCESS_TOKEN. -
OAuth / Business Login (authorization code → token): returns a short-lived token (~1 hour). Exchange it before production use:
- Set
INSTAGRAM_ACCESS_TOKENto the short-lived token (temporarily). - Set
INSTAGRAM_APP_SECRETto your Instagram app secret. POST /exchange-instagram-token(sendAuthorization: Bearer <MCP_AUTH_TOKEN>if configured).- Copy
long_lived_access_tokenfrom the JSON intoINSTAGRAM_ACCESS_TOKENon Vercel. - Redeploy / restart. Remove the short-lived value.
- Set
Auth is sent as Meta’s documented access_token query parameter. Tokens are trimmed (whitespace, quotes, accidental Bearer / access_token= prefixes) before use. The full token is never logged or returned by /debug-instagram-auth.
Type-check without running:
npm run typecheck
Test with MCP Inspector
npx @modelcontextprotocol/inspector
Connect with transport Streamable HTTP and URL http://localhost:3000/mcp.
Deploy as a remote MCP server
Vercel (serverless Express)
This project is set up for Vercel’s Express runtime: the app is exported as a default Express handler and only calls app.listen() when not running on Vercel (VERCEL=1). That matches serverless invocation — there is no permanently running Node process in production.
- Import the GitHub repo in Vercel (or run
vercel). - Set Project Environment Variables (Production/Preview):
INSTAGRAM_ACCESS_TOKENINSTAGRAM_ACCOUNT_ID- Optional:
MCP_AUTH_TOKEN,INSTAGRAM_GRAPH_API_BASE,INSTAGRAM_API_VERSION
- Deploy. Endpoints stay the same:
https://your-app.vercel.app/healthhttps://your-app.vercel.app/mcp(Streamable HTTP)
vercel.json pins the Express framework, runs npm run build, and sets function maxDuration to 60s for Graph API calls. MCP handling is stateless (fresh transport per request), which is compatible with Vercel Functions / Fluid compute.
Claude connector URL example:
https://your-app.vercel.app/mcp
Other Node hosts (Railway, Render, Fly.io, Cloud Run, etc.)
- Push this repo and deploy as a normal Node service.
- Set the same secret environment variables in the host dashboard.
- The process runs
npm start→node dist/index.js, which listens onPORT.
npm install
npm run build
npm start
Connect from Claude
Claude (web / desktop connectors)
Add a custom connector with your HTTPS MCP URL, for example:
https://your-service.example.com/mcp
If you set MCP_AUTH_TOKEN, configure the matching bearer token in the connector settings when supported.
Claude Code
claude mcp add --transport http instagram-claude-mcp https://your-service.example.com/mcp
Cursor
Add to .cursor/mcp.json (or your MCP config):
{
"mcpServers": {
"instagram-claude-mcp": {
"url": "https://your-service.example.com/mcp"
}
}
}
Instagram API notes
- Uses only the official Meta Graph API (
graph.facebook.comorgraph.instagram.com). - Credentials are read from environment variables only — never hardcoded.
- Insights metrics and periods depend on Meta’s current Insights API rules (metric availability differs for account vs media, and by media product type). Pass the metrics Meta documents for your use case via the
metricstool argument. - Tokens expire; rotate long-lived tokens as needed in your host’s secret store.
Project layout
src/
app.ts # Express app factory (/health, /mcp) — default-exported for Vercel
index.ts # Entry: export app; listen only when not on Vercel
config.ts # Environment configuration
mcp-server.ts # MCP tool registration
instagram/client.ts # Official Graph API client (read-only)
vercel.json # Vercel Express + function limits
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。