insta-messenger-mcp-gateway
Facilitates interaction with Instagram's direct messaging infrastructure, enabling capabilities like message retrieval, transmission, and granular thread management. Incorporates operational oversight and diverse credential handling for robust execution.
Author

taskmaster-ai
Quick Info
Actions
Tags
Instagram DM MCP Server Wrapper
This repository details an MCP (Model-Consumer Protocol) intermediary service engineered for Instagram private messaging functions, leveraging the fastmcp framework alongside the instagrapi library. This service permits advanced computational agents to read and dispatch direct messages across the Instagram platform.
Current Iteration: 1.3.5
Core Capabilities
- Acquire recent direct communications from your Instagram inbox, complete with exhaustive metadata regarding message threads.
- Formulate and dispatch direct messages to specified Instagram accounts.
- Provision of a rudimentary 'greeting' endpoint for proof-of-concept operations.
- A dedicated operational health check endpoint reporting system status.
- Robust output logging directed to
stderrto maintain integrity of structured data interchange. - Support for multiple authentication protocols, including configuration via environmental variables.
Deployment Guide
Via npm Package (Recommended Approach)
- Install the package system-wide:
npm install -g instagram-dm-mcp
- Execute the prerequisite setup routine to install Python dependencies:
instagram-dm-mcp-setup
- Integrate the service with Claude Desktop and configure necessary access tokens:
instagram-dm-mcp install
You will be prompted to input your Instagram cookie data. If unfamiliar with extraction, navigate to Instagram in Google Chrome, invoke developer tools (Inspect), select the 'Application' tab, then 'Cookies' on the left navigation pane. Extract the values corresponding to sessionid, csrftoken, and ds_user_id.
The install command automatically registers this Instagram DM MCP service with Claude Desktop and updates its configuration file. This process is set up to utilize the npx execution strategy for simplified maintenance. The resulting configuration is fully portable to Claude Desktop or any other compatible MCP client.
Access credentials can be provided through several mechanisms:
-
Utilizing command-line parameters:
bash instagram-dm-mcp install --session-id YOUR_SESSION_ID --csrf-token YOUR_CSRF_TOKEN --ds-user-id YOUR_DS_USER_ID -
Referencing a dedicated credentials file:
bash instagram-dm-mcp install --from-file /path/to/instagram_cookies.json -
Employing system environment variables (specifically
INSTAGRAM_SESSION_ID,INSTAGRAM_CSRF_TOKEN, andINSTAGRAM_DS_USER_ID)
Upon successful installation, the installer injects these credentials as environment variables into the Claude Desktop configuration, resulting in a structure similar to this:
"mcpServers": {
// existing servers...
"InstagramDM": {
"command": "npx",
"args": [
"-y",
"instagram-dm-mcp",
"start"
],
"env": {
"INSTAGRAM_SESSION_ID": "your-session-id",
"INSTAGRAM_CSRF_TOKEN": "your-csrf-token",
"INSTAGRAM_DS_USER_ID": "your-ds-user-id"
}
}
}
