Skip to main content
Glama
README.md
# AgentOps

**Browser Automation Agent** — an MCP server that browses the web, checks conditions, and takes autonomous action. Combined with n8n for notifications and fully Dockerized for portability.

This is not a chatbot. AgentOps is a real agentic automation system: it navigates pages, extracts data, evaluates conditions, sends notifications, and can fill forms autonomously.

---

## Architecture

```
┌──────────────┐     ┌─────────────────────────────────────────────┐     ┌───────────┐     ┌─────────────┐
│  MCP Client  │────▶│           AgentOps MCP Server               │────▶│ n8n Webhook│────▶│ Email/Slack │
│ (Claude etc) │     │  ┌───────────┐  ┌──────────────────────┐   │     │ (free/host)│     │ Notification │
└──────────────┘     │  │ FastAPI   │  │   Playwright Agent   │   │     └───────────┘     └─────────────┘
                     │  │ Dashboard │──│ Navigate → Extract    │   │
┌──────────────┐     │  │ :8000     │  │ → Screenshot → Form  │   │
│   Browser    │     │  └───────────┘  └──────────────────────┘   │
│ (your app)   │────▶│                                          │     ┌───────────┐
└──────────────┘     │  ┌──────────────────┐  ┌───────────────┐  │────▶│  SQLite   │
                     │  │ Condition Checker │  │   Scheduler   │  │     │  (logs)   │
┌──────────────┐     │  │ price/text/stock  │  │   (periodic)  │  │     └───────────┘
│  Dashboard   │────▶│  │ + Groq LLM fallback│  │               │  │
│  Web UI      │     │  └──────────────────┘  └───────────────┘  │
└──────────────┘     └─────────────────────────────────────────────┘
```

**Flow**: MCP Client / Dashboard → MCP Server → Playwright Agent → Condition Check → (if met) n8n Webhook → Notification

---

## Features

- **5 MCP Tools**: `check_url_condition`, `get_check_history`, `create_scheduled_check`, `get_agent_activity_log`, `trigger_form_fill`
- **Condition Types**: `price_below:X`, `price_above:X`, `text_contains:Y`, `text_absent:Y`, `stock_available`, `stock_unavailable`, or custom (Groq LLM)
- **Scheduled + On-Demand Checks**: periodic via APScheduler or instant "Run Now"
- **n8n Integration**: webhook-triggered notifications (email, Slack, or any n8n-supported channel)
- **Full Activity Log**: every action logged to SQLite with timestamps and screenshots
- **Dark/Light Theme Dashboard**: real-time updates, screenshot previews, one-click check creation
- **100% Free Stack**: Groq free tier, Playwright (OSS), SQLite, self-hosted n8n

---

## Quick Start (Docker — Recommended)

### Prerequisites

- [Docker](https://docs.docker.com/get-docker/) and Docker Compose installed

### One-Command Start

```bash
git clone <your-repo> && cd AgentOps
docker-compose up --build
```

That's it. Two containers spin up:

| Service | URL | Description |
|---------|-----|-------------|
| AgentOps Dashboard | http://localhost:8000 | Web UI, API, MCP tools |
| n8n Editor | http://localhost:5678 | Workflow automation |

### Set Up n8n Notifications

1. Open http://localhost:5678 in your browser
2. Click **"Import from File"** and upload `n8n-workflow.json`
3. The workflow receives webhooks from AgentOps and can send to:
   - **Email** (configure SMTP credentials in n8n — Settings > Credentials > SMTP)
   - **Slack** (add your webhook URL to the Slack node)
   - **Any channel** n8n supports (Discord, Telegram, PagerDuty, etc.)
4. Toggle the imported workflow to **Active** (top-right switch)
5. Test by clicking **"Test Webhook"** in the AgentOps dashboard header

---

## Quick Start (Manual)

### Prerequisites

- Python 3.11+
- [Playwright browsers installed](https://playwright.dev/python/docs/browsers)

### Install

```bash
cd AgentOps
pip install -r requirements.txt
playwright install chromium
```

### Configure (optional)

```bash
cp .env.example .env
# Edit .env — add your GROQ_API_KEY (free at console.groq.com) for custom condition evaluation
```

### Run

```bash
# Dashboard + API server
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000

# MCP server (stdio transport, for Claude Desktop etc.)
python -m app.mcp_server
```

To use with Claude Desktop, add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "agentops": {
      "command": "python",
      "args": ["-m", "app.mcp_server"],
      "cwd": "/path/to/AgentOps"
    }
  }
}
```

---

## MCP Tools Reference

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `check_url_condition` | Navigate to URL, extract data, evaluate condition | `url`, `condition`, `selector?` |
| `get_check_history` | Get past check results for a URL | `url` |
| `create_scheduled_check` | Create a periodically-running check | `url`, `condition`, `interval?`, `selector?` |
| `get_agent_activity_log` | Full activity log with all agent actions | (none) |
| `trigger_form_fill` | Autonomously fill and submit a web form | `url`, `form_data` (JSON) |

### Condition Formats

```
price_below:50          → True if any price on page < 50
price_above:20          → True if any price > 20
text_contains:In Stock  → True if page text contains "In Stock"
text_absent:Sold Out   → True if text does NOT contain "Sold Out"
stock_available         → True if stock signals found
stock_unavailable       → True if out-of-stock signals found
(anything else)         → Evaluated by Groq LLM (requires API key)
```

---

## Demo Script

Once AgentOps is running, here's what to show:

1. **Open Dashboard** at http://localhost:8000 — see 3 pre-seeded demo checks
2. **Click "▶ Run"** on any check — watch the activity log populate with navigation, extraction, condition evaluation, and screenshot
3. **Create a New Check** — click "+ New Check", enter a books.toscrape.com URL, set a condition, and run it
4. **View Screenshots** — click any screenshot in the activity log to see full-size visual proof
5. **Toggle Theme** — click the moon/sun icon in the header
6. **Set Up n8n** — import the workflow, activate it, and trigger a condition to see a real notification

### Example MCP Client Session

```
You: Check if the book at https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html
    has a price below £100. Use the .price_color selector.

→ AgentOps calls check_url_condition(url, "price_below:100", ".price_color")
→ Navigates to page, extracts "£51.77", evaluates: price 51.77 < 100 → MET
→ If n8n is configured, sends notification webhook
→ Returns full result with screenshot path
```

---

## Demo Safety

All default/seeded checks use **[books.toscrape.com](https://books.toscrape.com)** — a dedicated web scraping practice site. No real e-commerce or business sites are targeted by default.

---

## Project Structure

```
AgentOps/
├── app/
│   ├── main.py                  # FastAPI entry point, lifespan, seed data
│   ├── mcp_server.py            # MCP server with 5 tools (stdio transport)
│   ├── services.py              # Orchestrator: browser + checker + DB + notifications
│   ├── config.py                # Settings (env vars, defaults)
│   ├── agent/
│   │   ├── browser.py           # Playwright: navigate, extract, screenshot, form fill
│   │   ├── checker.py           # Condition evaluation (built-in + Groq LLM)
│   │   └── scheduler.py         # APScheduler for periodic checks
│   ├── database/
│   │   └── db.py                # SQLite: checks, activity_log, scheduled_checks
│   ├── notifications/
│   │   └── n8n.py               # Webhook caller for n8n
│   └── dashboard/
│       ├── routes.py            # FastAPI API endpoints
│       └── templates/
│           └── index.html        # Dashboard UI (dark/light theme)
├── Dockerfile
├── docker-compose.yml
├── n8n-workflow.json            # Import into n8n
├── requirements.txt
├── .env.example
└── README.md
```

---

## Free Tier Stack

| Component | Tool | Cost |
|-----------|------|------|
| LLM | Groq (Llama-3.3-70b-versatile) | Free |
| Browser Automation | Playwright (OSS) | Free |
| Database | SQLite | Free |
| Workflow/Notifications | n8n (self-hosted) | Free |
| MCP Protocol | mcp Python SDK | Free |
| Containerization | Docker | Free |

---

## License

MIT