mcp-instagram
Allows publishing posts (single image or carousel) to Instagram via the official Graph API, including checking publishing quotas and managing access token refresh.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-instagram Publish an image at https://example.com/pic.jpg to Instagram with caption 'Hi there!'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-instagram
Instagram 发布 MCP server —— 走官方 Graph API,同时支持 stdio 与 streamable-http 两种传输。
为飞雁(feiyan)而写,但不依赖飞雁:任何 MCP 客户端都能用。AGPL-3.0-only。
为什么自己写
Meta 没有官方 Instagram MCP(唯一的官方连接器是 Meta Ads,只管广告投放)。社区实现有几个,但全是 Graph API 的薄封装、star 个位到二十几、维护弱。既然是薄封装,与其依赖一个随时会停更的仓库,不如自己维护一份。
Related MCP server: instagram-mcp-server
先决条件
这三件是 Meta 的硬门槛,不是本项目能绕开的:
专业账号(Business / Creator)。个人号在 API 层面被结构性排除。
Meta 应用 + Advanced Access:
instagram_business_content_publish权限要过 App Review 与企业验证,每次提交 2–4 周。长期访问令牌(60 天)与
IG_USER_ID。短期令牌可以用exchangeForLongLived()换一次;之后本服务会在剩余 7 天内自动续期。
平台硬限制(工具描述里也写了一遍)
项 | 限制 |
图片格式 | 仅 JPEG |
图片大小 | ≤ 8 MB |
图片尺寸 | 宽 320–1440 px |
宽高比 | 4:5 ~ 1.91:1 |
轮播 | 2–10 张;所有图按第一张的比例裁剪,顺序即展示顺序 |
caption | ≤ 2200 字符,≤ 30 个话题标签,不渲染 Markdown |
发布配额 | 100 条 / 24 小时滚动窗口(轮播算 1 条) |
媒体必须是 https 公网地址 —— Instagram 由服务端主动拉取,本地路径和内网地址它都取不到。把图片放到公网(对象存储 / CDN / 图床)再把 URL 交给本服务。
配置
环境变量 | 必填 | 说明 |
| ✅ | 专业账号的 user id(不是用户名) |
| ✅ | 长期访问令牌 |
| 仅「短期换长期」时需要;续期用不到 | |
| 默认 | |
| 令牌缓存目录。容器里挂卷,续期结果才能跨重启保留 | |
| http 模式的 Bearer 令牌。不设 = 不鉴权 | |
|
|
运行
# stdio(默认):客户端拉起本进程,一进程一账号
IG_USER_ID=... IG_ACCESS_TOKEN=... npx @feiyan/mcp-instagram
# streamable-http:常驻服务 / 容器
IG_USER_ID=... IG_ACCESS_TOKEN=... AUTH_TOKEN=$(openssl rand -hex 24) \
npx @feiyan/mcp-instagram --http --port 18080
# 端点 http://<host>:18080/mcp,健康检查 http://<host>:18080/healthz(不鉴权)Claude Desktop 之类的客户端配置:
{
"mcpServers": {
"instagram": {
"command": "npx",
"args": ["-y", "@feiyan/mcp-instagram"],
"env": { "IG_USER_ID": "...", "IG_ACCESS_TOKEN": "..." }
}
}
}工具
工具 | 说明 |
| 1 张 → 单图帖,2–10 张 → 轮播。唯一的发布入口 |
| 24 小时配额用了多少、还剩多少 |
| 令牌剩余有效天数 |
| 立即续期(通常不必手动调,快过期会自动续) |
失败一律以 isError: true 返回,并把 Graph API 的错误码翻成可执行的话(例如 190 → 「重新走一次授权」,10 → 「缺 instagram_business_content_publish,去 App Review 申请 Advanced Access」)。
开发
pnpm install
pnpm build # stdio 子进程用例测的是 dist/index.js,跑测试前先 build
pnpm test
pnpm check # tsc --noEmit
pnpm lint测试不打真实网络:起一个真的 node:http 假 Graph API 当夹具(mock fetch 只能证明「我以为的请求」是对的),并用真的 MCP 客户端 SDK 连 stdio 与 streamable-http 各跑一遍。
Available Tools
4 toolscheck_tokenA
查看访问令牌剩余有效天数。Instagram 长期令牌 60 天过期,本服务在剩余 7 天内自动续期;若长期不发布导致令牌彻底过期,则只能重新授权。
Inputs: no named parameters.
get_publishing_limitA
Instagram 的发布配额:100 条 / 24 小时滚动窗口(轮播算 1 条)。发布失败疑似限流时先查这个。
Inputs: no named parameters.
publish_postA
发布图文到 Instagram 专业账号。1 张图 → 单图帖,2–10 张 → 轮播(顺序即展示顺序,所有图按第一张的宽高比裁剪)。图片必须是 https 公网地址、JPEG 格式、≤8MB、宽 320–1440px、宽高比 4:5~1.91:1 —— Instagram 由服务端主动拉取媒体,本地路径与内网地址取不到。caption ≤2200 字符、话题标签 ≤30 个,且不渲染 Markdown。
Inputs: caption (required), image_urls (required), alt_texts.
refresh_tokenA
立即续期访问令牌(有效期重置为 60 天)。通常不必手动调用 —— 快过期时会自动续。
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
每个工具功能边界清晰:publish_post 负责发布内容,get_publishing_limit 查询配额,check_token 检查令牌有效期,refresh_token 刷新令牌。不存在职责重叠,易于选择。
所有工具均采用一致的 verb_noun 命名模式(publish_post, get_publishing_limit, check_token, refresh_token),动词明确,风格统一。
4 个工具精准覆盖 Instagram 发布与令牌管理的核心需求,数量精简,没有冗余工具。
覆盖了发布、配额查询、令牌查看与刷新等关键操作,但缺少如获取账号信息、删除帖子等扩展功能,不过对于当前定位已足够完整。
Maintenance
Related MCP Connectors
MCP server for QPost — lets AI agents publish video and image posts to YouTube, TikTok, Instagram.
Publish to Instagram from chat — official Graph API, OAuth 2.1, free for your own posts.
Instagram MCP for DM and comment automation, AI Agent and content publishing via Meta's official API
Instagram data over MCP: profiles, posts, reels, stories, highlights and search as JSON
Related MCP Servers
- AlicenseBqualityBmaintenanceMCP server for Instagram Graph API, Threads API & Meta platform — posting, insights, comments, messaging66361 npm32MIT
- FlicenseNot gradedqualityDmaintenanceMCP server for automatic Instagram publishing — single image, carousel and Reels — via the official Instagram Graph API.7 npm-
- AlicenseNot gradedqualityCmaintenanceMCP server for Instagram Graph API integration, enabling AI applications to manage Instagram Business accounts: fetch profiles, media, insights, publish content, and handle DMs.MIT
- AlicenseNot gradedqualityCmaintenanceLocal MCP server for preparing previews and publishing single image posts to Instagram after explicit user confirmation, with OAuth and safety safeguards.MIT