# Hubfluencer agent kit for Pi

Teach the [Pi coding agent](https://pi.dev) to generate finished, post-ready videos with Hubfluencer — prompt in, MP4 out.

This kit contains:

| File | What it is | Where it goes |
| --- | --- | --- |
| `SKILL.md` | The reusable how-to (Pi Agent Skill) | `~/.pi/agent/skills/hubfluencer-create/` (global) or `.pi/skills/hubfluencer-create/` (project) |
| `AGENTS.md` | Always-on pointer so Pi knows the skill/MCP exist | your project root (or any ancestor of your working dir) |
| `mcp.json` | Registers the `@hubfluencer/mcp` server | see step 2 below |

---

## 1. Get credits + an access token

In the Hubfluencer app:

1. **Buy credits.** Creating a draft is free (0 credits); rendering a short is 15 credits; multi-scene editor ads cost more.
2. Go to **Settings -> Access tokens** and create a token with the **"Generate videos"** scope (`video:generate` + `video:read`).
3. Keep the token handy — you'll expose it as the `HUBFLUENCER_API_TOKEN` environment variable.

**Or skip the copy-paste** — connect with a device link instead:

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

It prints a URL and a short code. Approve the connection in your signed-in Hubfluencer app. A scoped token is saved to `~/.hubfluencer/credentials.json` and the MCP server picks it up automatically — so you can leave `HUBFLUENCER_API_TOKEN` out of `mcp.json` entirely.

> Never share or paste your token into chat. The agent never needs to see it.

## 2. Register the MCP server in Pi

The official Pi agent has no built-in MCP support, so install the community MCP adapter once:

```bash
pi install npm:pi-mcp-adapter
```

Then drop this kit's `mcp.json` where the adapter looks for it. Any of these paths works (first found wins): `~/.config/mcp/mcp.json`, `~/.pi/agent/mcp.json`, `./.mcp.json`, `./.pi/mcp.json`. For example, globally:

```bash
mkdir -p ~/.pi/agent
cp mcp.json ~/.pi/agent/mcp.json
```

`mcp.json` contents:

```json
{
  "mcpServers": {
    "hubfluencer": {
      "command": "npx",
      "args": ["-y", "@hubfluencer/mcp"],
      "env": {
        "HUBFLUENCER_API_TOKEN": "${HUBFLUENCER_API_TOKEN}"
      }
    }
  }
}
```

- `${HUBFLUENCER_API_TOKEN}` is interpolated from your environment, so the secret stays out of the committed config. Export it before launching Pi: `export HUBFLUENCER_API_TOKEN=...`. (Or paste the literal token in place of `${HUBFLUENCER_API_TOKEN}`.)
- If you connected with `npx -y @hubfluencer/mcp login`, you can delete the whole `env` block — the locally saved token is used automatically.
- Optional env vars: `HUBFLUENCER_BASE_URL` (default `https://hubfluencer.com`) and `HUBFLUENCER_OUTPUT_DIR` (confines where downloaded MP4 files are written).

Restart Pi after installing the adapter or editing `mcp.json`.

## 3. Install the instructions

**The skill** (the canonical how-to). Copy `SKILL.md` into a Pi skills directory named `hubfluencer-create`:

```bash
# Global (available everywhere)
mkdir -p ~/.pi/agent/skills/hubfluencer-create
cp SKILL.md ~/.pi/agent/skills/hubfluencer-create/SKILL.md

# …or project-local
mkdir -p .pi/skills/hubfluencer-create
cp SKILL.md .pi/skills/hubfluencer-create/SKILL.md
```

Pi loads it automatically when your request matches, or you can force it with `/skill:hubfluencer-create`.

**The always-on pointer** (optional but recommended). Copy `AGENTS.md` to your project root so Pi always knows Hubfluencer is available:

```bash
cp AGENTS.md ./AGENTS.md
```

## 4. Try it

Just ask Pi:

```
Use Hubfluencer to make me a 15s ad for my cold-brew coffee brand, energetic gen-z vibe.
```

Pi creates the project, starts generation, waits a few minutes for the render, downloads the MP4, and hands you the file plus a ready-to-paste caption. (It won't auto-publish — you post it yourself.)
