This MCP server enables AI assistants to interact with Instagram direct messages, allowing them to read and send messages through the Instagram platform. It uses the Model-Consumer Protocol (MCP) with fastmcp and instagrapi libraries to provide this functionality.
To install the Instagram DM MCP server:
npm install -g instagram-dm-mcp
instagram-dm-mcp-setup
instagram-dm-mcp install
During this step, you'll need to provide your Instagram cookies information (sessionid, csrftoken, and ds_user_id).
You can provide your Instagram credentials in several ways:
Command-line arguments:
instagram-dm-mcp install --session-id YOUR_SESSION_ID --csrf-token YOUR_CSRF_TOKEN --ds-user-id YOUR_DS_USER_ID
Using a credentials file:
instagram-dm-mcp install --from-file /path/to/instagram_cookies.json
Using environment variables:
Set INSTAGRAM_SESSION_ID
, INSTAGRAM_CSRF_TOKEN
, and INSTAGRAM_DS_USER_ID
in your environment
To find your Instagram cookies:
sessionid
, csrftoken
, and ds_user_id
After installation, the Instagram DM MCP server will be registered with Claude Desktop with a configuration similar to:
"mcpServers": {
"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"
}
}
}
The MCP server provides these key capabilities:
When connected to an AI assistant like Claude, you can ask it to read your recent Instagram messages or send messages to specific users, and the assistant will use this MCP server to perform those actions.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "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"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"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"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"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"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect