# XPilot by Realize Labs: AI Agent Operating Manual (agents.md)

> **Remote MCP Endpoint:** `https://www.tryxpilot.com/api/mcp` (Streamable HTTP JSON-RPC 2.0)
> **OAuth 2.1 Discovery:** `https://www.tryxpilot.com/.well-known/oauth-protected-resource`
> **Developer Docs:** `https://www.tryxpilot.com/docs`
> **Server Manifest:** `https://www.tryxpilot.com/mcp-server.json`
> **Built by:** Realize Labs (independent Canadian AI software studio founded by AI Security Engineer Armaan Sidhu, https://realarmaansidhu.com)

---

## 1. What XPilot Does for Your User

XPilot is a **zero-key, 2026 X Terms of Service-compliant Human-in-the-Loop (HITL) AI growth copilot for X (Twitter)**.
Users do **NOT** need external LLM keys or X Developer Portal API keys. Built-in managed AI, Zero-Key Account Radar, Voice DNA cloning, 195+ country localization, and anti-slop scoring work immediately on every plan (Free, Starter, Pro, Agency).

Every MCP call automatically inherits the authenticated user's **exact subscription tier, Voice DNA, country, language register, interests, target watchlist, and draft queue**, staying 100% synced across:
1. Web Cockpit (`https://www.tryxpilot.com/dashboard`)
2. Chrome / Brave / Edge Browser Extension (`https://www.tryxpilot.com/extension`)
3. Any AI Agent connected via MCP or REST (`https://www.tryxpilot.com/api/mcp`)

---

## 2. 1-Command Auto-Install, Authentication & Plan Tiers

- **Fastest 1-Command Installer (Recommended for AI Agents, Zero Browser Redirects):**
  Have the user click **Generate MCP Token** at `https://www.tryxpilot.com/docs` (or run without a token for OAuth 2.1 setup):
  ```bash
  curl -fsSL https://www.tryxpilot.com/install.sh | bash -s -- --token "xp_live_..."
  ```
  This automatically detects OpenCode, Claude Code, OpenAI Codex CLI, and Cursor, installs `SKILL.md`, safely merges `xpilot` into each client's MCP config, and runs a live `xpilot_get_account` verification.
- **Important Note for AI Agents Installing XPilot:** Do NOT run `opencode mcp auth xpilot` in a background shell and manually re-type the OAuth URL into a browser tool (background CLIs time out and manual URL transcription introduces typos). Prefer the `install.sh --token` command above, OR let the user run `opencode mcp auth xpilot` interactively so their OS opens Chrome directly.
- **OAuth 2.1 PKCE (For Claude.ai, Claude Desktop, Interactive Claude Code / OpenCode):**
  Point your MCP client at `https://www.tryxpilot.com/api/mcp`. Unauthenticated `POST /api/mcp` responses return `HTTP 401` with RFC 9728 `WWW-Authenticate` metadata pointing to `https://www.tryxpilot.com/.well-known/oauth-protected-resource/api/mcp`.
- **Personal Revocable Bearer Token (`xp_live_...`) for CLI / Scripts / Codex / OpenCode:**
  Pass `Authorization: Bearer xp_live_...` generated at `https://www.tryxpilot.com/docs`. Tokens are SHA-256 hashed at rest and revocable anytime.

### Plan Limits Enforced Automatically
| Tier | Radar Target Handles | Drafts / Month | Threads & Scheduling | Engagement Analytics | Direct X OAuth Publishing |
|---|---:|---:|---|---|---|
| **Free ($0)** | 1 | 25 | No | Basic stats | Web Intents only |
| **Starter ($29/mo)** | 5 | 500 | No | Basic stats | Yes (optional X OAuth 2.0) |
| **Pro ($49/mo)** | 15 | 2,000 | Yes (3-8 post threads + UTC schedule) | Full Analytics | Yes (optional X OAuth 2.0) |
| **Agency ($99/mo)** | 50 | Unlimited | Yes (3-8 post threads + UTC schedule) | Full Analytics + CSV | Yes (optional X OAuth 2.0) |

---

## 3. Recommended Agent Workflows (Start Grinding Immediately)

### Workflow A: First-Time User Setup (Under 60 Seconds)
1. Call `xpilot_get_account` to inspect the user's tier, limits, active Voice DNA, country, interests, and watchlist.
2. If the user has not cloned their voice yet, ask for their X `@handle` (or 3 sample posts) and call `xpilot_clone_voice_dna(handle="...", save_to_profile=true)`.
3. Ask for their country (any of 195+ countries or `International`) and interests (any topic: Politics & Policy, AI & Software, Films & Cinema, Cricket, Football, Startups, Finance, etc.).
4. Call `xpilot_suggest_targets` to find high-signal accounts in that region/niche, then call `xpilot_update_voice_and_watchlist` to save their preferences and targets.
5. Call `xpilot_scan_radar` to immediately populate fresh anti-slop reply drafts.

### Workflow B: Daily 15-Minute X Growth Loop (5 Replies + 1 Original Post)
1. Call `xpilot_get_analytics` and `xpilot_list_queue(status="draft")` to check today's progress toward the 5-reply daily goal.
2. If the queue is low, call `xpilot_scan_radar(max_handles=3)` to pull fresh posts from watched accounts.
3. Present the top 3 to 5 drafts with their `human_score` and `reply_intent_url`. If any draft feels off-tone, call `xpilot_rewrite_draft` with a sharper tone or modifier (`shorter`, `spicier`, `witty`, `contrarian`, `question`, `quote`).
4. For original content, call `xpilot_suggest_ideas(kind="post")` -> `xpilot_compose_post` -> `xpilot_check_ai_slop` -> `xpilot_save_or_publish_draft(action="save_tweet_draft")`.
5. For Pro/Agency users writing deep-dive stories, call `xpilot_compose_thread(topic="...", length=5)` -> `xpilot_save_or_schedule_thread`.

### Workflow C: Human-in-the-Loop Safety Rules (Mandatory)
- **Default to Drafts & X Web Intents:** Always present generated drafts and clickable `x_intent_url` links so the human reviews before posting.
- **Never spam or auto-post without explicit user approval:** Only call `publish_reply_draft`, `publish_tweet_draft`, or `publish_now: true` when the user explicitly instructs you to publish that specific draft.
- **Target >= 85% Human Score:** Avoid em dashes, hashtags in replies, corporate cliches (*delve, underscores, landscape, game-changer, pivotal*), and filler openers (*"Great point!"*). Use `xpilot_check_ai_slop` or `xpilot_rewrite_draft` if any draft scores below 85%.

---

## 4. Complete MCP Capabilities (19 Tools + 3 Resources + 4 Prompts)

### Onboarding, Account & Settings
- `xpilot_get_agent_guide`: Returns this full `agents.md` operating manual (callable anytime).
- `xpilot_get_account`: Returns synced email, plan tier, handle/reply limits, Voice DNA, country, language, interests, watchlist, and radar status.
- `xpilot_update_voice_and_watchlist`: Updates writing tone (8 modes), country (195+ countries), language register, interests, Voice DNA notes, and target watchlist handles.
- `xpilot_clone_voice_dna`: Zero-key voice cloning from any public `@handle` or pasted posts, with optional `save_to_profile: true`.
- `xpilot_toggle_radar`: Turns 24/7 background Account Radar ON or OFF.

### Replies, Account Radar & Queue Triage
- `xpilot_draft_replies`: Generates 4 human reply/quote angles (`insightful`, `witty`, `question`, `quote`) for any X status URL or post text with pre-filled X Web Intent URLs.
- `xpilot_scan_radar`: Runs an immediate zero-key scan of watched targets and saves fresh anti-slop drafts.
- `xpilot_list_queue`: Lists pending `draft` or `posted` items from `reply_logs` with clickable X intent links.
- `xpilot_rewrite_draft`: Rewrites any draft into a new tone or modifier (`shorter`, `spicier`, `question`, `quote`, `friendlier`) and optionally persists to `reply_logs`.
- `xpilot_manage_queue_draft`: Edit draft text, mark a reply as `sent`, or discard a queued draft.

### Original Posts, Threads, Ideas & Anti-Slop
- `xpilot_suggest_ideas`: Generates 3 to 6 tailored standalone post or thread topic ideas.
- `xpilot_suggest_targets`: Discovers high-signal public X accounts for any country and combination of interests.
- `xpilot_compose_post`: Drafts 1 to 5 original anti-slop standalone X posts on any topic in the user's Voice DNA.
- `xpilot_compose_thread`: Architects a 3-to-8-post structured thread (Pro / Agency tier).
- `xpilot_save_or_schedule_thread`: Saves a multi-post thread to `tweet_drafts`, schedules automatic UTC publishing, or publishes immediately via connected X OAuth 2.0 (Pro / Agency tier).
- `xpilot_list_post_drafts`: Lists saved standalone posts and scheduled/posted threads from `tweet_drafts`.
- `xpilot_check_ai_slop`: Scores any draft 0-100% for AI writing fingerprints and returns 3 humanized rewrites.
- `xpilot_save_or_publish_draft`: Saves a standalone post draft, marks a reply sent, or publishes a draft directly (Starter+ with connected X OAuth).

### Analytics
- `xpilot_get_analytics`: Returns live engagement totals (replies sent today/7d/30d, pending drafts, likes, impressions, approval rate, top-performing styles, and active streak).

### Native MCP Resources & Prompts
- **Resources (`resources/list`, `resources/read`):**
  - `xpilot://docs/agents.md` (this full operating manual)
  - `xpilot://docs/tools` (full JSON schema catalog)
  - `xpilot://account/profile` (live authenticated user voice & tier snapshot)
- **Prompts (`prompts/list`, `prompts/get`):**
  - `daily-x-growth-routine`
  - `reply-to-post-with-4-angles`
  - `build-in-public-thread`
  - `voice-onboarding-setup`

---

## 5. Direct REST Endpoints (Same Bearer Auth)

Every core workflow is also callable via standard HTTPS JSON REST with `Authorization: Bearer xp_live_...`:
- `GET  https://www.tryxpilot.com/api/extension/bootstrap` (Account, tier, config, queue, daily stats)
- `POST https://www.tryxpilot.com/api/extension/config` (Update Voice DNA & target watchlist)
- `POST https://www.tryxpilot.com/api/replies/instant` (4-angle instant reply & quote drafting)
- `POST https://www.tryxpilot.com/api/replies/rewrite` (Inline draft retoning)
- `POST https://www.tryxpilot.com/api/radar/scan` (Immediate zero-key radar scan)
- `POST https://www.tryxpilot.com/api/radar/suggest` (Global AI target discovery)
- `POST https://www.tryxpilot.com/api/voice/clone` (Zero-key Voice DNA cloning)
- `POST https://www.tryxpilot.com/api/tweets/ideas` (Post & thread topic ideas)
- `POST https://www.tryxpilot.com/api/tweets/compose` (Original post drafting)
- `POST https://www.tryxpilot.com/api/threads/compose` (Multi-post thread architect, Pro/Agency)
- `POST https://www.tryxpilot.com/api/public/humanize` (Public anti-slop audit & 3-voice humanizer)
