# MCP server (Claude, Cursor, VS Code, Codex)

> Connect Claude Code, Claude Desktop, Cursor, VS Code Copilot, Codex, Windsurf or Gemini CLI to Instagram data with the hosted Klupt MCP server. Newest-first followers and following, profiles, posts and more. Same key and price as the REST API.

The Klupt API has a **hosted MCP server** at `https://api.klupt.io/mcp`. Add it to your AI assistant and ask in plain words: *"Who did @natgeo follow most recently?"*, *"Show the newest followers of @nasa"*, *"Get the last 5 reels of @bbcnews with views"*. The assistant calls the Klupt tools and answers from live public Instagram data.

- **URL:** `https://api.klupt.io/mcp` (streamable HTTP, stateless; no install, nothing runs on your machine)
- **Auth:** your Klupt API key in `X-Api-Key: kd_live_…` or `Authorization: Bearer kd_live_…` ([get a key](/signup))
- **Price:** the same as the REST API. Each tool call is one API call: 1 credit (2 for a following page of about 200 accounts), from $2.00 per 1,000 credits, nothing for a cache hit or an error; +1 when a username has to be looked up, so let the assistant pass numeric ids ([Pricing](/pricing))
- **Sandbox:** a `kd_test_…` key returns sample data at no cost. Start with one to try the setup.
- **Public accounts only.** Every answer carries `meta.credits_charged` and `meta.credits_remaining`, so the assistant can tell you what a question cost.

Tool calls share your account's [rate limits](/docs/rate-limits), credit balance and per-key monthly caps with your REST calls, and show up in your dashboard usage like any other request.

## Claude Code

```bash
claude mcp add --transport http klupt https://api.klupt.io/mcp \
  --header "X-Api-Key: $KLUPT_API_KEY" --scope user
```

`--scope user` makes it available in every project. To share it with a team in a repository, put it in `.mcp.json` and let each person set `KLUPT_API_KEY` in their environment:

```json
{
  "mcpServers": {
    "klupt": {
      "type": "http",
      "url": "https://api.klupt.io/mcp",
      "headers": { "X-Api-Key": "${KLUPT_API_KEY}" }
    }
  }
}
```

Then ask: *"Use klupt to list the 20 accounts @natgeo followed most recently."* Type `/mcp` in Claude Code to check the connection.

## Claude Desktop and claude.ai

**Custom connector** (where your plan offers request headers): Settings → Connectors → **Add custom connector**, URL `https://api.klupt.io/mcp`, authentication **No sign-in**, then under **Request headers** add `x-api-key` with your key (or `authorization` with `Bearer kd_live_…`).

**Config file** (works on every plan, needs Node.js): add this to `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/`, Windows: `%APPDATA%\Claude\`) and restart Claude Desktop. It runs the open-source `mcp-remote` bridge, which forwards to our hosted server.

```json
{
  "mcpServers": {
    "klupt": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://api.klupt.io/mcp", "--header", "X-Api-Key:${KLUPT_API_KEY}"],
      "env": { "KLUPT_API_KEY": "kd_live_your_key" }
    }
  }
}
```

## Cursor

`~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project):

```json
{
  "mcpServers": {
    "klupt": {
      "url": "https://api.klupt.io/mcp",
      "headers": { "X-Api-Key": "${env:KLUPT_API_KEY}" }
    }
  }
}
```

## VS Code (GitHub Copilot)

`.vscode/mcp.json`. VS Code asks for the key once and stores it securely:

```json
{
  "inputs": [
    { "type": "promptString", "id": "klupt-key", "description": "Klupt API key", "password": true }
  ],
  "servers": {
    "klupt": {
      "type": "http",
      "url": "https://api.klupt.io/mcp",
      "headers": { "X-Api-Key": "${input:klupt-key}" }
    }
  }
}
```

Open Copilot Chat in **Agent** mode and pick the Klupt tools.

## OpenAI Codex

`~/.codex/config.toml`:

```toml
[mcp_servers.klupt]
url = "https://api.klupt.io/mcp"
bearer_token_env_var = "KLUPT_API_KEY"
```

Or from the command line: `codex mcp add klupt --url https://api.klupt.io/mcp --bearer-token-env-var KLUPT_API_KEY`.

## Windsurf

`~/.codeium/windsurf/mcp_config.json`:

```json
{
  "mcpServers": {
    "klupt": {
      "serverUrl": "https://api.klupt.io/mcp",
      "headers": { "X-Api-Key": "${env:KLUPT_API_KEY}" }
    }
  }
}
```

## Gemini CLI

```bash
gemini mcp add --transport http --header "X-Api-Key: $KLUPT_API_KEY" -s user klupt https://api.klupt.io/mcp
```

## ChatGPT and the OpenAI API

ChatGPT's own connector screen (developer mode) only accepts servers with OAuth sign-in or no sign-in, so it cannot send a Klupt API key yet. From code, the **OpenAI Responses API** can use the server directly:

```python
from openai import OpenAI
import os

client = OpenAI()
resp = client.responses.create(
    model="gpt-5",
    tools=[{
        "type": "mcp",
        "server_label": "klupt",
        "server_url": "https://api.klupt.io/mcp",
        "headers": {"X-Api-Key": os.environ["KLUPT_API_KEY"]},
        "require_approval": "never",
    }],
    input="Who did @natgeo follow most recently? List 10, newest first.",
)
print(resp.output_text)
```

## Claude API (MCP connector)

```bash
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: mcp-client-2025-11-20" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1500,
    "mcp_servers": [{ "type": "url", "url": "https://api.klupt.io/mcp", "name": "klupt", "authorization_token": "'"$KLUPT_API_KEY"'" }],
    "tools": [{ "type": "mcp_toolset", "mcp_server_name": "klupt" }],
    "messages": [{ "role": "user", "content": "Show the 10 newest followers of @nasa." }]
  }'
```

The connector sends the token as `Authorization: Bearer`, which the Klupt server accepts.

## Any other MCP client

Use the streamable HTTP transport with the URL `https://api.klupt.io/mcp` and one header, `X-Api-Key` or `Authorization: Bearer`. The server is stateless: every request is a plain JSON-RPC `POST`, there is no session to keep and no SSE stream to hold open. Server metadata (an MCP server card) is at [https://api.klupt.io/mcp/server-card](https://api.klupt.io/mcp/server-card).

## Tools

| Tool | What it does | Credits |
|---|---|---|
| `get_profile` | Public Instagram profile for a username or numeric user id: full name, bio, external link, category, verified and private flags, follower / following / post counts, profile picture and the numeric user id. | 1 |
| `get_following` | Accounts that a public Instagram account follows, in Instagram's real newest-first order: position 1 is the account they followed most recently. | 2 |
| `get_followers` | Accounts that follow a public Instagram account, newest follower first: position 1 is the most recent follower. | 1 |
| `get_posts` | Posts of a public Instagram account, newest first, about 12 per page: shortcode, URL, date, type, caption, like / comment / view counts and thumbnail. | 1 |
| `search_users` | Find Instagram accounts by name or username (up to about 40 results). | 1 |
| `get_reels` | Reels of a public Instagram account, newest first (sort "recent") or most viewed (sort "views"), about 12 per page, with view counts and video URLs. | 1 |
| `get_tagged_posts` | Posts in which a public Instagram account is tagged, about 12 per page. | 1 |
| `get_reposts` | Posts a public Instagram account reposted, about 12 per page. | 1 |
| `get_stories` | Stories a public Instagram account posted in the last 24 hours, with media URLs and expiry times. | 1 |
| `get_highlights` | Story highlights of a public Instagram account (id, title, item count, cover). | 1 |
| `get_account_details` | When an Instagram account joined (month and year), its country and how many times it changed username. | 1 |
| `get_similar_accounts` | Accounts Instagram considers similar to this one (up to about 80). | 1 |
| `get_post_stats` | Like, comment and view counts for 1 to 20 posts in one call. | 1 |
| `get_post` | One Instagram post or reel by shortcode, numeric id or instagram.com URL: caption, date, counts, media URLs, owner, location and audio. | 1 |
| `get_comments` | Comments on an Instagram post, top first (sort "top") or newest first (sort "newest"), about 15 per page. | 1 |
| `get_post_likers` | Accounts that liked an Instagram post, about 100 per page. | 1 |
| `get_comment_replies` | Replies to a comment. | 1 |
| `get_comment_likers` | Accounts that liked a comment. | 1 |
| `get_story` | One Instagram story by numeric id. | 1 |
| `get_highlight_stories` | The stories inside one story highlight (ids come from get_highlights). | 1 |
| `search_hashtags` | Find Instagram hashtags matching a word, with post counts. | 1 |
| `search_places` | Find Instagram places (locations) by name, or near a point with lat and lng. | 1 |
| `search_audio` | Find songs and original audio used in Reels. | 1 |
| `get_hashtag` | One Instagram hashtag and its post count. | 1 |
| `get_hashtag_posts` | Top posts for an Instagram hashtag. | 1 |
| `get_place` | One Instagram place: name, category, address, city, coordinates, phone and website. | 1 |
| `get_place_posts` | Top (sort "top") or most recent (sort "recent") posts tagged at an Instagram place. | 1 |
| `get_trending_audio` | Audio trending on Instagram Reels right now. | 1 |
| `get_audio` | One song or original audio: title, artist, duration and how many reels use it. | 1 |
| `get_audio_reels` | Reels that use a given song or original audio. | 1 |
| `resolve_instagram_url` | Turn any instagram.com link (profile, post, reel, story, highlight, hashtag, place or audio) into its type, ids and the tool to call next. | 0 |
| `get_balance` | Your Klupt API plan, credit balance, rate limits and this key's usage this month. | 0 |

Lists come in pages. The assistant passes `pagination.next_cursor` back as `cursor` for the next page, and each page is billed, so ask for what you need ("the first page", "the 50 most recent").

Two built-in prompts help in clients that show them (in Claude Code they appear as `/mcp__klupt__recent_follows` and `/mcp__klupt__new_followers`).

## FAQ

### Is there an Instagram MCP server that returns followers and following newest first?
Yes. The Klupt MCP server's `get_following` and `get_followers` tools return a public account's lists in Instagram's real newest-first order: `position` 1 is the most recent follow, and `meta.order` is `"newest_first"`.

### Does the MCP server cost extra?
No. A tool call costs the same as the REST call behind it, and errors are free. A `kd_test_` key returns sample data at no cost.

### Can the assistant see private accounts?
No. The server only covers public accounts and publicly visible data. A private account answers `private_account`, and that call is free.

### Do I need to install anything?
No for Claude Code, Cursor, VS Code, Codex, Windsurf and Gemini CLI: they connect to the hosted URL directly. The Claude Desktop config-file route uses `npx mcp-remote`, which needs Node.js.

### How do I limit what an assistant can spend?
Create a separate key for the assistant in the dashboard and give it a monthly credit cap. Calls past the cap answer `key_quota_exceeded` for free.
