Instagram MCP Server
Provides tools for publishing posts, managing media containers and carousels, handling comments, sending direct messages, retrieving user and media insights, and accessing Instagram Direct conversations through the Instagram Graph API.
Provides tools for managing Messenger platform profile settings (greeting text, ice breakers, etc.) associated with the Instagram account.
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., "@Instagram MCP Serverpost a photo with caption 'Sunset vibes'"
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.
Instagram MCP Server
A production-quality Model Context Protocol server that exposes Instagram actions (posts, media containers/carousels, comments, direct messages, insights, Messenger profile) to Claude and ChatGPT. Built for personal, single-user use with Composio as the auth/action layer, deployed on Alpic.
This project mirrors the sibling Linkedin-alpic-mcp server's architecture exactly — same stack, same
production fixes, just scoped to Instagram's Composio toolkit.
Features
Curated tool scope — the Composio session and tool discovery are both scoped to exactly the 34 Instagram actions enabled for this account (see
ENABLED_INSTAGRAM_TOOLSinsrc/composio_client.py), not every action Composio's Instagram toolkit could theoretically expose. Callinstagram_mcp_list_toolsto see the current live list with full JSON Schemas.Automatic Instagram auth — on startup, checks whether the fixed user is connected; if not, starts the OAuth flow, logs the authorization URL, and waits (bounded timeout) for the connection to complete.
Structured logging — JSON logs via the stdlib
loggingmodule, best-effort rotating log file underlogs/(falls back to stdout-only on a read-only filesystem, e.g. serverless deploys).Local stats tracking — total/successful/failed calls, average latency, last execution, startup time, and uptime; best-effort persistence to a local JSON file (falls back to in-memory-only if unwritable).
Health reporting —
instagram_mcp_healthreports server, Instagram connection, and Composio reachability.Never crashes — every Composio/network/auth failure (including Composio's own
PermissionDeniedErrorfor a playground-key/user_id mismatch) is caught and returned as a normal (but error-flagged) tool result, never an unhandled exception.Streamable-HTTP transport, binding
PORT/HOST— ready for Alpic's hosting model.
Architecture
src/
├── server.py # FastMCP app + entrypoint; wires everything together
├── composio_client.py # Thin wrapper around the Composio SDK (Instagram toolkit only)
├── tool_registry.py # Dynamic MCP tool list/dispatch: static utility tools + every Instagram action
├── config.py # Settings loaded from environment / .env
├── logger.py # Logging setup (best-effort file handler)
├── stats.py # JSON-backed call statistics tracker (best-effort persistence)
├── health.py # Health status aggregation
├── models.py # Shared Pydantic models
└── utils.py # Retry/backoff decorator, TimerThe four static tools (instagram_mcp_ping, instagram_mcp_health, instagram_mcp_version,
instagram_mcp_list_tools) are always available. Every other tool name is a Composio Instagram action slug
(e.g. INSTAGRAM_CREATE_POST, INSTAGRAM_GET_USER_INFO, INSTAGRAM_SEND_TEXT_MESSAGE, ...) — call
instagram_mcp_list_tools at any time to see the current live list with descriptions.
Available Instagram Tools
The server's Composio session is scoped to exactly these 34 actions. Parameters below are best-effort,
inferred from action names and the Instagram Graph API's conventions (this project's Composio account
hadn't completed its Instagram connection yet at doc-writing time, so schemas weren't live-fetched the way
the LinkedIn project's were) — call instagram_mcp_list_tools once connected to confirm exact fields.
Tool | Likely parameters | Use case |
| image/video URL, caption | Publish a single-media feed post. |
| media URL, caption, media type | Stage a single media item before publishing (required step before |
| list of child media container IDs, caption | Stage a multi-image/video carousel post from already-created media containers. |
| media container params | Create IG user media (container-based posting flow). |
|
| Publish a previously staged media container (single or carousel). |
| container/media id | Check whether a staged container has finished processing and is ready to publish. |
| media id | Get metadata for one media item (post). |
| carousel media id | List the individual media items inside a carousel post. |
| ig user id, pagination | List media (posts) on an account, paginated. |
| ig user id | List currently active stories for an account. |
| ig user id | List currently live video sessions for an account. |
| ig user id | List media where the account has been tagged. |
| ig user id | Check remaining publish quota (IG rate-limits posts per 24h). |
| media id, pagination | List comments on a post. |
| media id, comment text | Add a top-level comment to a post. |
| comment id, reply text | Reply to an existing comment. |
| comment id, pagination | List replies to a comment. |
| comment id | Delete a comment or reply. |
| (none — authenticated user) | Get your own connected account's profile info (username, id, account type). |
| ig user id, metrics, period | Account-level insights (reach, impressions, follower demographics). |
| media id, metrics | Per-post insights (impressions, engagement, saves). |
| ig user id, pagination | List Instagram Direct conversations for the account. |
| conversation id | Get one conversation's message history. |
| conversation id, pagination | List messages within a conversation. |
| recipient id, text | Send a text DM. |
| recipient id, image URL | Send an image DM. |
| conversation/message id | Mark a DM/conversation as read. |
| media id, comment/mention id | Handle a mention notification (e.g. tag reply flows). |
| (none) | Get the account's Messenger platform profile config (greeting text, ice breakers, etc.). |
| profile fields to update | Update the Messenger platform profile config. |
| field names to clear | Remove specific Messenger profile fields. |
Installation
Requires Python 3.12+ and uv.
git clone <this-repo>
cd instagram-mcp
uv venv
uv pip install -e ".[dev]"Configuration
Copy .env.example to .env and fill in your Composio credentials:
cp .env.example .envVariable | Required | Default | Description |
| Yes | — | Your Composio API key. A project-scoped key, not a playground key — playground keys are locked to one bound user and will 403 on any other |
| Yes | — | Your Composio account's user id — tool calls and the Instagram connection are scoped to this user. |
| No | Composio default | Use a specific Instagram auth config instead of the default one |
| No |
|
|
| No |
| Directory for the rotating log file (best-effort — falls back to stdout-only if unwritable) |
| No |
| Path to the persisted stats JSON file (best-effort — falls back to in-memory-only if unwritable) |
| No |
| Max time to wait for Instagram OAuth to complete at startup |
| No |
| Bind port (Alpic sets this automatically at deploy time) |
| No (baked into Dockerfile) | — | Composio's SDK writes a cache dir at import time; set to a writable path (e.g. |
Never hardcode COMPOSIO_API_KEY anywhere — it's read exclusively from the environment.
Running locally
uv run python -m src.serverOn first run, if Instagram isn't connected yet, the server logs an authorization URL and waits for you to complete the OAuth flow in a browser before finishing startup (or continues anyway on timeout — the server never crashes on this, it just starts without a working connection until you finish the OAuth link).
Test it's alive — note streamable-HTTP requires the MCP handshake (initialize →
notifications/initialized → your call, all carrying the same mcp-session-id response header), a bare
tools/call will fail with "Missing session ID". Also: on Windows PowerShell, bare curl is aliased to
Invoke-WebRequest and will silently mangle -X/-d — use curl.exe explicitly, or Git Bash's real curl.
curl -s -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'Running with Docker
docker build -t instagram-mcp .
docker run --rm -p 8000:8000 --env-file .env instagram-mcpDeploying to Alpic
npm install -g alpic # once
alpic login # or set ALPIC_API_KEY
alpic environment-variable add --env-file .env --environment-id <id>
alpic deploy --runtime python3.13Alpic prints the live MCP server URL and a /try playground URL on success. Note: Alpic's managed Python
runtime does not use this repo's Dockerfile — it builds directly from pyproject.toml with its own
buildpack, running out of a sandboxed home directory that's read-only. That's why COMPOSIO_CACHE_DIR,
best-effort file logging, and best-effort stats persistence all exist in this codebase — they were required
to get a Composio-based server running on Alpic at all (see Troubleshooting below).
Connecting from Claude Desktop
Deploy first (or run locally and expose it, e.g. with
ngrok http 8000).In Claude Desktop: Settings → Connectors → Add custom connector.
Paste the Alpic-hosted MCP URL (ends in
/mcp).Claude will list
instagram_mcp_ping,instagram_mcp_health, and every enabled Instagram action.
Connecting from ChatGPT
In ChatGPT: Settings → Connectors → Advanced settings → Developer mode (required for full custom tool calling, not just search/fetch).
Add custom connector, paste the Alpic-hosted MCP URL.
Enable the connector in a chat and ChatGPT can call any Instagram action directly.
Troubleshooting
Symptom | Likely cause | Fix |
Server won't start / crashes immediately |
| Both are mandatory — set them before first deploy/run |
| You're using a Composio playground key | Mint a project-scoped API key in the Composio dashboard instead — playground keys are hard-locked to one bound user server-side, no client-side |
Alpic build fails: | Composio's SDK creates a cache dir at import time; Alpic's sandbox | Set |
Alpic build fails: | Same read-only-filesystem class of issue, this time our own log/stats file writes | Already fixed in this codebase ( |
| OAuth never completed | Check server logs for the authorization URL, visit it, then call |
| Bad API key or Composio outage | Verify |
A Instagram tool call errors out | Expired auth, missing scope, or bad input | The error message is returned verbatim from Composio/Instagram in the tool result — read it, it's usually actionable |
|
| Use |
Testing
uv run pytestLicense
MIT — see LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- 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/selvin-paul-raj/Instagram-Alpic-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server