Skip to main content
Glama
Instagram Posting MCP

Instagram Posting MCP

README.md
# Instagram Posting MCP — local bridge (v1)

**What this is:** a small, local-only MCP server that lets **any AI** post to
Instagram and read insights — without opening the Instagram app.

**What it is not (v1):** it does **not** watch or judge a video. Checking
subtitles, titles, audio gaps or visual quality is a separate project.
This bridge checks size / duration / ratio / caption length only, then posts.

**Local only:** this creates a **temporary local server on your PC**.
There is no cloud server in v1. When it is off, nothing runs and nothing
is uploaded anywhere. Your Instagram token stays in a file on your PC
(`.env`, git-ignored) — it is never sent to the AI, never pasted in chat,
and never shared with another user.

## The 12 tools (v1 — 8 posting/reading + 1 uninstall + 1 startup switch + 2 account selection)

| Tool | What it does |
|---|---|
| `list_accounts` | List the Instagram accounts on this bridge — id, username, which is default (never shows tokens) |
| `set_default_account` | Switch the default posting account — asks you Yes/No first, only switches after you say Yes (same confirm gate as `set_startup_mode`) |
|---|---|
| `set_startup_mode` | Switch between auto-start and on-demand any time, no reinstall — never switches silently: confirm=false only returns the Yes/No question to ask the user, confirm=true (after the user said Yes) switches and saves `startup_mode` to config.json (see "Switch startup mode any time" below) |
| `request_uninstall` | Start the uninstall flow — returns a one-time link; nothing is deleted until you click the final Uninstall button in your browser (see "How to uninstall" below) |
| `post_reel` | Publish a Reel — video < 90 s, < 100 MB, vertical 1080×1920, cover image required |
| `post_feed_image` | Publish a feed photo |
| `post_story` | Publish a Story (image or video) |
| `schedule_post` | Schedule a reel / image for a future time |
| `list_posts` | List recent posts / reels (read-only) |
| `get_post_insights` | Lifetime insights for one post (read-only) |
| `get_account_insights` | Account totals / trends (read-only) |
| `update_post_settings` | Turn comments on/off on a post |

**Approval rule:** a publish tool must only be called after **you** have
approved the exact video, caption, hashtags and settings. The bridge
cannot see that approval — the AI calling it must ask you first, the same
live Allow step used today. No tool posts silently.

**Instagram limits (Graph API):**
- Caption edit: **NOT supported** by Instagram Graph API — Meta documents no caption-edit endpoint for published media. Only comments on/off can be changed via API. Edit captions in the Instagram app.
- Reels via API: **under 90 seconds, under 100 MB**. A longer video must
  be posted from the Instagram app (app allows up to 3 min).
- Every file: under 100 MB. Caption + hashtags: max 2,200 characters.
- Needs a **Business or Creator** Instagram account, connected to a
  Facebook Page (Meta requirement).
- Instagram does not let this bridge list, edit or cancel a scheduled
  post — check scheduled posts in the Instagram app.

**Local files vs public URLs — read this before a real post:**
Instagram's Graph API needs a **public https URL** for a video / image,
not a file on your PC. So:
- Pass a public `https://…` URL directly, **or**
- Set `IG_PUBLIC_BASE_URL` in `.env` to a folder where your file is
  publicly served, and pass the local file path — the bridge builds the
  URL from it, **or**
- In dry-run mode the bridge simulates the post and tells you exactly
  what URL it would have used.
If neither is set, the tool fails with a clear message and **no
Instagram call is made**. A temporary-upload helper is planned later, not v1.

## Two modes — how it runs on your PC

### Mode 1 (recommended): auto-start wake helper — 5–10 MB RAM
`wake-helper.js` is a tiny, zero-dependency listener. When your PC is on
it uses only ~5–10 MB RAM. A remote AI sends it a secret wake signal,
it starts the full bridge for a short time, and the bridge shuts itself
off after **5 minutes idle** (`IDLE_TIMEOUT_MINUTES`). The AI can also
turn it off with `POST /stop`. The listener is reachable over the
Tailscale interface (so a remote AI can wake it) and every wake/stop
needs the secret token — never expose the PC directly to the public
internet; Tailscale only.

```bash
node wake-helper.js          # listener on :8787 (this PC + Tailscale, token-gated)
curl http://127.0.0.1:8787/status
curl -X POST http://127.0.0.1:8787/wake -H "Content-Type: application/json" -d '{"token":"<WAKE_SECRET>"}'
```

### Mode 2: on-demand — double-click / On button
Run the bridge only when you need to post. Local AI launches it itself
(stdio mode, below); for HTTP mode run `npm run start:http`. It exits
by itself after 5 min idle. Nothing runs when you are not posting.

## Switch startup mode any time (no reinstall)

Your mood can change — so can the mode. Tell any AI "switch the bridge
to auto-start" (or "to on-demand") and it works instantly, no reinstall:

1. The AI calls `set_startup_mode` **without** confirmation first.
   That call changes **nothing** — it only returns the exact Yes/No
   question to ask you.
2. **You say Yes (or No).** Only if you say Yes does the AI call it
   again with `confirm=true`.
3. The bridge then writes `startup_mode` to `config.json` and
   creates/removes the OS auto-start entry for the tiny wake helper:
   - **Windows:** HKCU Run value `InstagramMCPBridge` (your own user
     hive — **no admin needed** for the switch itself; the installer
     asked for UAC once at install time, the switch does not).
   - **macOS:** LaunchAgent plist
     `~/Library/LaunchAgents/com.instagram-mcp-bridge.plist`
     (takes effect at next login).
   - **Linux:** autostart file `~/.config/autostart/instagram-mcp-bridge.desktop`.
4. Done — the switch is instant. The mode that is running right now is
   not affected; the new mode applies from the next login.

If the OS entry cannot be created/removed (missing tool, locked file,
permission error), the mode is **not** saved and the tool returns a
clear error saying what failed and how to fix it by hand — it never
pretends the switch worked, and the bridge keeps running. Uninstall
removes the auto-start entry either way (see "How to uninstall").

## Multiple Instagram accounts — pick which one a post goes to

One bridge can hold several Instagram accounts. A post always goes to
exactly **one** account — never to all of them at once.

- **See your accounts:** call `list_accounts`. It shows each account's
  short id, username, and which one is the default. It never shows
  tokens or full Instagram user ids.
- **Pick the default once:** tell your AI, e.g. "make @stud.playz the
  default account". The AI asks you first ("Do you want to make
  @stud.playz the default?") and only switches after you say Yes —
  exactly like the startup-mode switch. The default is saved in
  `config.json` (`default_account_id`).
- **Post to another account just once:** pass `account` on that one
  call (the id or the username from `list_accounts`), e.g.
  `post_reel(..., account: "builderji")`. The default does not change.
- **If you name an account that is not on this bridge,** the tool
  fails with a clear error and no Instagram call is made.

How accounts are stored: `config.json` holds an `accounts` list of
`{ id, username, ig_user_id, ig_access_token }` plus
`default_account_id`. If there is no list yet, the single account from
`.env` (`IG_USER_ID` / `IG_ACCESS_TOKEN`) is used as the default —
nothing about the old single-account setup changes.

How a second account gets added: only through the one-click Instagram
login, which delivers its token straight to this PC. There is no tool
that adds an account with a pasted token — never paste a token in
chat, and never send one to the AI.

How a second account gets added, in practice: connect it once with
the one-click Instagram login on the installer website. The installer
opens the login, you approve on Meta, and the bridge saves the new
account itself — you never edit a file. If that account was already
connected before, reconnecting just refreshes its token. Your
previous default account stays the default unless you ask your AI
to change it.

Token expiry: `list_accounts` shows how many days each token has
left, and warns when one expires within 7 days (or has already
expired) so you can reconnect in time. An account from the old
single-account setup shows unknown expiry — the bridge never
guesses a number.

## Install — for normal users (one click, no commands)

**You do NOT need to run any `npm` or `node` command.** That is only
for developers — see "Advanced / developers" at the bottom.

1. Open the installer website, pick your computer (Windows / Mac /
   Linux), click **Download**. One program file downloads (see
   INSTALL.md for the exact names and the honest warnings).
2. Put the file in its own folder, with `uninstall.html` next to it.
   Double-click the file to run it.
   - **Windows:** SmartScreen will warn because the file is unsigned
     — check the SHA-256 checksum first, then More info → Run anyway.
   - **macOS:** Gatekeeper will block it at first — right-click the
     file and choose Open.
   - **Linux:** `chmod +x` the file first, then run it.
3. With no settings the bridge runs in dry-run mode (safe — nothing
   is posted). Your AI can switch startup mode for you later
   (`set_startup_mode`) — there is no auto-start question at install
   in v1.0.0, and no Start-menu shortcut yet.
4. Connect Instagram once (below). After that, just tell your AI
   "post this reel".

Full installer plan (how the one-click file is made, what it installs,
per-OS packaging, and what v1.0.0 actually ships): see **INSTALL.md**.
v1.0.0 single-file programs are built (release files staged in
`release-v1.0.0/`, GitHub Release to be created). The Windows file is
unsigned and the macOS files are not notarised — see **SECURITY.md**
(code signing is still a launch blocker for a zero-warning launch).
A wrapped installer (Inno Setup / .dmg / .deb) is still pending.

## How to uninstall (easy, two steps)

1. Tell any AI: "uninstall the Instagram MCP Bridge". The AI must ask
   you first — it cannot uninstall anything by itself.
2. Open the link the AI gives you.
   **Step 1:** "Do you want to uninstall this?" — No cancels, Yes
   goes to Step 2.
   **Step 2:** optional feedback + tick "delete my Instagram token
   and settings" (recommended), then click the final **Uninstall**
   button. Only that click starts uninstalling.
3. You see **"Thank you for using us"**. The bridge, wake helper and
   auto-start are gone. Your Instagram posts stay on Instagram.
   (In v1.0.0 there is no Settings → Apps entry yet — that comes with
   the wrapped installer. Until then, delete the program file and its
   folder after the two steps above.)

## Advanced / developers (only place with commands)

```bash
cd instagram-mcp-bridge
npm install
npm run build
node dist/index.js --help        # usage, no token needed
node dist/index.js --list-tools  # the 12 tools, no token needed
npm run start:dry-run            # safe test, stdio mode, no real call
npm run package                  # build dist-package/ installer payload
npm run uninstall-server         # serve the uninstall page on localhost
```

Node 18+ required for this developer flow. `ffprobe` (from ffmpeg) is
optional but recommended — without it the bridge cannot check a video's
duration locally and says so.

## How any AI connects

### A. Local AI — Claude Code / Codex / VS Code (same PC, stdio)
The AI launches the bridge on demand. No port, no token, no always-on
server. Add to the AI's MCP config:

```json
{
  "mcpServers": {
    "instagram-posting": {
      "command": "node",
      "args": ["/path/to/instagram-mcp-bridge/dist/index.js"],
      "env": { "IG_DRY_RUN": "true" }
    }
  }
}
```

- **Claude Code:** `claude mcp add instagram-posting -- node /path/to/instagram-mcp-bridge/dist/index.js`
- **Codex:** add the same block to `~/.codex/config.toml` under `[mcp_servers.instagram-posting]`
- **VS Code / Copilot:** add it to the workspace `.vscode/mcp.json`
- **ChatGPT desktop app (if it supports MCP):** same stdio block in its
  MCP settings. ChatGPT **web chat** cannot join a local MCP directly —
  it needs the HTTP mode below (or the Codex CLI, which can).

### B. Remote AI — HTTP via Tailscale (e.g. cloud Muse)
1. On the PC, run the bridge: `node dist/index.js --http --port 8788`
   (or wake it with `wake-helper.js`).
2. Join the PC and the AI's machine to the same Tailscale network.
3. In the remote AI's MCP config, point it at:
   `http://<tailscale-ip-of-pc>:8788/mcp` with header
   `X-MCP-Token: <MCP_SECRET_TOKEN>` from `.env`.
4. Never expose port 8788 to the public internet — Tailscale only.

## How Instagram connects (one-time setup — needs Abhishek)

1. **Instagram account:** switch `@stud.playz` (or the account to post
   from) to **Business or Creator** in the Instagram app, and connect it
   to a Facebook Page.
2. **Meta App:** at https://developers.facebook.com — create an app,
   add the **Instagram Graph API** product.
3. **Permissions to request:** `instagram_basic`,
   `instagram_content_publish`, `instagram_manage_insights`,
   `pages_read_engagement`, `pages_show_list`.
4. **Get a token:** in the App Dashboard / Graph API Explorer, generate
   a **long-lived User access token** for the Page, then get the
   Instagram Business Account id — that is `IG_USER_ID`.
5. **Put them in `.env`** (copy `.env.example` to `.env` first):
   ```
   IG_USER_ID=<the instagram business account id>
   IG_ACCESS_TOKEN=<the long-lived token>
   IG_DRY_RUN=false
   ```
   Long-lived tokens expire after ~60 days — refresh and update `.env`.
   If a token ever leaks, revoke it in the Meta App Dashboard.
6. **Test safe first:** leave `IG_DRY_RUN=true`, run
   `node dist/index.js --list-tools` and call `list_posts` from your AI.
   Only set `IG_DRY_RUN=false` when you are ready for a real post —
   and only after approving the exact video + caption.

No real token exists in this repo. The code never invents one.

## Website (installer) — LIVE on GitHub Pages
The installer website is live (free, GitHub Pages, no domain needed):
**https://pratapsinghabhishek.github.io/instagram-mcp-bridge/installer-website/dist/ig-mcp-bridge-standalone.html**
— the standalone page, confirmed as the final frontend.
It is install-only: click to download, steps for Windows / Mac / Linux, a
small GUI box, and the two modes above (auto-start recommended, 5–10 MB
RAM — or on-demand On button). It states clearly that it creates a
temporary local server on the user's PC. Every user connects **their
own** Instagram with their own token — never Abhishek's. The same page
also exists as a Muse artifact ("Instagram MCP Installer"). The download
buttons now link the v1.0.0 release files (single-file programs for
Windows / macOS / Linux) with the honest warnings: Windows unsigned,
macOS not notarised, none run on a real PC yet (see INSTALL.md).

## Backend — DEPLOYED (Render + Neon, live)
`backend/` — the hosted Postgres path adds one dependency, `pg`. 40 tests
passing (plus 6 Postgres tests that run only with `DATABASE_URL` set).
See **backend/README.md** for the full contract.
- **Live:** https://ig-bridge-backend.onrender.com — `/health` returns
  `{"status":"ok","version":"1.0.0","storage":"local","db":"postgres"}`.
  Render free web service `ig-bridge-backend` (Docker, Node 24) +
  Neon free Postgres (`instagram-mcp-bridge`, ap-southeast-1, database
  `bridge`). Deployed 2026-12-03 via `render.yaml` Blueprint.
  Free-tier note: the service sleeps after 15 min idle and takes ~1 min
  to wake; nothing persistent lives on its disk.
- **One-click Instagram OAuth:** `GET /oauth/instagram/start` →
  Meta dialog → `GET /oauth/instagram/callback` exchanges the code for
  a short token, then a 60-day long-lived token, resolves the IG
  account, and delivers the token to the local installer on the user's
  PC (loopback only). The token is **never stored** in the database
  and never logged — the test suite proves it appears nowhere in the
  DB file or logs.
- **Temp media URLs:** ticket-gated `PUT /media/upload` (100 MB max,
  mp4/mov/jpg/png/webp by magic bytes), returns a public URL for the
  Graph API, auto-deletes after 24h (or right after posting). Storage
  is pluggable: local filesystem (dev default) or S3-compatible
  (Cloudflare R2 / AWS S3 via SigV4 — signing verified against the AWS
  test vector, but untested against a live bucket).
- **Database:** SQLite (`data/bridge.db`, auto-created) for local dev,
  with 3 tables — `oauth_states` (single-use CSRF state, delivery-token
  hash only), `upload_tickets` (24h, max 5 uploads), `media_files`
  (temp index), plus anonymous `download_counts` aggregates. No IG
  token, no plain IG id, no IP, no user agent is ever stored. Hosted
  deploys use Postgres instead: adapter built (`src/db-pg.js`,
  picked by `src/dbAdapter.js` when `DATABASE_URL` is set), migration
  in `migrations/001_init.postgres.sql`. Deploy target decided
  2026-12-03 and deployed the same day: **Render free web service + Neon
  free Postgres** (`render.yaml` at the repo root).
- **Hosting-ready:** `Dockerfile` included (Node 24 Alpine, non-root,
  `/health` healthcheck, `npm ci` installs `pg`). Deployed on Render
  2026-12-03; Meta App "Posting MCP Bridge" (1852127846017295) has the
  redirect URI registered. See backend/README.md for the deploy steps.
- Run locally: `cd backend && cp .env.example .env && node src/server.js`
  (`npm test` runs the 31 tests, no network, fake Meta server).

## Security — see SECURITY.md for the full launch checklist
- Tokens live in `.env` / `config.json` on the local PC only.
  `.gitignore` blocks `.env`, `config.json`, `.wake-secret`.
- **Honest gap (launch blocker):** in v1 the token is stored in plain
  text in `.env` on your own PC. It is never sent to the AI or
  uploaded anywhere, but it is not encrypted at rest yet. Before a
  public launch it must move to the OS credential store (Windows
  Credential Manager / macOS Keychain / Linux Secret Service).
  See SECURITY.md §4.
- HTTP mode requires `MCP_SECRET_TOKEN`; the wake helper requires
  `WAKE_SECRET`. Without the secret, a request does nothing.
- The bridge never logs a token. It logs only tool names, validation
  results and idle-off messages.
- Revoke any time: Meta App Dashboard → revoke the token, or delete
  `.env` and stop the bridge.

## Updates — the software must stay updatable (v1 rule)
The bridge only connects an AI to Instagram for posting today, but it
must be updatable later without rebuilding from scratch. Current version:
**1.0.0** (both `package.json` and `backend/package.json`). Rules:
- **Versioning:** semantic versioning — bump the version in both
  `package.json` files on every release, and tag the release in GitHub.
- **Backend:** push to `main` on GitHub → Render redeploys the service
  automatically (auto-deploy verified ON, "On Commit", branch `main`,
  2026-12-05). No manual deploy step.
- **Website:** push the rebuilt standalone file
  (`installer-website/dist/ig-mcp-bridge-standalone.html`) to `main` →
  GitHub Pages republishes it automatically (a few minutes).
- **Bridge on the user's PC:** no auto-update in v1. An update means
  downloading the new installer version and installing over the old
  one. The installer **must preserve** the user's `config.json`
  (startup mode) and `.env` (Instagram token) across updates — never
  wipe them, never ask the user to reconnect Instagram after an update
  unless the token itself expired. This is a hard requirement for the
  installer build, not a nice-to-have.
- **Future (after v1):** the bridge checks its own version against the
  latest GitHub release and tells the user an update is available —
  it never updates itself silently.
- **Database:** schema changes go through a new numbered migration
  (`migrations/002_*.postgres.sql`), never by editing `001` after it
  has run in production.

## Files

```
package.json / tsconfig.json
.env.example / .gitignore
wake-helper.js            tiny wake listener (no dependencies)
uninstall.html            uninstall Step 1 + Step 2 page (localhost only)
INSTALL.md                one-click installer plan (Windows / Mac / Linux)
SECURITY.md               launch security checklist (code signing = blocker)
INSTALLER-STEPS.md        steps for the installer website
scripts/package.sh        builds dist-package/ installer payload
release-v1.0.0/           v1.0.0 release files (staged; GitHub Release to be created) + MANIFEST.md
.private/                 NEVER committed: code-signing private key + GPG keyring (local only)
src/config.ts             .env / config.json loading, dry-run flag, SEA-aware bridgeDir()
src/validate.ts           size / duration / caption / schedule checks
src/instagram.ts          Meta Graph API client
src/tools.ts              the 12 MCP tools (8 posting/reading + request_uninstall + set_startup_mode + list_accounts + set_default_account)
src/startup.ts            set_startup_mode logic: confirm gate, config.json startup_mode, per-OS auto-start entries
src/uninstall.ts          one-time uninstall token + performUninstall()
src/uninstall-server.ts   serves uninstall.html on 127.0.0.1:8790
src/index.ts              stdio + HTTP entry, --help / --list-tools, idle-off
```

## License

MIT License — free, no cost. See [LICENSE](LICENSE). Copyright (c) 2026 Abhishek (pratapsinghabhishek). Anyone can use, copy, modify and share this software, but must keep the copyright notice and credit the author. No one can claim it as their own without credit.

TDQS

A3.9/5.0

Scored across 12 tools

Disambiguation4/5

Each tool targets a distinct action/resource: reads (list_accounts, list_posts, get_post_insights, get_account_insights), publishing by media type (post_reel, post_feed_image, post_story), and one-off admin actions (set_default_account, set_startup_mode, request_uninstall). The main soft spots are schedule_post vs the three post_* tools (same media, deferred time) and update_post_settings, whose name implies broad post editing but actually only toggles comments — both are clarified in the description but still invite a brief second look.

Naming Consistency5/5

Strict verb_noun snake_case throughout: get_*, list_*, post_*, schedule_*, update_*, request_*, set_*. No camelCase or style drift, and the verb choice (post_ vs schedule_ vs update_) reflects the actual semantic difference between tools.

Tool Count5/5

12 tools is a good fit for a posting bridge: 3 publish tools, 1 schedule, 4 read/insight tools, and 4 account/bridge admin tools. Nothing looks redundant or bolted on, and the deliberately absent token-paste tool is justified in the description.

Completeness4/5

Core lifecycle for its stated purpose is covered: account discovery, publish/schedule across all three Instagram formats, post listing, post- and account-level insights, plus bridge admin and a safe uninstall path. Gaps exist around engagement (no reading or replying to comments, no carousel/multi-image or single-post fetch-by-id) and scheduled posts cannot be listed/cancelled — the latter is an API limitation the description discloses, so it's a workable rather than blocking gap.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues