Instagram DM MCP server
Provides tools for interacting with Instagram, including sending direct messages (text, photo, and video), listing and searching chats and messages, downloading media from messages, marking messages as seen, retrieving user information, stories, followers, following, and posts, and liking media.
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 DM MCP serversend an Instagram DM to @sarah saying 'happy birthday!'"
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 DM MCP server
This is a Model Context Protocol (MCP) server for sending instagram Direct Messages.
With this you can send Instagram Direct Messages from your account (more capabilities coming soon).
Here's an example of what you can do when it's connected to Claude.
https://github.com/user-attachments/assets/9c945f25-4484-4223-8d6b-5bf31243464c
To get updates on this and other projects we work on enter your email here
Installation
Prerequisites
Python 3.11+
Anthropic Claude Desktop app (or Cursor)
Pip (Python package manager), install with
python -m pip installAn instagram account
Steps
Clone this repository
git clone https://github.com/trypeggy/instagram_dm_mcp.git cd instagram_dm_mcpInstall dependencies
Using uv (recommended):
uv syncUsing Pip:
pip install -r requirements.txt
Configure Instagram credentials
You have two options for providing your Instagram credentials:
Option A: Environment Variables (Recommended)
Quick Setup (Recommended):
Run the helper script:
python setup_env.pyThis will interactively prompt you for your credentials and create the
.envfile securely.Manual Setup:
Create a
.envfile in the project root:cp env.example .envThen edit
.envwith your actual credentials:INSTAGRAM_USERNAME=your_instagram_username INSTAGRAM_PASSWORD=your_instagram_passwordOption B: Command Line Arguments
You can still pass credentials as command line arguments (less secure).
Connect to the MCP server
For Claude Desktop:
Save this as
claude_desktop_config.jsonin your Claude Desktop configuration directory at:~/Library/Application Support/Claude/claude_desktop_config.jsonFor Cursor:
Save this as
mcp.jsonin your Cursor configuration directory at:~/.cursor/mcp.jsonConfiguration with Environment Variables (Recommended):
Using uv
{ "mcpServers": { "instagram_dms": { "command": "uv", "args": [ "run", "--directory", "PATH/TO/instagram_dm_mcp", "python", "src/mcp_server.py" ] } } }Using Python
{ "mcpServers": { "instagram_dms": { "command": "python", "args": [ "{{PATH_TO_SRC}}/instagram_dm_mcp/src/ mcp_server.py" ] } } }Configuration with Command Line Arguments:
{ "mcpServers": { "instagram_dms": { "command": "python", "args": [ "{{PATH_TO_SRC}}/instagram_dm_mcp/src/mcp_server.py", "--username", "{{YOUR_INSTAGRAM_USERNAME}}", "--password", "{{YOUR_INSTAGRAM_PASSWORD}}" ] } } }Restart Claude Desktop / Cursor
Open Claude Desktop and you should now see the Instagram DM MCP as an available integration.
Or restart Cursor.
Related MCP server: mcp-instagram-dm
Usage
Below is a list of all available tools and what they do:
Tool Name | Description |
| Send an Instagram direct message to a user by username. |
| Send a photo as an Instagram direct message to a user by username. |
| Send a video as an Instagram direct message to a user by username. |
| Get Instagram Direct Message threads (chats) from your account, with optional filters/limits. |
| Get messages from a specific Instagram Direct Message thread by thread ID. Now exposes |
| Download a direct-uploaded photo or video from a DM message (not for shared posts/reels/clips). |
| Download media from a shared post, reel, or clip in a DM message (not for direct uploads). |
| List all messages containing direct-uploaded media (photo/video) in a DM thread. |
| Mark a specific message in an Instagram Direct Message thread as seen. |
| Get Instagram Direct Message threads from your pending inbox. |
| Search Instagram Direct Message threads by username or keyword. |
| Get an Instagram Direct Message thread by participant user IDs. |
| Get details and messages for a specific Instagram Direct Message thread by thread ID. |
| Get the Instagram user ID for a given username. |
| Get the Instagram username for a given user ID. |
| Get information about a specific Instagram user by username. |
| Search for Instagram users by username |
| Get recent stories from a specific Instagram user by username. |
| Like or unlike a specific media post by media ID. |
| Get a list of followers for a specific Instagram user by username. |
| Get a list of users that a specific Instagram user is following by username. |
| Get recent posts from a specific Instagram user by username. |
Troubleshooting
Instagram Login Hanging: The server now includes automatic session management to prevent login hangs. Session files (e.g., username_session.json) are automatically created and reused to maintain authentication state between runs.
For additional Claude Desktop integration troubleshooting, see the MCP documentation. The documentation includes helpful tips for checking logs and resolving common issues.
Feedback
Your feedback will be massively appreciated. Please tell us which features on that list you like to see next or request entirely new ones.
License
This project is licensed under the MIT License.
This server cannot be deployed
Maintenance
Related MCP Connectors
- cloziqOAuthcom.cloziq
Create your offers and launch AI Instagram DM sales agents from any MCP client, over OAuth.
Create, schedule, and publish social posts, manage accounts, and read analytics as MCP tools.
Hosted MCP for Instagram, Facebook, X, LinkedIn, Pinterest, and Ghost. OAuth 2.1, 38 tools.
Unified messaging MCP server: WhatsApp, Instagram, Telegram, SMS, Messenger & email support inbox
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to read, send, and manage Instagram direct messages, including viewing conversations, sending DMs to users, reacting to messages, and searching for users by username.10-
- AlicenseNot gradedqualityDmaintenanceMCP server for Instagram Direct Messages. Read inbox, send messages, search conversations, react to messages, manage pending requests, and more. 15 tools with cookie-based authentication.55 npm4MIT
- 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
- AlicenseNot gradedqualityDmaintenanceExposes Instagram actions (posts, media, comments, DMs, insights, Messenger profile) to Claude and ChatGPT via MCP.MIT