Metadata-Version: 2.5
Name: tubesentry
Version: 0.1.2
Summary: Local-First YouTube & Performance Max Placement Waste Auditor & MCP Server
Project-URL: Homepage, https://flovv.github.io/tubesentry
Project-URL: Documentation, https://flovv.github.io/tubesentry/guide/quickstart
Project-URL: Repository, https://github.com/flovv/tubesentry
Project-URL: Changelog, https://github.com/flovv/tubesentry/releases
Author: TubeSentry Core Team
License: MIT
License-File: LICENSE
Keywords: claude-desktop,dv360,google-ads,made-for-kids,mcp-server,model-context-protocol,performance-max,placement-exclusions,youtube-ads
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Requires-Dist: httpx>=0.25.0
Requires-Dist: mcp<2.0.0,>=1.2.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: pyarrow>=14.0.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.9.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.2.0; extra == 'dev'
Description-Content-Type: text/markdown

# TubeSentry

Local-first placement auditor and Model Context Protocol (MCP) server for Google Ads and DV360.

[![CI Tests](https://github.com/flovv/tubesentry/actions/workflows/ci_tests.yml/badge.svg)](https://github.com/flovv/tubesentry/actions/workflows/ci_tests.yml)
[![Documentation](https://github.com/flovv/tubesentry/actions/workflows/deploy_docs.yml/badge.svg)](https://flovv.github.io/tubesentry/)
[![PyPI version](https://img.shields.io/pypi/v/tubesentry.svg)](https://pypi.org/project/tubesentry/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg)](https://www.python.org/)
[![M8ven Verified](https://m8ven.ai/badge/mcp/flovv-tubesentry-vkj518?v=8dc4fcf3c83d08d489cf708727c98799&variant=verified)](https://m8ven.ai/mcp/flovv-tubesentry-vkj518?s=readme)

**Documentation:** [https://flovv.github.io/tubesentry/](https://flovv.github.io/tubesentry/)

---

## Description

TubeSentry analyzes placement reports ("Where ads showed") from Google Ads (YouTube, Performance Max, Demand Gen) and Google Display & Video 360 (DV360). It categorizes placements against known risk patterns, quantifies wasted media spend, calculates an impression-weighted quality score, and generates exclusion lists for Google Ads Editor.

Processing runs 100% locally. Client placement data, impressions, and budgets never leave your machine.

**Tags:** `google-ads`, `youtube-ads`, `performance-max`, `dv360`, `adtech`, `ppc`, `mcp-server`, `placement-exclusions`, `marketing-analytics`

---

## What TubeSentry Detects

When running YouTube or Performance Max campaigns, broad placement algorithms frequently allocate budget to non-converting or unintended inventory:

* **Made for Kids (MFK):** Toddler songs and children's cartoons streamed on shared mobile devices, leading to accidental taps and COPPA compliance concerns.
* **Passive Audio & Music:** 24/7 background lo-fi streams, ambient sleep tracks, and white-noise loops where visual engagement is minimal.
* **Underage Gaming:** Channels dedicated to mobile sandbox titles (Roblox, Minecraft) that generate high view counts with negligible conversion value.
* **Foreign Script Delivery:** Placements running on non-target language scripts (Cyrillic, Devanagari, Arabic, Thai) within domestic campaigns.
* **Low-Quality Content Farms:** Automated short-form compilations designed for view arbitrage with high bounce rates.
* **Performance Sinkholes:** Placements that exceed 3x target CPA without registering conversions.
* **Creative Alignment Gap:** Optional analysis comparing your creative's intended target audience with the actual channels where impressions ran.

---

## Installation

```bash
pip install tubesentry
```

Or run directly without installation using `uvx`:

```bash
uvx --from tubesentry tubesentry --help
```

---

## Quickstart

### 1. Run a Synthetic Demo Audit

Generate a 25,000-row synthetic placement report and review the audit output:

```bash
tubesentry demo --out-dir ./demo_output
```

### 2. Audit an Exported Placement CSV

Export your placement report from Google Ads (*Reports > Predefined reports > Other > Where ads showed > Download CSV*) or DV360:

```bash
tubesentry audit where_ads_showed.csv --lang en,de --cpa 45.0
```

### 3. Compare Creative Intent to Actual Delivery

Pass your YouTube ad URL or creative brief text to compare target audience expectations against delivery reality:

```bash
tubesentry audit where_ads_showed.csv \
  --ad-url "https://youtube.com/watch?v=your_ad_id" \
  --ad-text "B2B infrastructure platform for DevOps and cloud architects"
```

### 4. Export Google Ads JavaScript Automation

Generate a copy-paste Google Ads Script snippet that automatically creates or populates an account-level Shared Placement Exclusion List:

```bash
tubesentry audit where_ads_showed.csv --export-script cleanup_placements.js
```

Paste into Google Ads (*Tools & Settings > Bulk Actions > Scripts*) and schedule to run daily or weekly.

---

## Integrations

### Google Ads Scripting Ecosystem

For media buyers who maintain automation by pasting JavaScript snippets into Google Ads, TubeSentry outputs a self-contained script with a built-in `DRY_RUN` preview mode:

```bash
tubesentry export script --report where_ads_showed.csv --out cleanup.js --list-name "TubeSentry Waste Shield"
```

* **Shared List Mode (Default):** Applies exclusions account-wide across Video, Performance Max, and Demand Gen campaigns without hitting individual campaign limits.
* **Campaigns Mode:** Targets specific campaigns matching a name filter via `--mode CAMPAIGNS`.
* **Safe Preview:** Defaults to `DRY_RUN = true` so media buyers can review logs before applying live exclusions.

### BigQuery Data Transfer Service (DTS) & dbt

For analytics and data engineering teams querying raw Google Ads Data Transfer Service tables (`p_Placement_*`), TubeSentry generates an optimized BigQuery Standard SQL query:

```bash
# Standard BigQuery SQL query
tubesentry export bigquery --out tubesentry_audit.sql --dataset google_ads_export

# dbt model format (with partitioning and clustering)
tubesentry export bigquery --out models/tubesentry_audit.sql --dbt
```

Evaluates heuristics (Made-for-Kids, passive audio, underage gaming, foreign language scripts) directly in BigQuery without moving data out of your data warehouse.

---

## Python API

TubeSentry supports localized Google Ads CSV exports (English, German, Spanish, French, Italian, Dutch):

```python
import tubesentry as ts

report = ts.audit_placements(
    report="where_ads_showed.csv",
    target_languages=["en", "de"],
    target_cpa=40.0,
    ad_url="https://youtube.com/watch?v=your_ad_id",
    ad_text="B2B cloud infrastructure monitoring for SRE teams.",
)

print(f"Audited Spend:    EUR {report.total_spend:,.2f}")
print(f"Wasted Spend:     EUR {report.total_wasted_spend:,.2f} ({report.wasted_spend_percentage:.1f}%)")
print(f"Quality Score:    {report.weighted_quality_score:.1f} / 10.0")

if report.creative_alignment:
    print(f"Alignment Score:  {report.creative_alignment.overall_alignment_score:.1f} / 10.0")
    print(f"Off-Target Spend: EUR {report.creative_alignment.off_target_spend:,.2f}")
```

---

## MCP Server (Claude Desktop, Claude Code, Cursor)

TubeSentry includes a native Model Context Protocol (FastMCP) server, allowing AI coding assistants and agents to inspect placements and channels directly.

### Claude Desktop Configuration

Add to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "tubesentry": {
      "command": "uvx",
      "args": ["--from", "tubesentry", "tubesentry-mcp"]
    }
  }
}
```

### Cursor Configuration

Add to `.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "tubesentry": {
      "command": "uvx",
      "args": ["--from", "tubesentry", "tubesentry-mcp"]
    }
  }
}
```

---

## Agent Skill

TubeSentry includes an installable skill (`youtube-placement-audit`) formatted with standard frontmatter for AI coding assistants and agent environments (Claude Code, Cursor, Antigravity, Codex).

### Install via skills.sh / npx

Install directly to your agent configuration using the open skills standard:

```bash
npx skills add flovv/tubesentry
```

### Install via TubeSentry CLI

```bash
tubesentry skill install
```

Or run without installation via `uvx`:

```bash
uvx --from tubesentry tubesentry skill install
```

This places `SKILL.md` into your workspace (`.agents/skills/` or `.claude/skills/`), providing autonomous agents with:
* Operational recipes for analyzing Google Ads / DV360 placement reports
* Waste category decision rules and CPA thresholds
* FastMCP tool invocation patterns and creative targeting fit guides

To view the raw skill instructions directly in the terminal:

```bash
tubesentry skill show
```

---

## Editions

| Feature | Open-Core (Free) | Pro (Licensed) |
| :--- | :--- | :--- |
| Waste category breakdown and percentage | Yes | Yes |
| Impression-weighted quality score (1-10) | Yes | Yes |
| Worst-offender channel reporting | Top 25 unmasked | All unmasked |
| Bundled waste seed database | Curated seed channels + heuristics | Curated seed DB + Parquet index & SQLite cache |
| Channel metadata resolution | Local heuristics | 50-ID batch YouTube API v3 enricher |
| Google Ads Editor exclusion CSV | No | Yes (reactive & 65k-capped exclusion CSVs) |
| DV360 SDF exclusion chunks | No | Yes (10,000-row SDF blocks) |
| Creative targeting fit engine | Core matching | Multimodal creative profiler |
| Client HTML presentation deck | No | Yes (single-file HTML report) |

---

## Pro Activation

TubeSentry Pro (Monthly, $199/mo) is available via [Polar](https://buy.polar.sh/polar_cl_lRuifr3uJS0LR0k6frhg3JEKBRZNQq75hv7cS2am9cX).

After purchasing, download your platform wheel (`.whl`) from the [Polar Customer Portal](https://polar.sh/spotlift/portal) and activate via CLI:

```bash
tubesentry auth --key tube_-XXXX-XXXX-XXXX --wheel path/to/tubesentry_pro-*.whl
```

Or via Python:

```python
import tubesentry as ts

ts.install_pro(api_key="tube_-XXXX-XXXX-XXXX", local_path="path/to/tubesentry_pro-*.whl")
```

---

## Security & Privacy

* **Local execution:** All CSV parsing, heuristic scoring, and database lookups run locally.
* **No cloud ingestion:** Client spend numbers, impressions, and account identifiers are never transmitted to external servers.
* **No telemetry:** The core package does not collect analytics or track usage.

---

## License

MIT License. See [LICENSE](LICENSE) for details.
