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 "Install 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-instagramPublish 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
先决条件
这三件是 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 天内自动续期;若长期不发布导致令牌彻底过期,则只能重新授权。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It adds genuine context — automatic renewal within the 7-day window and the re-authorization fallback — which helps the agent interpret results. Still, the tool's own operational traits (read-only, no side effects) are only implied by the verb '查看' rather than stated.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two compact clauses front-load the core purpose and then add only high-value lifecycle facts. Every sentence earns its place; there is no filler or repetition of schema content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter, no-output-schema check tool this is nearly complete: the description states what is reported (remaining days) and explains the surrounding token policy. It could add a brief note on the exact return format, but nothing an agent needs to call the tool is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema is empty (0 parameters, 100% coverage), so there is nothing for the description to document. Baseline 4 applies: no parameter ambiguity exists, and the description confirms the tool only inspects token state.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb and resource — '查看访问令牌剩余有效天数' (check the remaining valid days of the access token) — so an agent immediately knows what the tool does. The 60-day expiry and auto-renewal context helps place it in the token lifecycle and implicitly set it apart from siblings like refresh_token, though it never names the alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The lifecycle information ('60 天过期', '剩余 7 天内自动续期', '彻底过期则只能重新授权') implies when checking token health matters and hints that renewal is handled automatically. However, there is no explicit guidance on when to use this tool versus refresh_token or get_publishing_limit — no direct exclusions or alternative routing.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_publishing_limitA
Instagram 的发布配额:100 条 / 24 小时滚动窗口(轮播算 1 条)。发布失败疑似限流时先查这个。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description bears the full burden. It discloses the key behavioral detail: the exact quota window and counting rule, which is useful. However, it does not state whether the operation is read-only, what the return value looks like, or any side effects. The description is partially transparent but lacks return-format and safety context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, compact sentence that packs the necessary quota information and usage trigger into minimal words. Every phrase is informative: the quota value, the rolling window, the carousel counting rule, and the use case.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter read-only discovery tool, the description provides the essential facts: quota limit, time window, and when to invoke. The lack of return-value specification is a minor gap since the operational context is otherwise clear. The description is complete enough for an agent to successfully use the tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
This tool has zero parameters, so the baseline is 4. The description correctly focuses on the quota details rather than parameter explanations, which are unnecessary. The description adds value by explaining the quota semantics that would otherwise be opaque.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: retrieving Instagram's publishing quota with specific details (100 posts per 24-hour rolling window, carousel counts as 1). It uses the verb '查' (check) and names the exact resource, making it distinct from siblings which handle publishing and token management.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly says to check this when publishing failures are suspected to be caused by rate limiting, providing a clear when-to-use. It does not mention when not to use it or alternatives, but for a simple quota lookup this guidance is sufficient and actionable.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
publish_postA
发布图文到 Instagram 专业账号。1 张图 → 单图帖,2–10 张 → 轮播(顺序即展示顺序,所有图按第一张的宽高比裁剪)。图片必须是 https 公网地址、JPEG 格式、≤8MB、宽 320–1440px、宽高比 4:5~1.91:1 —— Instagram 由服务端主动拉取媒体,本地路径与内网地址取不到。caption ≤2200 字符、话题标签 ≤30 个,且不渲染 Markdown。
| Name | Required | Description | Default |
|---|---|---|---|
| caption | Yes | 正文,≤2200 字符;纯文本,Markdown 标记会原样显示 | |
| alt_texts | No | 无障碍描述,与 image_urls 一一对应 | |
| image_urls | Yes | 图片的 https 公网地址,1–10 个;第一张决定轮播的裁剪比例 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Although no annotations are provided, the description discloses important behavioral traits: the server actively pulls media from public https URLs, local/intranet paths won't work; image cropping based on first image's aspect ratio; carousel ordering defines display order; pure text rendering (no Markdown). These are non-obvious behaviors that help avoid failed calls. A small gap: it doesn't mention what the response looks like or potential side effects (e.g., posting immediately).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is dense but well-structured: it front-loads the core purpose, then breaks constraints into a compact list of requirements. Every sentence provides actionable information with no fluff. It's long but justified because of the numerous technical constraints; clarity is maintained.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a publishing tool with no annotations or output schema, the description covers input constraints comprehensively, the behavior of media fetching, and likely failure modes (e.g., local paths won't work). It lacks explicit return-value or error-handling info, but since there's no output schema, the description carries that burden; still, it's sufficiently complete for an agent to invoke correctly. Sibling context shows it's part of an Instagram integration, so no further context is needed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds significant meaning beyond the schema strings: it explains that image_urls must be publicly accessible https URLs (server fetches them), 1-10 images, JPEG, size limits, dimensions, and aspect ratios; alt_texts correspond one-to-one; caption length and pure-text behavior. This compensates and elevates above baseline.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: publish images/text to an Instagram professional account. It specifies the resource (Instagram professional account) and action (publish), and differentiates itself from sibling tools like get_publishing_limit, check_token, and refresh_token, which are about authorization or limits, not publishing content.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states when to use this tool (to publish single or carousel posts) and what constraints apply (image format, size, dimensions, aspect ratio, caption length, hashtag limits). It also implies not to use it for other Instagram operations such as fetching limits or managing tokens, which are handled by sibling tools. This is clear usage context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
refresh_tokenA
立即续期访问令牌(有效期重置为 60 天)。通常不必手动调用 —— 快过期时会自动续。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
没有注解,描述承担全部责任。它揭示了自动续期行为和有效期重置,但未提及可能的副作用、权限要求、频率限制或幂等性,行为透明性不足。
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
两句话简明扼要,关键信息(续期、60天、自动)前置,无冗余内容,结构高效。
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
对于无参数、无输出schema的简单工具,描述提供了核心行为和默认调用场景,但缺少手动调用的必要场景说明,完整性略有欠缺。
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
此工具没有参数,schema覆盖率为100%,描述无需额外解释参数。无参数的工具基线为4,符合要求。
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
描述明确说明了操作是'续期访问令牌',并给出了具体效果(有效期重置为60天),动词和资源清晰,与兄弟工具(如check_token)形成区分。
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
描述提到'通常不必手动调用',暗示了非使用场景,但没有说明何时需要手动调用或提供替代方案。虽有一定指引,但不够完整。
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
每个工具功能边界清晰:publish_post 负责发布内容,get_publishing_limit 查询配额,check_token 检查令牌有效期,refresh_token 刷新令牌。不存在职责重叠,易于选择。
所有工具均采用一致的 verb_noun 命名模式(publish_post, get_publishing_limit, check_token, refresh_token),动词明确,风格统一。
4 个工具精准覆盖 Instagram 发布与令牌管理的核心需求,数量精简,没有冗余工具。
覆盖了发布、配额查询、令牌查看与刷新等关键操作,但缺少如获取账号信息、删除帖子等扩展功能,不过对于当前定位已足够完整。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for QPost — lets AI agents publish video and image posts to YouTube, TikTok, Instagram.
Hosted MCP for Instagram, Facebook, X, LinkedIn, Pinterest, and Ghost. OAuth 2.1, 38 tools.
FastMCP server for posting formatted content to X (Twitter) — Tollbooth-monetized, DPYC-native
Create your offers and launch AI Instagram DM sales agents from any MCP client, over OAuth.
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server for Instagram Graph API, Threads API & Meta platform — posting, insights, comments, messaging5730723MIT
- AlicenseBqualityAmaintenanceAn MCP server for the official Instagram Graph API, enabling read, publish, comment, and analytics across Instagram Business/Creator accounts.29MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for automatic Instagram publishing — single image, carousel and Reels — via the official Instagram Graph API.26
- 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
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zouwei/mcp-instagram'
If you have feedback or need assistance with the MCP directory API, please join our Discord server