# @xreplyai/mcp

[![npm version](https://img.shields.io/npm/v/@xreplyai/mcp.svg)](https://www.npmjs.com/package/@xreplyai/mcp)
[![npm downloads](https://img.shields.io/npm/dm/@xreplyai/mcp.svg)](https://www.npmjs.com/package/@xreplyai/mcp)
[![license](https://img.shields.io/npm/l/@xreplyai/mcp.svg)](https://www.npmjs.com/package/@xreplyai/mcp)

MCP server for [XreplyAI](https://xreplyai.com) — plan, generate, and schedule posts in your voice. Manage your post queue and publish to X/Twitter from any AI agent.

The only MCP with **voice profile integration**: post generation is trained on your own archive, not a style prompt, so drafts sound like you, not generic AI.

<!-- TODO(demo): embed a demo GIF here (an agent drafting and scheduling a week of posts from Claude Code). -->

> **Requires an active XreplyAI subscription.** Every new account starts with a **14-day trial** of the Unlimited plan (card required), which covers the full MCP toolset.

## Features

44 tools covering the full posts workflow across 10 platforms (X/Twitter, LinkedIn, YouTube, Threads, Instagram, Bluesky, Mastodon, Facebook, Pinterest, TikTok):

- **Generation** — Generate single posts, threads, batches, LinkedIn carousels, on-voice replies, and drafts from content ideas
- **Post management** — Create, edit, delete, list, and run the team review workflow on posts
- **Publishing** — Publish immediately, schedule, or queue into the next open posting-schedule slot on any connected platform
- **Planning** — List content ideas and act on them, create/run automated content plans, and find open calendar slots
- **Media uploads** — Images and video for X, LinkedIn, Instagram, Threads, Bluesky, Pinterest, TikTok, and YouTube, plus a reusable media asset list
- **Context** — Billing status, voice profile, preferences, platform styles, and custom rules
- **Accounts & communities** — List connected social accounts, X communities, and Pinterest boards
- **Analytics** — Per-account engagement rollups, time series, and best-times-to-post

## Requirements

- Node.js 20+
- An XreplyAI account with an active subscription or trial. Create an API key in Settings → API Keys.

## Setup

### Get your API key

Sign in to [XreplyAI](https://xreplyai.com), go to **Settings → API Keys**, and create an API key.

### Claude Desktop

Add to your Claude Desktop config file:
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux:** `~/.config/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "xreply": {
      "command": "npx",
      "args": ["@xreplyai/mcp@0.31.0"],
      "env": {
        "XREPLY_TOKEN": "your-api-key-here"
      }
    }
  }
}
```

### Claude Code

Run this command:

```bash
claude mcp add xreply -e XREPLY_TOKEN=your-api-key-here -- npx @xreplyai/mcp@0.31.0
```

Then run `claude mcp list` to confirm it's registered.

Or add manually to `~/.claude/mcp.json`:

```json
{
  "mcpServers": {
    "xreply": {
      "command": "npx",
      "args": ["@xreplyai/mcp@0.31.0"],
      "env": {
        "XREPLY_TOKEN": "your-api-key-here"
      }
    }
  }
}
```

### Cursor

Click to install (you'll be prompted to update your token after):

[Install in Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=xreply&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAeHJlcGx5YWkvbWNwIl0sImVudiI6eyJYUkVQTFlfVE9LRU4iOiJ5b3VyLWFwaS1rZXktaGVyZSJ9fQ)

Or add manually to `.cursor/mcp.json` in your project (or `~/.cursor/mcp.json` globally):

```json
{
  "mcpServers": {
    "xreply": {
      "command": "npx",
      "args": ["@xreplyai/mcp@0.31.0"],
      "env": {
        "XREPLY_TOKEN": "your-api-key-here"
      }
    }
  }
}
```

### Windsurf

Open Windsurf and go to **Plugins → Manage plugins → View raw config**, then add the server config below. Or edit `~/.codeium/windsurf/mcp_config.json` directly:

```json
{
  "mcpServers": {
    "xreply": {
      "command": "npx",
      "args": ["@xreplyai/mcp@0.31.0"],
      "env": {
        "XREPLY_TOKEN": "your-api-key-here"
      }
    }
  }
}
```

### OpenClaw

[OpenClaw](https://openclaw.ai) is a self-hosted AI gateway that connects chat apps (WhatsApp, Telegram, Discord) to AI agents via Skills.

**Install via ClawHub:**

```bash
clawhub install xreplyai
```

**Manual install:**

```bash
cp -r mcp/openclaw/ ~/.openclaw/skills/xreply/
```

**Configure your token** in `~/.openclaw/openclaw.json`:

```json
{
  "skills": {
    "entries": {
      "xreply": {
        "env": {
          "XREPLY_TOKEN": "your-api-key-here"
        }
      }
    }
  }
}
```

The skill uses `mcporter` to bridge OpenClaw to the XreplyAI MCP server. Install it with:

```bash
npm install -g mcporter
```

Verify the skill loads:

```bash
openclaw skills list --eligible
```

### Remote (hosted) server — no install

Prefer not to run anything locally? XreplyAI also hosts the MCP server over streamable HTTP with OAuth, so there's no `npx` process and no long-lived token to paste. Point any MCP client that supports remote servers at:

```
https://mcp.xreplyai.com/mcp
```

Authentication is OAuth 2.1 against `https://api.xreplyai.com` — your client walks you through sign-in on first connect. (In Claude, add it as a custom connector using that URL.) The same paid-plan requirement applies.

## Tools

### Generation

| Tool | Description |
|------|-------------|
| `xreply_posts_generate` | Generate a single post in your voice (all platforms) |
| `xreply_posts_generate_batch` | Generate 1–9 posts at once by category (Personalized/Trending/Viral) |
| `xreply_posts_generate_thread` | Generate a 2–10 tweet X thread in your voice |
| `xreply_carousel_generate` | Generate a LinkedIn PDF carousel (3–12 slides) |
| `xreply_reply_generate` | Generate an on-voice reply to a tweet/post (with thread context, tone preferences, and previous-attempts avoidance) |
| `xreply_posts_generate_from_idea` | Generate draft text from a seed idea — supports `variants` (2–3) or `refine` an existing draft |

### Post Management

| Tool | Description |
|------|-------------|
| `xreply_posts_list` | List posts in your queue — filter by `status`, `source`, `reviewable`; sort by `scheduled_at`/`created_at` (`sort_direction`); paginate with `limit`/`offset` |
| `xreply_posts_create` | Save a post draft (per-platform content). Pass `dry_run: true` to validate without saving |
| `xreply_posts_edit` | Edit body, scheduled time, or metadata |
| `xreply_posts_delete` | Delete a post (destructive; confirm the post with the user first) |
| `xreply_posts_review` | Run the team review workflow — `submit` a draft, `approve`, or `reject` (with reason) |

### Publishing

| Tool | Description |
|------|-------------|
| `xreply_posts_publish` | Publish now, schedule to a specific time, or queue into the next open posting-schedule slot (`use_next_slot`) |
| `xreply_posts_next_slot` | Preview when a post would go out if queued — returns `scheduled_at` without scheduling anything |

### Media Uploads

| Tool | Description |
|------|-------------|
| `xreply_media_upload` | Upload an image for X or LinkedIn |
| `xreply_video_upload` | Upload a video for LinkedIn |
| `xreply_youtube_upload` | Upload a video for YouTube (presigned R2) |
| `xreply_instagram_media_upload` | Upload an image or video for Instagram |
| `xreply_instagram_audio_search` | Search Instagram's audio catalog for a Reel (returns `audio_id`) |
| `xreply_threads_media_upload` | Upload an image for Threads |
| `xreply_bluesky_media_upload` | Upload an image for Bluesky (returns blob ref) |
| `xreply_pinterest_media_upload` | Upload an image for Pinterest |
| `xreply_linkedin_document_upload` | Upload a PDF for LinkedIn carousels |
| `xreply_media_assets_list` | List reusable media assets — reuse one by `r2_key` instead of re-uploading. Filter by `kind` or `tag` |

### Context & Config

| Tool | Description |
|------|-------------|
| `xreply_billing_status` | Check subscription tier and status |
| `xreply_voice_status` | Check voice profile analysis status |
| `xreply_preferences_get` | Get generation preferences (tone, emoji, structure) |
| `xreply_preferences_set` | Update tone, emoji, structure, and default AI model |
| `xreply_platform_styles_get` | Get per-platform style profiles |
| `xreply_platform_styles_set` | Override style settings for a specific platform |
| `xreply_brand_get` | Get the workspace Brand, the Social Agent's goal and its content pillars |
| `xreply_brand_update` | Update Brand fields, the goal or the pillars (list fields replace the whole list) |
| `xreply_rules_list` | List custom writing rules |
| `xreply_rules_create` | Add a new custom writing rule |
| `xreply_rules_update` | Edit an existing custom writing rule |
| `xreply_rules_delete` | Delete a custom writing rule |
| `xreply_list_social_accounts` | List connected social accounts with IDs |
| `xreply_content_plan_list` | List content plans (automated weekly schedule) |
| `xreply_posting_schedule_list` | List posting schedules (one per account) with slots |
| `xreply_posting_schedule_update` | Update one schedule's spacing, timezone, and slots |
| `xreply_posting_schedule_open_slots` | List upcoming open "ready to post" calendar slots across active schedules (optional `from`/`to` window) |

### Planning & Ideas

| Tool | Description |
|------|-------------|
| `xreply_content_plan_create` | Create an automated weekly content plan (triggers an initial run) |
| `xreply_content_plan_run` | Trigger a manual run of an existing content plan |

### Communities & Boards

| Tool | Description |
|------|-------------|
| `xreply_list_twitter_communities` | List recently-used X communities |
| `xreply_pinterest_boards` | List the user's Pinterest boards (with `force_refresh`) |

### Analytics

| Tool | Description |
|------|-------------|
| `xreply_analytics_get` | Read post-performance analytics (read-only). `view: rollups` (default) — per-account totals/averages + followers gained + period-over-period deltas; `view: timeseries` — daily deltas for charting; `view: best_times` — day-of-week × hour engagement grid. Filter with `start_date`/`end_date` (default last 30 days), `social_account_id`, or `platform` |

### Short links

| Tool | Description |
|------|-------------|
| `xreply_short_links_create` | Shorten up to 5 URLs through the branded Dub link service (`links:write` scope). Post creation already shortens opted-in bodies; this is for shortening before a post is saved |

## Example workflows

### Plan posts for the week

```
1. xreply_posts_generate_batch (category: "personalized", count: 7) — generate 7 posts
2. xreply_posts_list — review the queue
3. xreply_posts_edit (id: X, scheduled_at: "2026-03-10T09:00:00Z") — schedule each
```

### Quick post

```
1. xreply_posts_generate (topic: "my SaaS hit 1000 users", angle: "story_arc")
2. xreply_posts_create (body: "<generated text>")
3. xreply_posts_publish (id: X) — post immediately
```

### Queue to the next open slot

```
1. xreply_posts_create (body: "<post text>") — save a draft
2. xreply_posts_next_slot (id: X) — optional: preview when it would go out
3. xreply_posts_publish (id: X, use_next_slot: true) — queue into the next open posting-schedule slot
```

## Environment variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `XREPLY_TOKEN` | Yes | — | Your XreplyAI API key |
| `XREPLY_POSTHOG_KEY` | No | public project key | PostHog project key for usage analytics. Set to an empty string (`XREPLY_POSTHOG_KEY=""`) to disable analytics entirely |

## Security

- **Tool annotations.** Every tool declares the MCP `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint` annotations, so hosts can prompt before a destructive or outward-facing call. `xreply_posts_publish`, `xreply_posts_delete`, and `xreply_rules_delete` also say so in their descriptions: confirm the target with the user before calling them.
- **Upload tools read only real media.** Each file-upload tool checks the file size before reading it and verifies the bytes carry the declared format's signature (JPEG, PNG, GIF, WebP, MP4/MOV, WebM, MPEG, PDF) before anything leaves the machine. A file that does not match its declared type is refused, so the tools cannot be used to exfiltrate arbitrary files.
- **Environment.** The server reads `XREPLY_TOKEN`, `XREPLY_API_URL`, and `XREPLY_POSTHOG_KEY` from the process environment only. It does not read `.env` files or anything else on disk.
- **Network.** Requests go to the XreplyAI API (and, for direct platform uploads, the URL the API returns) plus the analytics event below.

## Analytics

Each tool call emits a fire-and-forget `$mcp_tool_call` event to PostHog (tool name, server version, duration, and error flag — never argument values). It never blocks or fails the tool response. Opt out by setting `XREPLY_POSTHOG_KEY=""`.

## Changelog

### 0.31.0 (2026-10-16)

- **`xreply_media_assets_list` drops the `catalog` filter.** The API stopped reading it on 2026-09-22, so a call that passed `catalog` silently got every asset. The description now names only the fields the API returns, and says the list includes Canva exports, each named after its design.

### 0.30.0 (2026-10-15)

- **YouTube and Pinterest channels, Quote looks.** `xreply_content_plan_create` describes `video` on a youtube channel, which takes only video: a slot whose post cannot become a clip gets no post, and the run's notes say how many. `carousel` is described on pinterest (2 to 5 slides), as a `media_format` and in `agent_post_types`. `overlay_mode: "pull_quote"` now says the agent picks each post's look among those the workspace allows (a line at the bottom, centred over a brand-washed picture, or a card on the brand colours). Descriptions only; no schema change.

### 0.29.0 (2026-10-13)

- **`video` on content plan channels.** `xreply_content_plan_create` channels accept `video` in `agent_post_types` (instagram, tiktok and youtube) and as a `media_format` (instagram and tiktok). With the workspace's video turned on, the agent places a video only on a post that shows a product with its own photo, at most seven per channel in any seven days; any other post ships as an illustration recorded `video_unavailable`. A channel created with `media_format: "video"` gets an empty `agent_post_types` list unless one is sent. A client that echoes a channel's server-seeded `agent_post_types` back no longer has `video` refused by the schema.

### 0.28.1 (2026-10-13)

- **No daily quota pre-checks.** The generate tools no longer read the billing status before calling the API, and their descriptions no longer mention a daily generation quota. `xreply_billing_status` describes the one plan (`unlimited`, or `free` when unsubscribed).

### 0.28.0 (2026-09-30)

- **`agent_post_types` on a channel.** `xreply_content_plan_create` accepts a list of post types (`text`, `illustration`, `quote`, `carousel`) the agent may choose between for each post on that channel. An empty list keeps the fixed `media_format` for every post. Omitted on a new channel, the agent chooses between the platform's image types, unless the channel is created with `media_format: "text"` or a `combine_group`. `carousel` is available on linkedin, instagram, facebook, threads, twitter, bluesky and mastodon. `carousel_every_n` is accepted and ignored.

### 0.27.1 (2026-09-25)

- **`quote_cards` is a deprecated alias.** `xreply_content_plan_create` still accepts it on a channel or a `platform_configs` entry, and stores it as `ai_illustration` with `overlay_mode: 'pull_quote'` (a Quote). Its former companions (`watermark_*`, `carousel_every_n`, `quote_topic`) are accepted and ignored. A new instagram or pinterest illustration channel is born with `overlay_mode: 'pull_quote'` unless the write says otherwise. Descriptions only; no schema change.

### 0.27.0 (2026-09-24)

- **`overlay_mode` on content plan channels.** `xreply_content_plan_create` channels accept `overlay_mode: "pull_quote"` on an `ai_illustration` channel to draw a short line from the post onto its image (at the bottom, in white or near-black text, with a shadow or dark gradient only where the image needs one). Works on every image-capable platform. `none` (the default) keeps the plain illustration; any other media format rejects `pull_quote`.

### 0.26.0 (2026-09-23)

- **MCP tool annotations on every tool** (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`), so hosts can prompt before destructive or outward-facing calls. `xreply_posts_publish`, `xreply_posts_delete`, and `xreply_rules_delete` now ask the agent to confirm the target with the user first.
- **Upload tools verify the file's signature** against the declared content type and check size before reading, so a non-media file can no longer be uploaded as an image, video, or PDF. The error text changed from `Cannot read file at` to `Could not read file at`, and a mismatched file returns `does not look like <content type>`.
- **Removed the `.env.local` loader** from the stdio entrypoint. Configuration comes from the process environment only.
- Retired tier names (Pro, Team) removed from tool descriptions; the rules and review tools now say "Requires an active subscription".

### 0.25.0 (2026-09-22)

- **`media_format` is the one image switch on every channel.** `xreply_content_plan_create` channels take `text`, `ai_illustration` (the default on every image-capable platform) or `quote_cards` (instagram, pinterest). `ai_illustration` now means the post waits for its image and fails visibly if it cannot be made; `text` is refused where the platform requires media. The `ai_images_enabled` channel field is gone.

### 0.24.0 (2026-09-21)

- **Removed `xreply_image_week_create` and `xreply_image_week_status`.** The Quote Week runs API they wrapped is gone (public API 14.0.0): it had no dashboard and no recorded use, and quote cards are still produced by the content planner as part of a plan. 46 tools became 44.

### 0.23.0 (2026-09-19)

- **A workspace now holds at most ONE content plan** — `xreply_content_plan_create` no longer advertises a 10-plan limit and returns `PLAN_LIMIT_REACHED` when a plan already exists. Edit the existing plan instead of creating a second; the dashboard only ever rendered one, so additional plans generated posts nobody could see.

### 0.21.0 (2026-09-07)

- **Removed Discord, Telegram, Tumblr, Google Business, and Slack as posting platforms** — their keys leave the `platform` enum on every post tool, and `xreply_tumblr_media_upload` is gone. Posts already published to those platforms keep their history; a new `post_contents` entry naming one is rejected. Polls are X, LinkedIn, and Mastodon only.

### 0.20.0 (2026-09-06)

- **Removed `paused` from `xreply_posting_schedule_update`** — schedule pause is retired; a schedule stops placing posts only while its account is disconnected or suspended by the platform, which the backend derives from the account. The `paused` field is also gone from `xreply_posting_schedule_list` responses. Per-channel intent lives on the account's automation level.

### 0.19.0 (2026-08-26)

- **Renamed content-plan channel fields** — `angles` is now `writing_formats`, and the quote-card output medium field `format` is now `media_format`. Existing values such as `data_point` and `quote_cards` are unchanged.

### 0.18.0 (2026-08-24)

- **Content angle enum split per learning scope** — Separated content generation rhetorical intents from craft preferences. Removed `one_liner`, `list`, `paragraph`, and `my_voice` from the angle union. Added `announcement` and `teaching` to match the new content strategy architecture.
- **Updated `PostAngle` type** — Now includes `announcement`, `data_point`, `myth_buster`, `opinion`, `question`, `story_arc`, `teaching`, and `this_or_that`.
- See [Briefing and Planner Architecture](https://github.com/xreplyai/xreplyai/blob/main/docs/architecture/briefing-and-planner.md) §1b for design rationale.

## Development

```bash
npm install
npm run build
npm test
XREPLY_TOKEN=your-token npx tsx src/index.ts
```
