home / mcp / instagram dm mcp server
Instagram Direct messages MCP
Configuration
View docs{
"mcpServers": {
"trypeggy-instagram_dm_mcp": {
"command": "uv",
"args": [
"run",
"--directory",
"PATH/TO/instagram_dm_mcp",
"python",
"src/mcp_server.py"
]
}
}
}This MCP server lets you send Instagram Direct Messages from your account and manage DMs from an MCP client or Claude/Cursor integration. It exposes a set of actions to read chats, fetch messages, send text, images, and videos, and manage media in DMs, making it easier to automate Instagram messaging tasks from your preferred client.
You connect the Instagram DM MCP server to your MCP client (such as Claude Desktop or Cursor) to perform common Instagram Direct Message actions. You can send messages and media, list chats and messages, download media from DMs, and manage conversations directly from your MCP workflow. Start by configuring credentials so the server can access your Instagram account, then run the MCP server locally or expose it through your MCP client as an integration. Once connected, use the available tool endpoints to interact with your DMs in real time.
Prerequisites: Install Python 3.11 or newer, ensure Pip is available, and have an Instagram account. You can also run the MCP server through uv (uv is recommended) or via a direct Python command.
# 1. Clone the project
git clone https://github.com/trypeggy/instagram_dm_mcp.git
cd instagram_dm_mcp
# 2. Install dependencies
# Using uv (recommended)
uv sync
# Or using Pip
pip install -r requirements.txtConfigure your Instagram credentials. You may provide credentials via environment variables or as command line arguments. A quick interactive setup can create a secure .env file for you, or you can manually create and edit the .env file in the project root.
Option A: Environment Variables (Recommended) — Quick Setup:
python setup_env.pyOption A cont'd — Manual Setup (if you prefer): create a .env file and fill in your credentials.
cp env.example .env
```
```
INSTAGRAM_USERNAME=your_instagram_username
INSTAGRAM_PASSWORD=your_instagram_passwordOption B: Command Line Arguments (less secure): supply credentials directly when starting the server.
Connect to the MCP server from Claude Desktop or Cursor. Use the provided configuration snippets to integrate the MCP server into your client.
For Claude Desktop: Save the following configuration as claude_desktop_config.json in your Claude Desktop configuration directory.
For Cursor: Save the following configuration as mcp.json in your Cursor configuration directory.
Configuration with Environment Variables (Recommended): Using uv
{
"mcpServers": {
"instagram_dms": {
"command": "uv",
"args": [
"run",
"--directory",
"PATH/TO/instagram_dm_mcp",
"python",
"src/mcp_server.py"
]
}
}
}Configuration with Python
{
"mcpServers": {
"instagram_dms": {
"command": "python",
"args": [
"{{PATH_TO_SRC}}/instagram_dm_mcp/src/ mcp_server.py"
]
}
}
}Configuration with Command Line Arguments (start the server with your credentials):
{
"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 or Cursor after adding the configuration. You should then see the Instagram DM MCP as an available integration.
Environment management and session handling improve reliability. Session files (for example, username_session.json) are created and reused to maintain authentication state between runs.
If you need more troubleshooting assistance with the MCP integration, check the MCP-related guidance for your client and verify that the server is running and reachable from your client.
If you encounter issues with Instagram login hanging, ensure your session management is functioning and that credentials are correct. Restart the MCP server and client after updating credentials or environment settings.
Share your experience and request new features. Your input helps shape future improvements to the Instagram DM MCP server.
This project is licensed under the MIT License.
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. Exposes item_type and shared post/reel info for each message.
Download a direct-uploaded photo or video from a DM message.
Download media from a shared post, reel, or clip in a DM message.
List all messages containing direct-uploaded media 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 a DM thread by participant user IDs.
Get details and messages for a specific DM 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.