Instagram Direct Messages MCP server

Enables reading and sending Instagram direct messages through a Python server that authenticates with Instagram cookies and provides tools for retrieving recent conversations and sending new messages.
Back to servers
Setup instructions
Provider
Eyal Toledano
Release date
Mar 17, 2025
Language
Python
Package
Stats
1.1K downloads
12 stars

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.

Installation

Using npm (Recommended)

To install the Instagram DM MCP server:

  1. Install the package globally:
npm install -g instagram-dm-mcp
  1. Run the setup script to install required Python dependencies:
instagram-dm-mcp-setup
  1. Register the server with Claude Desktop and configure credentials:
instagram-dm-mcp install

During this step, you'll need to provide your Instagram cookies information (sessionid, csrftoken, and ds_user_id).

Instagram Authentication Options

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

Finding Your Instagram Cookies

To find your Instagram cookies:

  1. Log into Instagram on Chrome
  2. Right-click on the page and select "Inspect"
  3. Go to the "Application" tab
  4. Click on "Cookies" in the left sidebar
  5. Find and copy the values for sessionid, csrftoken, and ds_user_id

Usage

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"
    }
  }
}

Available Features

The MCP server provides these key capabilities:

  • Reading recent direct messages from your Instagram inbox
  • Sending direct messages to Instagram users
  • Health check endpoint with status information

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.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            }
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later