# Hubfluencer + Codex CLI

Teach Codex CLI to generate finished videos with Hubfluencer. You buy credits and create an access token in the Hubfluencer app; your agent spends those credits to produce a post-ready MP4.

---

## 1. Connect (pick one)

**Option A — token via env (copy-paste once)**

1. In the Hubfluencer app, buy credits.
2. Go to **Settings → Access tokens** and create a token with the **"Generate videos"** scope (`video:generate` + `video:read`).
3. Supply it to Codex (see step 2 below).

**Option B — device link (no copy-paste)**

Register the server with just `command`/`args` (no token), then run:

```bash
npx -y @hubfluencer/mcp login
```

It prints a URL and a short code. Approve the connection in the signed-in Hubfluencer app. A scoped token is written to `~/.hubfluencer/credentials.json`, and the MCP server reads it automatically — so you can omit `HUBFLUENCER_API_TOKEN` entirely.

---

## 2. Register the MCP server in Codex CLI

**Fastest — one command:**

```bash
codex mcp add hubfluencer --env HUBFLUENCER_API_TOKEN=YOUR_TOKEN -- npx -y @hubfluencer/mcp
```

The `--` separates the stdio server command. (Using device-link / Option B? Drop `--env HUBFLUENCER_API_TOKEN=YOUR_TOKEN` — register with just `-- npx -y @hubfluencer/mcp`.)

**Or — edit the config file** at `~/.codex/config.toml` (global) or `.codex/config.toml` (per-project, trusted projects only):

```toml
[mcp_servers.hubfluencer]
command = "npx"
args = ["-y", "@hubfluencer/mcp"]

[mcp_servers.hubfluencer.env]
HUBFLUENCER_API_TOKEN = "YOUR_TOKEN"
# Optional:
# HUBFLUENCER_BASE_URL = "https://hubfluencer.com"
# HUBFLUENCER_OUTPUT_DIR = "/absolute/path/where/mp4s/may/be/written"
```

After editing `config.toml`, **restart Codex**. (Using device-link? Omit the `[mcp_servers.hubfluencer.env]` block.)

**Verify / manage:**

```bash
codex mcp list
codex mcp get hubfluencer
codex mcp remove hubfluencer
```

---

## 3. Install the instructions

Codex's recommended format is an **Agent Skill**. Copy `SKILL.md` to one of:

- `~/.codex/skills/hubfluencer-create/SKILL.md` — personal (all projects)
- `.codex/skills/hubfluencer-create/SKILL.md` — project (committable)

Codex invokes the skill automatically when a task matches its description, or explicitly via `/skills` (type `$` to mention it).

**Portable fallback / always-on guidance:** paste the contents of `AGENTS.md` into `~/.codex/AGENTS.md` (global) or your repo-root `AGENTS.md` (project-shared). Codex concatenates these from the repo root down to the cwd.

---

## 4. Try it

Ask Codex:

> Use Hubfluencer to make me a 15s ad for my cold-brew coffee subscription.

That's it — the agent creates the project, renders the video, downloads the MP4, and hands you a ready-to-paste caption.

---

### Notes

- **Credits:** creating a draft = 0 credits; rendering a short = 15 credits; multi-scene editor ads cost more. Check your balance any time — the agent can call `get_credits`.
- **Result links** are presigned and expire in ~24h, so the agent downloads them right away.
- **Publishing** to TikTok / Instagram needs a human-linked social account — the agent won't auto-publish; it returns the MP4 + caption for you to post.
