Enables reading and sending Instagram Direct Messages, including listing conversations, retrieving message history, sending messages to threads or users by username, adding emoji reactions, and searching for users.
Instagram DMs MCP
A Model Context Protocol (MCP) server that lets AI assistants read and send Instagram DMs.
Features
π₯ Get Inbox - List all DM conversations with previews
π¬ Read Messages - Get full message history from any thread
βοΈ Send Messages - Send text messages to existing threads
π Start Conversations - DM any user by username
β€οΈ React to Messages - Add emoji reactions
π€ User Lookup - Search for users by username
Quick Start
1. Get Your Instagram Cookies
Go to instagram.com and log in, then:
Open DevTools (F12 or Cmd+Option+I)
Go to Application tab β Cookies β
https://www.instagram.comFind and copy these cookie values:
Cookie | Required |
| β Yes |
| β Yes |
| β Yes |
| Optional |
| Optional |
| Optional |
Paste into console to generate JSON (replace with YOUR values):
This copies the JSON to your clipboard.
Why manual? Instagram marks
sessionidas HttpOnly, so JavaScript can't read it directly. You need to copy it from the Application tab.
2. Save Your Cookies
Create the config directory and save your cookies:
Your cookies.json should look like:
3. Build & Run
The MCP server will be available at http://localhost:8000/mcp
Connecting to Poke
Add a new MCP integration
Enter your MCP server URL:
http://your-server:8000/mcp
Available Tools
Tool | Description |
| Check connection status and get your username |
| List all DM conversations |
| Get messages from a specific thread |
| Send a message to a thread |
| Send a DM to a user by username |
| React to a message with an emoji |
| Look up a user by username |
| Get info about a user by ID |
| Mark a conversation as read |
Example Usage
Once connected to Poke, you can ask things like:
"Check my Instagram DMs"
"What are my recent Instagram messages?"
"Send a message to @username saying hello"
"React to that last message with β€οΈ"
Architecture
MCP Server (Python/FastMCP): Handles the MCP protocol and exposes tools
IG Gateway (Go/messagix): Handles Instagram's web API using session cookies
Development
Running Components Separately
Gateway only:
MCP Server only:
Environment Variables
Variable | Default | Description |
|
| Gateway address for MCP server |
|
| Path to cookies file |
|
| MCP server port |
Deployment
Using Render
Fork this repository
Create a new web service on Render
Connect your forked repository
Set the environment variables:
IG_COOKIES_FILE: Path to your cookies (you'll need to handle this securely)
Deploy
Note: For production deployments, you'll need to run the Go gateway separately or include it in your build process.
Troubleshooting
"Could not connect to gateway"
Make sure the gateway is running:
./gateway/ig-gatewayCheck that port 29391 is available
"No cookies file found"
Create
~/.instagram-dms-mcp/cookies.jsonwith your Instagram cookiesOr set the
IG_COOKIES_FILEenvironment variable
"Gateway failed to start"
Check if your cookies are valid (try logging into Instagram web again)
Instagram session cookies expire periodically - you may need to refresh them
Session expired
If your session expires, simply:
Log into Instagram web again
Run the cookie extraction script
Update your
cookies.jsonRestart the gateway
Security Notes
β οΈ Important: Your cookies.json contains your Instagram session. Keep it secure:
Never commit it to version control
Don't share it with anyone
Consider the security implications of self-hosting
Credits
This project uses:
License
MIT