Instagram Analytics MCP server

Integrates with Instagram's API and web scraping tools to enable social media analytics, account management, and content strategy insights.
Back to servers
Setup instructions
Provider
duhlink
Release date
Dec 14, 2024
Language
TypeScript
Stats
27 stars

This MCP server allows you to fetch Instagram posts using Chrome's existing login session, leveraging a Model Context Protocol implementation for standardized communication and data handling.

Installation

To get the Instagram MCP server up and running, follow these steps:

Prerequisites

  • Node.js installed on your system
  • A Chrome profile with an active Instagram login session

Setup

  1. Install the required dependencies:
npm install
  1. Build the server:
npm run build
  1. Run the server with your Chrome profile path:
CHROME_USER_DATA_DIR=/path/to/chrome/profile npm start

Replace /path/to/chrome/profile with the actual path to your Chrome user data directory that contains the Instagram login session.

Configuration

Required Environment Variables

  • CHROME_USER_DATA_DIR: Path to Chrome user data directory containing your Instagram login session

Optional Configuration

The server supports additional configuration options for:

  • Browser settings (viewport dimensions, timeouts)
  • Instagram-specific settings (delays between actions, batch sizes)
  • Save directories and file paths for downloaded media

Using the Server

The MCP server communicates using JSON-RPC 2.0 protocol. Here's how to interact with it:

Fetching Instagram Posts

You can use the get_instagram_posts tool to retrieve posts from an Instagram profile:

Parameters

  • username (required): The Instagram username to fetch posts from
  • limit (optional): Number of posts to fetch (between 1-50) or "all"
  • saveDir (optional): Directory where media files and metadata will be saved
  • delayBetweenPosts (optional): Milliseconds to wait between processing posts

Example Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "call_tool",
  "params": {
    "name": "get_instagram_posts",
    "arguments": {
      "username": "example",
      "limit": 10
    }
  }
}

This request will fetch 10 most recent posts from the Instagram user "example".

Error Handling

The server provides standardized error responses:

  • INVALID_REQUEST: Your request format or parameters are invalid
  • INVALID_PARAMS: Required parameters are missing or invalid
  • METHOD_NOT_FOUND: The requested method or tool doesn't exist
  • INTERNAL_ERROR: Server-side errors occurred during processing

When an error occurs, you'll receive a standard JSON-RPC error response with details about what went wrong.

Advanced Usage

Media Handling

The server automatically downloads media files from Instagram posts and organizes them in the specified save directory. This includes:

  • Images and videos from posts
  • Carousel items (multiple images/videos in a single post)
  • Post metadata in JSON format

SEO-Friendly Descriptions

The server generates SEO-friendly descriptions for each post based on captions and content, which can be useful for indexing or displaying the content elsewhere.

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 "instagram-server-next-mcp" '{"command":"npx","args":["-y","instagram-server-next-mcp"]}'

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": {
        "instagram-server-next-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "instagram-server-next-mcp"
            ]
        }
    }
}

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": {
        "instagram-server-next-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "instagram-server-next-mcp"
            ]
        }
    }
}

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