# Agent Wrapped — Official Agent Skill & MCP Protocol

> Official Stage: `https://wrapped.z40.io`
> Role: Local-first, read-only AI Agent & Token usage aggregation and official visual card handoff.

## Iron Rules (Read Before Acting)

1. **Zero Secrets / Zero Raw Prompts**:
   - NEVER read `.env*`, `auth.json`, `oauth_creds.json`, `*credential*`, `*secret*`, or raw chat prompt text.
   - Only read aggregated usage metrics, timestamps, model families, and dependency names (`package.json`, `pyproject.toml`, etc.).
2. **Anti-Cloning Guardrail (Never DIY Render)**:
   - NEVER fabricate, clone, or draw your own HTML, SVG, ASCII, or Markdown Wrapped cards in chat or files.
   - Your job ends at collecting, reconciling, merging, and calling `open_wrapped_stage` (or `--open` bridge) so the **official Agent Wrapped web stage** renders the authentic Risograph 4-card deck and exports 2× PNGs.

---

## Option A: Connect via MCP Server (Recommended)

Zero-install stdio MCP server (requires Node.js >= 18; downloads runner to a temp file so `stdin` remains open for JSON-RPC):

```bash
claude mcp add agent-wrapped -- sh -c 'f="${TMPDIR:-/tmp}/agent-wrapped-cli.js"; curl -fsSL https://wrapped.z40.io/cli/run.js -o "$f" && exec node "$f" --mcp'
```

Or via `mcp.json`:

```json
{
  "mcpServers": {
    "agent-wrapped": {
      "command": "sh",
      "args": [
        "-c",
        "f=\"${TMPDIR:-/tmp}/agent-wrapped-cli.js\"; curl -fsSL https://wrapped.z40.io/cli/run.js -o \"$f\" && exec node \"$f\" --mcp"
      ]
    }
  }
}
```

### MCP Workflow (4 Steps)

1. **Scan this machine**: Call `scan_local_agents({ year: 2026 })`.
   - Scans Claude Code, Codex, OpenCode, Antigravity, Cursor Local, Gemini CLI, AI Studio (Drive metadata), Pi, and shallow local SDK project fingerprints (`@google/genai`, `openai`, `@anthropic-ai/sdk`, etc.).
2. **Review `coverageAudit` & reconcile blind spots**:
   - Present a short summary of what was found (exact vs estimated) and ask the user about gaps reported in `coverageAudit.recommendedFollowups`:
     - **Gemini Web / Mobile App**: Did they export Google Takeout `MyActivity.json`? If yes, call `import_local_file({ filePath })`.
     - **Direct API billing**: Did they export OpenRouter / OpenAI / Anthropic / Gemini API usage `.csv`? If yes, call `import_local_file({ filePath })`.
     - **Other computers / SSH servers**: With user consent, run `curl -fsSL https://wrapped.z40.io/cli/run.js | node - --sync-code` on remote hosts to get `z4z1:...` codes, or point to a synced folder (`syncDir`) of `*.z4z.json` files.
3. **Merge**: Call `merge_wrapped_snapshots({ items: [...], syncDir? })` to deduplicate by `device.id` and recompute exact `activeDays`, `longestStreak`, `peakDay`, and 52-week heatmap.
4. **Launch Official Stage**: Call `open_wrapped_stage({ payload })` to open the user's browser straight onto the official Result Stage (`?mode=workspace&step=3&source=mcp#import=...`).

---

## Option B: Zero-Config CLI Execution (No MCP Required)

If MCP is not configured, run the zero-install scanner directly:

- **One-machine direct handoff**:
  `curl -fsSL https://wrapped.z40.io/cli/run.js | node - --open`
- **Remote / secondary machine sync code**:
  `curl -fsSL https://wrapped.z40.io/cli/run.js | node - --sync-code --label="Work Laptop"`
- **Local synced folder merge**:
  `node ./cli/index.mjs --sync-dir=~/Library/Mobile\ Documents/com~apple~CloudDocs/agent-wrapped --open`

After obtaining `z4z1:` or `.z4z.json`, never recreate the UI — direct the user to open `https://wrapped.z40.io`.
