Instagram Relationship MCP
Provides tools to connect to an Instagram account, check connection status, retrieve a list of accounts you follow that do not follow you back, and disconnect.
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., "@Instagram Relationship MCP Which accounts do I follow that don't follow me back?"
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 Relationship MCP
A local MCP server that answers one question for an Instagram account you control:
Which accounts do I follow that do not follow me back?
The server is read-only toward Instagram. It can sign in through a dedicated Playwright Chromium profile, read relationship data, cache derived results locally, and disconnect. It cannot follow, unfollow, block, like, comment, or send messages.
This project uses Instagram's private, unsupported Web API rather than Meta's supported Instagram Graph API. Instagram can change these endpoints without notice. Unknown response shapes fail closed withPRIVATE_API_CHANGED, and rate limits stop the scan. Use only an account you control and comply with Instagram's terms and policies.
How it works
Instagram
↑ dedicated authenticated browser profile
Playwright persistent Chromium context
↑ same-origin private Web API requests
InstagramWebAdapter
↑ normalized relationship records only
RelationshipService + local derived cache
↑ business-level MCP results
ChatGPT Work, Codex, or another MCP clientInstagram credentials are entered only in the visible instagram.com browser window. Passwords, cookies, CSRF tokens, request headers, and browser storage are never accepted as MCP arguments or returned in tool results.
Related MCP server: Insta MCP Server
Requirements
Windows 10/11 for the commands shown below. The Node server itself is portable, but the Secure Tunnel walkthrough is Windows/PowerShell focused.
A graphical desktop session for Instagram login, 2FA, and challenges
An Instagram account you control
One connection option:
ChatGPT Work with OpenAI Secure MCP Tunnel, or
a local MCP client that can launch a stdio server
This package is installed from source; it is not published to npm.
Install
Open PowerShell and run:
git clone https://github.com/rankes96-dev/instagram-relationship-mcp.git
Set-Location instagram-relationship-mcp
npm ci
npm run browser:install
npm run build
npm run checknpm ci installs the exact versions in package-lock.json. Playwright is pinned because every Playwright release expects matching browser binaries. Run npm run browser:install again after changing or updating Playwright.
Choose how to connect
Option A: ChatGPT Work through Secure MCP Tunnel
Use this path to keep the MCP server on your computer while making it available to a ChatGPT developer-mode app. Secure MCP Tunnel uses an outbound HTTPS connection; it does not require a public MCP port or inbound firewall rule.
1. Prepare OpenAI access
Create or inspect a tunnel in OpenAI Platform tunnel settings.
Associate the tunnel with both the Platform organization that owns it and the target ChatGPT workspace. A tunnel associated only with a Platform organization may not appear in ChatGPT Work.
Ensure the operator has the correct Platform permissions:
Tunnels Read + Manage to create or edit tunnels.
Tunnels Read + Use to run
tunnel-clientand select the tunnel in ChatGPT.
Ensure Developer mode is allowed by the ChatGPT workspace policy. In ChatGPT, enable it under Settings → Security and login → Developer mode.
Create a dedicated runtime API key for a user or service account whose Platform organization role has Tunnels Read + Use. Restrict the key where supported. Do not use an admin key for the long-running tunnel process.
See OpenAI's Secure MCP Tunnel guide for the current permission and workspace-association model.
2. Install tunnel-client
Download the correct Windows archive from the latest official tunnel-client release, extract it, and place tunnel-client.exe on PATH. Do not hard-code a release URL in an operational runbook.
Verify the binary:
tunnel-client --version
tunnel-client help quickstart3. Create and validate a local stdio profile
From the repository directory, set the runtime key only in the current PowerShell process and initialize a named profile. Replace the placeholders; never commit the real key or tunnel ID.
$env:CONTROL_PLANE_API_KEY = "<restricted-runtime-api-key>"
$repo = (Resolve-Path .).Path
$mcpCommand = "node `"$repo\scripts\tunnel-mcp-entry.mjs`""
tunnel-client init `
--sample sample_mcp_stdio_local `
--profile instagram-relationships `
--tunnel-id "tunnel_<32-lowercase-hex-characters>" `
--mcp-command $mcpCommand
tunnel-client doctor --profile instagram-relationships --explain
tunnel-client run --profile instagram-relationshipsKeep tunnel-client run running while ChatGPT uses the app. Its local /ui, /healthz, /readyz, and /metrics surfaces show runtime health; the startup output prints the loopback URL.
The tunnel profile must launch scripts/tunnel-mcp-entry.mjs, not dist/index.js directly. The wrapper removes OpenAI control-plane keys before importing the Instagram MCP server, so the Instagram subprocess does not inherit them. Prefer CONTROL_PLANE_API_KEY; OPENAI_API_KEY is only a tunnel-client fallback.
The Instagram server does not load .env automatically. Never put plaintext API keys in a tunnel profile or YAML file; use an env: reference, keep generated profiles outside Git (or ignored), and do not expose keys in command arguments or logs.
4. Add the tunnel in ChatGPT Work
Open ChatGPT Plugins.
Select the plus button and enter a user-facing name and description.
Under Connection, choose Tunnel.
Select the tunnel or paste its
tunnel_id.Create the connection and review the four discovered tools.
Start a new chat and add the connection from the tools menu.
After changing tool names, descriptions, schemas, or annotations, restart the tunnel-backed MCP server, open the connection in ChatGPT Plugins, select Refresh, and test in a new chat.
Option B: local stdio MCP client
For Codex or another local MCP client, build the project and configure the client with absolute paths:
{
"mcpServers": {
"instagram-relationships": {
"command": "node",
"args": [
"C:\\absolute\\path\\to\\instagram-relationship-mcp\\dist\\index.js"
]
}
}
}A complete example is available at docs/mcp-config.example.json.
The transport is stdio. The server does not bind a port. Standard output is reserved for MCP JSON-RPC; sanitized operational logs go only to standard error.
First login and first scan
Use this sequence in ChatGPT or your MCP client:
Call
instagram_connect.If it returns
LOGIN_PENDING, complete Instagram login, 2FA, or a challenge only in the visibleinstagram.comChromium window.Call
instagram_connection_statusuntil it returnsCONNECTED.CHALLENGE_REQUIREDmeans the visible window still needs action.Call
instagram_get_non_followers.
Never enter an Instagram password, cookie, session ID, CSRF token, or 2FA code into ChatGPT or an MCP tool argument. If a saved session is still valid, instagram_connect may return connected: true without opening a window.
MCP tools
instagram_connect
Reuses a verified saved session or opens one visible Chromium window and returns promptly with LOGIN_PENDING. Repeated calls while login is pending reuse the same attempt rather than opening another browser.
instagram_connection_status
Performs one bounded session check. It can return CONNECTED, LOGIN_PENDING, NOT_CONNECTED, SESSION_EXPIRED, LOGIN_REQUIRED, or CHALLENGE_REQUIRED. Once interactive login succeeds, it confirms that the saved profile also works in the background before reporting CONNECTED.
instagram_get_non_followers
Fetches Following pages, deduplicates numeric Instagram user IDs, checks relationship statuses in bounded batches, and returns only users with explicit followed_by === false status.
Inputs:
refresh(optional boolean): ignore a fresh derived cache and scan again.limit(optional integer, 1–100): number of users to return; default 50.cursor(optional string): opaque signed cursor returned by the previous page. Do not combine it withrefresh: true.
The result states whether it came from live or cache, when it was computed, whether the scan is complete, and how many statuses remain UNKNOWN. A partial fetch is never presented as a complete result.
instagram_disconnect
Closes Chromium, securely removes the dedicated browser profile, and purges local account metadata and cached relationship data. The next Instagram operation requires manual login again.
Configuration
All settings are optional. Supply them through the MCP client's environment or the operating system. The server does not load .env automatically.
Variable | Default | Allowed values |
|
| Absolute local directory |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See .env.example as an environment-variable reference only; copying it to .env has no effect. Put values in the MCP client's env block or set them in the process that launches the server, for example:
$env:INSTAGRAM_MCP_LOG_LEVEL = "debug"
npm startBatch sizes are runtime settings, not claimed Instagram API limits.
Local data and security
By default, data is stored outside the repository:
%LOCALAPPDATA%\InstagramRelationshipMcp\
├── instagram-profile\
└── instagram.dbThe dedicated browser profile contains Instagram authentication state. The SQLite database stores only account metadata, normalized users, and derived relationship scans. Do not point INSTAGRAM_MCP_DATA_DIR at your normal Chrome profile, this repository, a synchronized folder, or a shared directory.
Never commit or share:
.envor runtime API keystunnel IDs or tunnel-client profiles
the Playwright browser profile
SQLite database, WAL, or SHM files
cookies, headers, HAR files, screenshots, or network dumps
tunnel or MCP logs containing private account context
The included .gitignore excludes these local artifacts, but ignore rules are not an access-control boundary. See SECURITY.md for the threat model and safe diagnostics policy.
Update
Stop the foreground tunnel process, then run:
git pull
npm ci
npm run browser:install
npm run check
tunnel-client run --profile instagram-relationshipsThe browser profile and database live outside the repository and survive source updates unless instagram_disconnect is called. Refresh the ChatGPT developer-mode connection after MCP metadata changes.
Development
npm run build
npm test
npm run smoke:mcp
npm run check
npm run inspectnpm run checkbuilds the project, runs every test, and runs the stdio smoke test.npm run smoke:mcpbuilds and verifies both legacy stdio and MCP 2026-07-28 without opening a browser.Run
npm run buildbeforenpm run inspect; the Inspector usesdist/index.js.Browser and live-account scenarios require manual testing with an account you control. Automated tests use sanitized synthetic fixtures and contain no production credentials or usernames.
Troubleshooting
The tunnel is not visible in ChatGPT
Confirm that the tunnel is associated with the target ChatGPT workspace—not only a Platform organization—and that the app creator has Tunnels Read + Use. Developer mode must also be permitted by workspace policy.
ChatGPT cannot discover or call tools
Keep tunnel-client run --profile instagram-relationships running, then execute:
tunnel-client doctor --profile instagram-relationships --explainCheck the loopback /ui and ensure health, readiness, and the main MCP channel are green. If metadata is stale, refresh the connection in ChatGPT Plugins and start a new chat.
No Instagram window opens
Run npm run browser:install, confirm a graphical desktop session is active, and call instagram_connect again. A valid saved session may intentionally connect without a visible window.
The result remains LOGIN_PENDING
Finish the visible browser flow, then call instagram_connection_status. Do not repeatedly start new connections. If the browser was closed, call instagram_connect once to start a fresh attempt.
Instagram reports a rate limit or private API change
Stop and wait after INSTAGRAM_RATE_LIMITED; do not retry aggressively. PRIVATE_API_CHANGED means the expected private response contract no longer matches and requires a reviewed code update, not a guessed parser fallback.
Licensing and reference boundary
No software license is currently included. Source availability on GitHub does not grant an open-source reuse license.
IG-Cleaner was reviewed only for the general idea of manual local login and a dedicated persistent browser profile. This is a clean-room implementation and does not copy IG-Cleaner's Selenium, DOM-scrolling, username-comparison, or write-action design.
Available Tools
4 toolsinstagram_connectConnect InstagramAIdempotent
Use this when the user wants to connect Instagram or resume an unfinished local login. It reuses a verified saved session; otherwise it opens the dedicated local Chromium profile and returns immediately with LOGIN_PENDING. Credentials, 2FA, and challenge responses must be entered only on instagram.com; then use instagram_connection_status.
Inputs: no named parameters. Returns: object
instagram_connection_statusInstagram Connection StatusAIdempotent
Use this when the user wants to check whether Instagram is connected, especially after instagram_connect returned LOGIN_PENDING. It reports the current login or session state and never asks for credentials.
Inputs: no named parameters. Returns: object
instagram_disconnectDisconnect InstagramADestructiveIdempotent
Closes Chromium and permanently deletes the dedicated Instagram browser profile plus locally derived account and relationship data.
Inputs: no named parameters. Returns: object
instagram_get_non_followersGet Instagram Non-FollowersA
Returns accounts the connected user follows that explicitly do not follow the user back. Fetches a complete Following list before classification, reports unknown statuses, caches normalized results locally, and paginates MCP output.
Inputs: limit, cursor, refresh. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct role: connect initiates login, status checks login state, get_non_followers performs the main analysis, and disconnect cleans up. There is no overlap or ambiguity between them.
All tools share the 'instagram_' prefix, but the verb usage is slightly inconsistent: 'connect' and 'disconnect' are bare verbs, 'connection_status' is a noun phrase, and 'get_non_followers' uses a get_ prefix. Overall the pattern is readable and predictable.
With 4 tools, the server is well-scoped for its specific purpose of managing Instagram relationships. Each tool is necessary and none feel redundant.
The set covers the full lifecycle from connect to disconnect, with the core non-follower analysis in between. Minor gaps exist, such as no explicit refresh action or follow/unfollow operations, but these are outside the stated purpose.
Related MCP Connectors
Hosted Instagram MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted MCP server for DataLikers — Instagram & TikTok data API. 51 tools: Instagram user search by demographics (gender/age/race/country/city), profiles, bulk lookup, engagement, posts & reels, comments, hashtags, locations, stories, highlights, music, business accounts, top users; TikTok users, videos, comments, hashtags, playlists and top charts. Streamable HTTP, Bearer API key. Free tier: 100 requests on signup at https://datalikers.com/p/1by27bwg
Instagram data over MCP: profiles, posts, reels, stories, highlights and search as JSON
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- FlicenseBqualityDmaintenanceA server that allows fetching Instagram posts using Chrome's existing login session via Model Context Protocol (MCP).151-
- AlicenseAqualityBmaintenanceMCP server that enables integration with Instagram, allowing interaction with Instagram features through the Model Context Protocol.1518 npm9MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that wraps instagrapi to read, engage, and send DMs from a personal Instagram account, supporting 24 tools for auth, profile, engagement, and messages.MIT
- AlicenseBqualityCmaintenanceA professional, full-fidelity MCP server enabling AI agents to fully control and manage an Instagram account exactly like a human user.685MIT