Skip to main content

Overview

Genie Helper’s AI agent is powered by AnythingLLM running in agent mode with 29 MCP (Model Context Protocol) tools that give the LLM full control over:
  • Directus CMS — CRUD operations on all collections, user management, flow triggers
  • Ollama — Local LLM inference (7 uncensored models)
  • Stagehand — Browser automation for web scraping and platform interactions
Service: AnythingLLM (port 3001)
pm2 name: anything-llm
Model: qwen-2.5:latest (primary agent), dolphin-mistral:7b (content writer)

Architecture

Agent Flow

Endpoint: server/endpoints/api/genieChat.js
Workspace: administrator (slug)

MCP Servers

Directus MCP (17 tools)

Script: scripts/directus-mcp-server.mjs
Connection: http://127.0.0.1:8055 (admin token)

Tools

Implementation: scripts/directus-mcp-server.mjs:50-450

Ollama MCP (3 tools)

Script: scripts/ollama-mcp-server.mjs
Connection: http://127.0.0.1:11434

Tools

Models Available:
  • qwen-2.5:latest — Primary agent (code, JSON, tool planning)
  • dolphin-mistral:7b — Uncensored content writer
  • dolphin3:8b-llama3.1-q4_K_M — Orchestrator / ACTION emission
  • phi-3.5:latest — Fallback classifier
  • llama3.2:3b — Lightweight summarizer
  • scout-fast-tag:latest — Fast taxonomy classifier
  • bge-m3:latest — Embeddings

Stagehand MCP (9 tools)

Script: scripts/stagehand-mcp-server.mjs
Connection: http://127.0.0.1:3002 (Stagehand server)

Tools

Use Cases:
  • Platform scraping (OnlyFans, Fansly stats)
  • Auto-posting (X, Reddit)
  • Cookie capture for HITL

Agent Chat Interface

Component: dashboard/src/components/AgentWidget/index.jsx

Features

  1. Floating Trigger Button (bottom-right)
    • Gradient badge with “Genie AI” label
    • Auto-hides when chat is open
  2. Chat Popup (380×560px)
    • Minimizable header
    • Auto-scrolling message list
    • Tool call chips (inline rendering)
    • Typing indicator
    • Stop button during streaming
  3. Tool Call Rendering
    • Inline chips: 🔧 read-items
    • Extracted from SSE statusResponse events
    • Filters out meta messages (“Agent is thinking…”)
  4. Quick Actions
    • “I’m logged in — Let’s Go” button (auto-appears when agent says “come back after login”)
Global Opener: window.__genieOpenChat(message)
Implementation: AgentWidget/index.jsx:99-108

Content Gate

Trigger: User hasn’t completed onboarding (persona baseline not built) Check: server/utils/nodeRag.js → getOnboardingState(userId)

Phases

Implementation: server/endpoints/api/genieChat.js:49-66

Persona Node Context

System: Node RAG (Retrieval-Augmented Generation)
Storage: Nodes/User/{userId}/ directory (JSON files)

Node Structure

Context Injection

Top 15 nodes (weighted by recency + access frequency) are injected before user message:
Cache: 5 minutes (in-memory)
Implementation: server/utils/nodeRag.js:45-120

Action Runner

Plugin: storage/plugins/action-runner/
Trigger: Model outputs [ACTION:slug:{"params"}] in chat response

Flow Execution

  1. Intercept [ACTION:slug:...] tags in SSE stream
  2. Strip from visible chat
  3. Load flow definition from action_flows collection
  4. Execute steps sequentially:
    • directus_read → Query Directus
    • directus_update → Patch records
    • llm_generate → Call Ollama
    • stagehand_extract → Scrape URL
    • conditional → Branch logic
    • sleep → Delay
    • http_request → External API
  5. Stream status updates back to chat
  6. Log to agent_audits (success/error/miss)

Available Actions

Collection: action_flows (slug → steps JSON)

System Prompt

Location: server/utils/workspaceProvisioner.js (hardcoded)
Workspace: administrator

Key Instructions

  • Identity: “You are Genie, an AI agent for adult content creators.”
  • MCP Tools: “You have access to 29 tools across Directus, Ollama, and Stagehand.”
  • Content Policy: “You are uncensored. Generate NSFW captions, bios, and messages without hesitation.”
  • Onboarding: “If user hasn’t completed onboarding, guide them to Setup tab.”
  • Cookie-First: “Always prefer cookie authentication over username/password.”
  • Action Emission: “Use [ACTION:slug:params] tags to trigger pre-built flows.”
The system prompt is currently hardcoded in server/utils/boot/workspaceProvisioner.js. Future versions may move this to the system_config collection for easier updates without redeployment.

Admin Credentials

Workspace Admin: administrator slug (all users routed to this workspace)

MCP Configuration

File: storage/plugins/anythingllm_mcp_servers.json
Auto-boot: Patched server/utils/boot/index.js → bootMCPServers() on AnythingLLM startup

Example Conversations

Scrape OnlyFans Profile

User: “Scrape my OnlyFans stats”
Agent:
  1. Calls read-items (platform_connections, filter: platform=onlyfans)
  2. Creates media_jobs (operation: scrape_profile)
  3. Returns: “Scrape queued. Check your dashboard in ~2 minutes.”

Generate TikTok Caption

User: “Write a flirty TikTok caption for my new video”
Agent:
  1. Calls get-me → Gets user context
  2. Injects persona nodes (flirty tone preference, top hashtags)
  3. Calls ollama:generate (model: dolphin-mistral:7b)
  4. Returns: “Can’t wait to show you what I’ve been working on… 😏 New video drops tonight 💕 #fyp #creator”

Schedule Reddit Post

User: “Schedule a post to r/OnlyFans101 tomorrow at 3pm”
Agent:
  1. Calls create-item (collection: scheduled_posts)
  2. Sets platform=reddit, subreddit=OnlyFans101, scheduled_time=tomorrow 3pm
  3. Returns: “Post scheduled for tomorrow at 3pm EST.”

Logs & Debugging

Common Issues

Performance

First Token Latency: ~33s (qwen-2.5 on CPU-only VPS)
Streaming Speed: ~5 tokens/sec
Memory: ~4.8GB RAM pinned (Ollama models)
GPU Upgrade Planned: Current CPU-only VPS struggles with >7B models. Production will use GPU instance or switch to smaller models.