Google Ads MCP Server š
A FastMCP-powered Model Context Protocol server for Google Ads API integration with automatic OAuth 2.0 authentication
Connect Google Ads API directly to Claude Desktop and other MCP clients with seamless OAuth 2.0 authentication, automatic token refresh, GAQL querying, and keyword research capabilities.
<video controls width="1920" height="512" src="https://github.com/user-attachments/assets/1dc62f47-ace4-4dcf-8009-593ef7194b43">Your browser does not support the video tag.</video>
Easy One-Click Setup
For a simpler setup experience, we offer ready-to-use installers:
š Download installer - https://gomarble.ai/mcp
Join our community for help and updates
š Slack Community - AI in Ads
Try Facebook ads mcp server also
š Facebook Ads MCP - Facebook Ads MCP
⨠Features
- š Automatic OAuth 2.0 - One-time browser authentication with auto-refresh
- š Smart Token Management - Handles expired tokens automatically
- š GAQL Query Execution - Run any Google Ads Query Language queries
- š¢ Account Management - List and manage Google Ads accounts
- š Keyword Research - Generate keyword ideas with search volume data
- š FastMCP Framework - Built on the modern MCP standard
- š„ļø Claude Desktop Ready - Direct integration with Claude Desktop
- š”ļø Secure Local Storage - Tokens stored locally, never exposed
š Available Tools
| Tool | Description | Parameters | Example Usage |
|---|---|---|---|
list_accounts | List all accessible Google Ads accounts | None | "List all my Google Ads accounts" |
run_gaql | Execute GAQL queries with custom formatting | customer_id, query, manager_id (optional) | "Show me campaign performance for account 1234567890" |
run_keyword_planner | Generate keyword ideas with metrics | customer_id, keywords, manager_id, page_url, date range options | "Generate keyword ideas for 'digital marketing'" |
Note: All tools automatically handle authentication - no token parameters required!
š Quick Start
Prerequisites
Before setting up the MCP server, you'll need:
- Python 3.10+ installed
- A Google Cloud Platform account
- A Google Ads account with API access
š§ Step 1: Google Cloud Platform Setup
1.1 Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project:
- Click "Select a project" ā "New Project"
- Enter project name (e.g., "Google Ads MCP")
- Click "Create"
1.2 Enable Google Ads API
- In your Google Cloud Console:
- Go to "APIs & Services" ā "Library"
- Search for "Google Ads API"
- Click on it and press "Enable"
1.3 Create OAuth 2.0 Credentials
- Go to "APIs & Services" ā "Credentials"
- Click "+ CREATE CREDENTIALS" ā "OAuth 2.0 Client ID"
- Configure consent screen (if first time):
- Click "Configure Consent Screen"
- Choose "External" (unless you have Google Workspace)
- Fill required fields:
- App name: "Google Ads MCP"
- User support email: Your email
- Developer contact: Your email
- Click "Save and Continue" through all steps
- Create OAuth Client:
- Application type: "Desktop application"
- Name: "Google Ads MCP Client"
- Click "Create"
- Download credentials:
- Click "Download JSON" button
- Save file as
client_secret_[long-string].jsonin your project directory
š§ Step 2: Google Ads API Setup
2.1 Get Developer Token
- Sign in to Google Ads
- Go to Tools & Settings (wrench icon in top navigation)
- Under "Setup", click "API Center"
- Accept Terms of Service if prompted
- Click "Apply for token"
- Fill out application form:
- Describe your use case (e.g., "MCP integration for campaign analysis")
- Provide technical details about your implementation
- Submit and wait for approval (usually 1-3 business days)
Note: You'll initially get a test token with limited functionality. After testing, you can apply for production access.
2.2 Find Your Developer Token
Once approved:
- Return to API Center in Google Ads
- Copy your Developer Token (format:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
š§ Step 3: Installation & Setup
3.1 Clone and Install
# Clone the repository
git clone https://github.com/yourusername/google-ads-mcp-server.git
cd google-ads-mcp-server
# Create virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt3.2 Environment Configuration
Create a .env file in your project directory:
# Copy the example file
cp .env.example .envEdit .env with your credentials:
# Required: Google Ads API Developer Token
GOOGLE_ADS_DEVELOPER_TOKEN=your_developer_token_here
# Required: Path to OAuth credentials JSON file (downloaded from Google Cloud)
GOOGLE_ADS_OAUTH_CONFIG_PATH=/full/path/to/your/client_secret_file.jsonExample .env file:
GOOGLE_ADS_DEVELOPER_TOKEN=ABCDEFG1234567890
GOOGLE_ADS_OAUTH_CONFIG_PATH=/Users/john/google-ads-mcp/client_secret_138737274875-abc123.apps.googleusercontent.com.jsonš„ļø Step 4: Claude Desktop Integration
4.1 Locate Claude Configuration
Find your Claude Desktop configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json4.2 Add MCP Server Configuration
Edit the configuration file and add your Google Ads MCP server:
{
"mcpServers": {
"google-ads": {
"command": "/full/path/to/your/project/.venv/bin/python",
"args": [
"/full/path/to/your/project/server.py"
]
}
}
}Real Example:
{
"mcpServers": {
"google-ads": {
"command": "/Users/marble-dev-01/workspace/google_ads_with_fastmcp/.venv/bin/python",
"args": [
"/Users/marble-dev-01/workspace/google_ads_with_fastmcp/server.py"
]
}
}
}Important:
- Use absolute paths for all file locations
- On Windows, use forward slashes
/or double backslashes\\in paths - Replace
your_developer_token_herewith your actual developer token
4.3 Restart Claude Desktop
Close and restart Claude Desktop to load the new configuration.
š Step 5: First-Time Authentication
5.1 Trigger OAuth Flow
- Open Claude Desktop
- Try any Google Ads command, for example:
"List all my Google Ads accounts"
5.2 Complete Authentication
- Browser opens automatically to Google OAuth page
- Sign in with your Google account (the one with Google Ads access)
- Grant permissions by clicking "Allow"
- Browser shows success page
- Return to Claude - your command will complete automatically!
5.3 Verify Setup
After authentication, you should see:
- A
google_ads_token.jsonfile created in your project directory - Your Google Ads accounts listed in Claude's response
š Usage Examples
Basic Account Operations
"List all my Google Ads accounts"
"Show me the account details and which ones have active campaigns"Campaign Analysis
"Show me campaign performance for account 1234567890 in the last 30 days"
"Get conversion data for all campaigns in the last week"
"Which campaigns have the highest cost per conversion?"Keyword Research
"Generate keyword ideas for 'digital marketing' using account 1234567890"
"Find keyword opportunities for 'AI automation' with search volume data"
"Research keywords for the page https://example.com/services"Custom GAQL Queries
"Run this GAQL query for account 1234567890:
SELECT campaign.name, metrics.clicks, metrics.cost_micros
FROM campaign
WHERE segments.date DURING LAST_7_DAYS"
"Get keyword performance data:
SELECT ad_group_criterion.keyword.text, metrics.ctr, metrics.average_cpc
FROM keyword_view
WHERE metrics.impressions > 100"š Advanced GAQL Examples
Campaign Performance with Revenue
SELECT
campaign.id,
campaign.name,
metrics.clicks,
metrics.impressions,
metrics.cost_micros,
metrics.conversions,
metrics.conversions_value
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.cost_micros DESCKeyword Performance Analysis
SELECT
campaign.name,
ad_group_criterion.keyword.text,
ad_group_criterion.keyword.match_type,
metrics.ctr,
metrics.average_cpc,
metrics.quality_score
FROM keyword_view
WHERE segments.date DURING LAST_7_DAYS
AND metrics.impressions > 100
ORDER BY metrics.conversions DESCDevice Performance Breakdown
SELECT
campaign.name,
segments.device,
metrics.clicks,
metrics.cost_micros,
metrics.conversions
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
AND campaign.status = 'ENABLED'š Project Structure
google-ads-mcp-server/
āāā server.py # Main MCP server
āāā oauth/
ā āāā __init__.py # Package initialization
ā āāā google_auth.py # OAuth authentication logic
āāā google_ads_token.json # Auto-generated token storage (gitignored)
āāā client_secret_[long-string].json # Your OAuth credentials (gitignored)
āāā .env # Environment variables (gitignored)
āāā .env.example # Environment template
āāā .gitignore # Git ignore file
āāā requirements.txt # Python dependencies
āāā LICENSE # MIT License
āāā README.md # This fileš Security & Best Practices
File Security
- ā Credential files are gitignored - Never committed to version control
- ā
Local token storage - Tokens stored in
google_ads_token.jsonlocally - ā
Environment variables - Sensitive data in
.envfile - ā Automatic refresh - Minimal token exposure time
Recommended File Permissions
# Set secure permissions for sensitive files
chmod 600 .env
chmod 600 google_ads_token.json
chmod 600 client_secret_*.jsonProduction Considerations
- Use environment variables instead of
.envfiles in production - Implement rate limiting to respect API quotas
- Monitor API usage in Google Cloud Console
- Secure token storage with proper access controls
- Regular token rotation for enhanced security
š ļø Troubleshooting
Authentication Issues
| Issue | Symptoms | Solution |
|---|---|---|
| No tokens found | "Starting OAuth flow" message | ā Normal for first-time setup - complete browser authentication |
| Token refresh failed | "Refreshing token failed" error | ā
Delete google_ads_token.json and re-authenticate |
| OAuth flow failed | Browser error or no response | Check credentials file path and internet connection |
| Permission denied | "Access denied" in browser | Ensure Google account has Google Ads access |
Configuration Issues
| Issue | Symptoms | Solution |
|---|---|---|
| Environment variables missing | "Environment variable not set" | Check .env file and Claude config env section |
| File not found | "FileNotFoundError" | Verify a |
ā¦