Skip to main content
Glama
phanindraintelligenzit-afk

MCP Server for Google Ads Meta Ads GA4

README.md
# MCP Server for Google Ads, Meta Ads & GA4

> **Connect Claude, Cursor, and any MCP-compatible AI agent directly to your ad platforms.**
> Stop switching tabs. Stop copy-pasting spreadsheets. Let your AI read, analyze, and optimize your Google Ads, Meta Ads, and GA4 data β€” all from a single conversation.

---

## 🎯 The Problem

Performance marketers, agencies, and growth teams waste **hours every week** on:

- **Manual campaign analysis** β€” logging into Google Ads, Meta Business Suite, and GA4 separately to check what's working.
- **Context switching** β€” jumping between dashboards, spreadsheets, and Slack to piece together a coherent picture.
- **Delayed reactions** β€” underperforming campaigns and budget waste go unnoticed until the weekly report lands (too late).
- **Repetitive reporting** β€” rebuilding the same performance decks every Monday morning.

Your AI assistant (Claude, Cursor, etc.) is brilliant β€” but it has **zero visibility** into your ad accounts. Until now.

---

## πŸ’‘ The Solution: 4-Agent Pipeline

This MCP server exposes a **4-agent pipeline** that turns raw ad data into actionable decisions β€” all accessible from your AI client:

| Agent | Role |
|-------|------|
| **Campaign Reader** | Pulls live campaign data from Google Ads API & Meta Ads API β€” budgets, impressions, clicks, conversions, and more. |
| **Performance Analyzer** | Identifies underperforming campaigns, budget waste, and anomalies across all connected platforms. |
| **Insight Generator** | Delivers AI-powered optimization recommendations β€” bid adjustments, audience shifts, creative fatigue alerts. |
| **Report Builder** | Generates structured weekly performance reports ready to share with stakeholders or clients. |

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     MCP Client (Claude / Cursor)                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚  MCP Protocol (stdio / HTTP)
                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   MCP Server (FastAPI + Python)                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚Campaign Readerβ”‚β†’β”‚Performance Analyzerβ”‚β†’β”‚  Insight Generator β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         β”‚                                         β”‚             β”‚
β”‚         β–Ό                                         β–Ό             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Google Ads APIβ”‚                      β”‚   Report Builder    β”‚  β”‚
β”‚  β”‚  Meta Ads API β”‚                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”‚    GA4 API    β”‚                                              β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## πŸ›  Tech Stack

| Layer | Technology |
|-------|------------|
| **Language** | Python 3.11+ |
| **Protocol** | [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) |
| **Framework** | FastAPI |
| **APIs** | Google Ads API, Meta Marketing API, Google Analytics Data API (GA4) |
| **Testing** | pytest |
| **CI/CD** | GitHub Actions |
| **Containerization** | Docker |

---

## πŸ“¦ Installation

### Prerequisites

- Python 3.11+
- Google Ads Developer Token
- Meta Business App with Marketing API access
- Google Cloud project with GA4 Data API enabled

### 1. Clone & Install

```bash
git clone https://github.com/phanindraintelligenzit-afk/mcp-server-for-google-ads-meta-ads-ga4.git
cd mcp-server-for-google-ads-meta-ads-ga4
pip install -e ".[dev]"
```

### 2. Configure Environment

```bash
cp .env.example .env
# Fill in your API credentials:
# - GOOGLE_ADS_DEVELOPER_TOKEN
# - GOOGLE_ADS_CLIENT_ID / CLIENT_SECRET / REFRESH_TOKEN
# - META_APP_ID / APP_SECRET / ACCESS_TOKEN
# - GA4_PROPERTY_ID
```

### 3. Claude Desktop Config

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "google-ads-meta-ga4": {
      "command": "python",
      "args": ["-m", "mcp_server"],
      "env": {
        "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_TOKEN",
        "META_ACCESS_TOKEN": "YOUR_TOKEN",
        "GA4_PROPERTY_ID": "YOUR_PROPERTY_ID"
      }
    }
  }
}
```

### 4. Cursor Config

Add to your Cursor `settings.json` under `mcpServers`:

```json
{
  "mcpServers": {
    "google-ads-meta-ga4": {
      "command": "python",
      "args": ["-m", "mcp_server"],
      "env": {
        "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_TOKEN",
        "META_ACCESS_TOKEN": "YOUR_TOKEN",
        "GA4_PROPERTY_ID": "YOUR_PROPERTY_ID"
      }
    }
  }
}
```

---

## πŸš€ Quick Start

Once configured, restart Claude Desktop or Cursor. The MCP server tools will be available automatically.

### Example Prompts

```
"Show me all active Google Ads campaigns with CTR below 2% this week."
"Compare Meta Ads vs Google Ads ROAS for the last 30 days."
"Generate a weekly performance report for my GA4 property."
"Which campaigns are wasting budget? Give me optimization recommendations."
"Pull conversion data from GA4 and cross-reference with Google Ads campaigns."
```

### MCP Client Config Examples

**Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):

```json
{
  "mcpServers": {
    "ad-platforms": {
      "command": "python",
      "args": ["-m", "mcp_server"],
      "cwd": "/path/to/mcp-server-for-google-ads-meta-ads-ga4"
    }
  }
}
```

**Cursor** (`.cursor/mcp.json` in project root):

```json
{
  "mcpServers": {
    "ad-platforms": {
      "command": "python",
      "args": ["-m", "mcp_server"],
      "cwd": "/path/to/mcp-server-for-google-ads-meta-ads-ga4"
    }
  }
}
```

---

## πŸ”§ API / Tools Available

| Tool | Description |
|------|-------------|
| `list_campaigns` | List all campaigns from Google Ads and/or Meta Ads |
| `get_campaign_metrics` | Fetch impressions, clicks, spend, conversions for a campaign |
| `analyze_performance` | Identify underperformers, budget waste, and anomalies |
| `get_recommendations` | AI-powered optimization suggestions |
| `generate_report` | Build a structured weekly performance report |
| `get_ga4_data` | Pull sessions, conversions, and engagement from GA4 |
| `compare_platforms` | Side-by-side Google Ads vs Meta Ads analysis |
| `audit_budget_allocation` | Detect overspend and reallocation opportunities |

---

## 🎯 Use Cases

- **Performance Marketers** β€” Automate daily monitoring and get instant optimization recommendations without leaving your AI workspace.
- **Agencies** β€” Generate client-ready reports in seconds, audit multiple ad accounts, and surface cross-client insights.
- **Growth Teams** β€” Unify Google Ads, Meta Ads, and GA4 data into a single source of truth for faster, data-driven decisions.
- **Freelancers & Consultants** β€” Deliver enterprise-grade analysis without enterprise-grade tooling costs.

---

## πŸ’° Pricing

| Tier | What's Included |
|------|-----------------|
| **Free Repo** | Full source code (MIT). Clone, test, and deploy yourself. |
| **Done-for-You Setup** | **$1,000 – $3,000** β€” We configure the server, connect your ad accounts, customize the pipeline, and get you live in days. |

*Contact us for custom enterprise deployments or multi-account agency setups.*

---

## πŸ—Ί Roadmap

- [x] Google Ads API integration
- [x] Meta Ads API integration
- [x] GA4 Data API integration
- [x] 4-agent pipeline (Campaign Reader β†’ Performance Analyzer β†’ Insight Generator β†’ Report Builder)
- [ ] Slack / email report delivery
- [ ] Automated bid adjustment suggestions with approval workflow
- [ ] TikTok Ads API integration
- [ ] LinkedIn Ads API integration
- [ ] Custom dashboard UI
- [ ] Multi-account agency management panel

---

## πŸ“„ License

MIT License β€” see [LICENSE](LICENSE) for details.

---

Built by [AIdentify](https://github.com/phanindraintelligenzit-afk/AIdentify) β€” AI Automation Marketplace.