Send Direct Messages on Instagram Through Your LLM
MCP server sending and managing Instagram DMs from your account - messages, threads, media, and user profile lookups.
Maintainer of this project? Claim this page to edit the listing.
1.0.0Add to Favorites
Why it matters
Enable your LLM to communicate directly with Instagram users by sending direct messages programmatically, allowing for automated customer engagement, notifications, and conversational interactions on the Instagram platform.
Outcomes
What it gets done
Send direct messages to Instagram users from your LLM
Automate Instagram DM responses and notifications
Enable conversational AI interactions via Instagram messaging
Connect LLM workflows to Instagram's messaging platform
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-instagram-dm | bash Overview
Instagram DM MCP Server
An MCP server letting Claude or Cursor send Instagram DMs, manage threads and media, and look up Instagram user profiles, followers, and posts from your own account. Use when an AI assistant needs to send or manage Instagram DMs, or look up Instagram user profile data by username.
What it does
This MCP server lets Claude (or Cursor) send Instagram Direct Messages and manage DM threads directly from your own Instagram account - sending text/photo/video messages, listing and searching chats and pending inbox threads, reading and downloading message media, and looking up Instagram user info, followers, following, posts, and stories.
When to use - and when NOT to
Use it when an AI assistant needs to send or manage Instagram DMs from your account, or look up Instagram user/profile data (followers, following, posts, stories) by username. Requires Python 3.11+, Claude Desktop or Cursor, and an actual Instagram account whose credentials it authenticates with - it operates on your account directly, not via Instagram's official API.
Capabilities
Twenty-two tools. Messaging: send_message, send_photo_message, send_video_message (send text, a photo, or a video DM to a user by username). Threads: list_chats (list DM threads with optional filters/limits), list_pending_chats (threads in the pending inbox), search_threads (search threads by username or keyword), get_thread_by_participants (find a thread by participant user IDs), get_thread_details (details and messages for a specific thread by ID), and mark_message_seen. Message inspection and media: list_messages (now exposing item_type and shared post/reel info per message, to determine which download tool applies), list_media_messages (list messages containing direct-uploaded photo/video), download_media_from_message (download a direct-uploaded photo/video, not shared posts), and download_shared_post_from_message (download media from a shared post, reel, or clip, not direct uploads). User/profile lookups: get_user_id_from_username, get_username_from_user_id, get_user_info, search_users, get_user_stories, get_user_followers, get_user_following, get_user_posts, and like_media (like or unlike a post by media ID).
How to install
Clone and install dependencies (uv or pip):
git clone https://github.com/trypeggy/instagram_dm_mcp.git
cd instagram_dm_mcp
uv sync
Configure Instagram credentials via python setup_env.py (interactive) or by copying env.example to .env and setting INSTAGRAM_USERNAME/INSTAGRAM_PASSWORD (recommended over passing them as CLI args). Register in Claude Desktop's claude_desktop_config.json or Cursor's ~/.cursor/mcp.json, pointing uv run --directory PATH/TO/instagram_dm_mcp python src/mcp_server.py (or the plain python equivalent) as the mcpServers command, then restart Claude Desktop or Cursor. Session files (e.g. username_session.json) are created and reused automatically to prevent login hangs and maintain authentication between runs - the project's own troubleshooting notes point to this as the fix for Instagram login hanging. Licensed under the MIT License, and the project explicitly invites feedback on which capabilities to add next.
Who it's for
Anyone who wants Claude or Cursor to send and manage Instagram DMs, or pull Instagram profile/follower/post data, directly from their own account rather than the Instagram app.
Source README
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 install - An 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 sync - Using 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.
Usage
Below is a list of all available tools and what they do:
| Tool Name | Description |
|---|---|
send_message |
Send an Instagram direct message to a user by username. |
send_photo_message |
Send a photo as an Instagram direct message to a user by username. |
send_video_message |
Send a video as an Instagram direct message to a user by username. |
list_chats |
Get Instagram Direct Message threads (chats) from your account, with optional filters/limits. |
list_messages |
Get messages from a specific Instagram Direct Message thread by thread ID. Now exposes item_type and shared post/reel info for each message. Use this to determine which download tool to use. |
download_media_from_message |
Download a direct-uploaded photo or video from a DM message (not for shared posts/reels/clips). |
download_shared_post_from_message |
Download media from a shared post, reel, or clip in a DM message (not for direct uploads). |
list_media_messages |
List all messages containing direct-uploaded media (photo/video) in a DM thread. |
mark_message_seen |
Mark a specific message in an Instagram Direct Message thread as seen. |
list_pending_chats |
Get Instagram Direct Message threads from your pending inbox. |
search_threads |
Search Instagram Direct Message threads by username or keyword. |
get_thread_by_participants |
Get an Instagram Direct Message thread by participant user IDs. |
get_thread_details |
Get details and messages for a specific Instagram Direct Message thread by thread ID. |
get_user_id_from_username |
Get the Instagram user ID for a given username. |
get_username_from_user_id |
Get the Instagram username for a given user ID. |
get_user_info |
Get information about a specific Instagram user by username. |
search_users |
Search for Instagram users by username |
get_user_stories |
Get recent stories from a specific Instagram user by username. |
like_media |
Like or unlike a specific media post by media ID. |
get_user_followers |
Get a list of followers for a specific Instagram user by username. |
get_user_following |
Get a list of users that a specific Instagram user is following by username. |
get_user_posts |
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.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.