Instagram MCP Server

Instagram MCP Server

A server that allows fetching Instagram posts using Chrome's existing login session via Model Context Protocol (MCP).

duhlink

Browser Automation
Social Media
Local
TypeScript
Visit Server

Tools

get_instagram_posts

Get recent posts from an Instagram profile using existing Chrome login

README

Instagram MCP Server

A Model Context Protocol (MCP) server for fetching Instagram posts using Chrome's existing login session.

Features

  • Modular architecture with clear separation of concerns
  • Type-safe implementation using TypeScript
  • Improved error handling and logging
  • Configurable through environment variables
  • JSON-RPC 2.0 compliant communication
  • Automatic media downloading and metadata generation
  • SEO-friendly description generation

Architecture

The server follows a modular architecture with the following structure:

src/
├── core/                      # Core MCP functionality
│   ├── mcp/                  # MCP server implementation
│   │   ├── server.ts        # Server class
│   │   ├── stdio.ts         # StdioServerTransport
│   │   └── index.ts         # Barrel exports
│   ├── types/               # Core type definitions
│   │   └── mcp.ts          # MCP types
│   └── utils/               # Utility functions
│       ├── config.ts        # Configuration management
│       └── errors.ts        # Error handling
├── features/                 # Feature modules
│   └── instagram/           # Instagram feature
│       ├── types.ts         # Instagram types
│       ├── utils/           # Feature utilities
│       │   ├── media.ts     # Media handling
│       │   ├── post.ts      # Post processing
│       │   └── seo.ts       # SEO generation
│       └── instagram.service.ts # Instagram service
├── services/                 # Shared services
│   └── browser/             # Browser service
│       ├── types.ts         # Browser types
│       └── browser.service.ts # Browser service
├── index.ts                 # Entry point
└── server.ts                # Main server class

Configuration

The server requires the following environment variables:

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

Additional configuration options are available through the config manager:

  • Browser settings (viewport, timeouts)
  • Instagram settings (delays, batch sizes)
  • Save directory and file paths

Usage

  1. Install dependencies:

    npm install
    
  2. Build the server:

    npm run build
    
  3. Run the server:

    CHROME_USER_DATA_DIR=/path/to/chrome/profile npm start
    

Available Tools

get_instagram_posts

Fetches recent posts from an Instagram profile.

Parameters:

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

Example:

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

Error Handling

The server uses standardized error codes and messages:

  • INVALID_REQUEST: Invalid request format or parameters
  • INVALID_PARAMS: Missing or invalid parameters
  • METHOD_NOT_FOUND: Unknown method or tool
  • INTERNAL_ERROR: Server-side errors

Development

  1. Start in development mode:

    npm run dev
    
  2. Run linter:

    npm run lint
    

Improvements Over Original

  1. Modular Architecture

    • Clear separation of concerns
    • Better code organization
    • Easier to maintain and extend
  2. Type Safety

    • Comprehensive TypeScript types
    • Better error catching
    • Improved IDE support
  3. Error Handling

    • Standardized error codes
    • Better error messages
    • Proper error propagation
  4. Configuration

    • Centralized configuration
    • Environment variable validation
    • Type-safe config access
  5. Code Quality

    • Consistent coding style
    • Better documentation
    • Improved logging
  6. Testing Support

    • Modular design enables testing
    • Dependency injection ready
    • Clear interfaces

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Excel MCP Server

Excel MCP Server

A Model Context Protocol server that enables AI assistants to read from and write to Microsoft Excel files, supporting formats like xlsx, xlsm, xltx, and xltm.

Featured
Local
Go
Playwright MCP Server

Playwright MCP Server

Provides a server utilizing Model Context Protocol to enable human-like browser automation with Playwright, allowing control over browser actions such as navigation, element interaction, and scrolling.

Featured
Local
TypeScript
@kazuph/mcp-fetch

@kazuph/mcp-fetch

Model Context Protocol server for fetching web content and processing images. This allows Claude Desktop (or any MCP client) to fetch web content and handle images appropriately.

Featured
Local
JavaScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
Apple MCP Server

Apple MCP Server

Enables interaction with Apple apps like Messages, Notes, and Contacts through the MCP protocol to send messages, search, and open app content using natural language.

Featured
Local
TypeScript
DuckDuckGo MCP Server

DuckDuckGo MCP Server

A Model Context Protocol (MCP) server that provides web search capabilities through DuckDuckGo, with additional features for content fetching and parsing.

Featured
Python
contentful-mcp

contentful-mcp

Update, create, delete content, content-models and assets in your Contentful Space

Featured
TypeScript