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. Your browser does not support the video tag. For a simpler setup experience, we offer ready-to
Add this skill
npx mdskills install gomarble-ai/google-ads-mcp-serverComprehensive Google Ads API integration with excellent OAuth setup and well-documented tools
1# Google Ads MCP Server π23[](https://opensource.org/licenses/MIT)4[](https://www.python.org/downloads/)5[](https://github.com/jlowin/fastmcp)67**A FastMCP-powered Model Context Protocol server for Google Ads API integration with automatic OAuth 2.0 authentication**89Connect 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.1011<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>1213## Easy One-Click Setup1415For a simpler setup experience, we offer ready-to-use installers:1617π **Download installer -** [https://gomarble.ai/mcp](https://gomarble.ai/mcp)1819## Join our community for help and updates2021π **Slack Community -** [AI in Ads](https://join.slack.com/t/ai-in-ads/shared_invite/zt-3f17k0kwl-kJskxR0FtcKJZhEYjc4X_A)2223## Try Facebook ads mcp server also2425π **Facebook Ads MCP -** [Facebook Ads MCP](https://github.com/gomarble-ai/facebook-ads-mcp-server)2627## β¨ Features2829- π **Automatic OAuth 2.0** - One-time browser authentication with auto-refresh30- π **Smart Token Management** - Handles expired tokens automatically31- π **GAQL Query Execution** - Run any Google Ads Query Language queries32- π’ **Account Management** - List and manage Google Ads accounts33- π **Keyword Research** - Generate keyword ideas with search volume data34- π **FastMCP Framework** - Built on the modern MCP standard35- π₯οΈ **Claude Desktop Ready** - Direct integration with Claude Desktop36- π‘οΈ **Secure Local Storage** - Tokens stored locally, never exposed3738## π Available Tools3940| Tool | Description | Parameters | Example Usage |41|------|-------------|------------|---------------|42| `list_accounts` | List all accessible Google Ads accounts | None | "List all my Google Ads accounts" |43| `run_gaql` | Execute GAQL queries with custom formatting | `customer_id`, `query`, `manager_id` (optional) | "Show me campaign performance for account 1234567890" |44| `run_keyword_planner` | Generate keyword ideas with metrics | `customer_id`, `keywords`, `manager_id`, `page_url`, date range options | "Generate keyword ideas for 'digital marketing'" |4546**Note:** All tools automatically handle authentication - no token parameters required!4748## π Quick Start4950### Prerequisites5152Before setting up the MCP server, you'll need:53- Python 3.10+ installed54- A Google Cloud Platform account55- A Google Ads account with API access5657## π§ Step 1: Google Cloud Platform Setup5859### 1.1 Create Google Cloud Project60611. **Go to [Google Cloud Console](https://console.cloud.google.com/)**622. **Create a new project:**63 - Click "Select a project" β "New Project"64 - Enter project name (e.g., "Google Ads MCP")65 - Click "Create"6667### 1.2 Enable Google Ads API68691. **In your Google Cloud Console:**70 - Go to "APIs & Services" β "Library"71 - Search for "Google Ads API"72 - Click on it and press "Enable"7374### 1.3 Create OAuth 2.0 Credentials75761. **Go to "APIs & Services" β "Credentials"**772. **Click "+ CREATE CREDENTIALS" β "OAuth 2.0 Client ID"**783. **Configure consent screen (if first time):**79 - Click "Configure Consent Screen"80 - Choose "External" (unless you have Google Workspace)81 - Fill required fields:82 - App name: "Google Ads MCP"83 - User support email: Your email84 - Developer contact: Your email85 - Click "Save and Continue" through all steps864. **Create OAuth Client:**87 - Application type: **"Desktop application"**88 - Name: "Google Ads MCP Client"89 - Click "Create"905. **Download credentials:**91 - Click "Download JSON" button92 - Save file as `client_secret_[long-string].json` in your project directory9394## π§ Step 2: Google Ads API Setup9596### 2.1 Get Developer Token97981. **Sign in to [Google Ads](https://ads.google.com)**992. **Go to Tools & Settings** (wrench icon in top navigation)1003. **Under "Setup", click "API Center"**1014. **Accept Terms of Service** if prompted1025. **Click "Apply for token"**1036. **Fill out application form:**104 - Describe your use case (e.g., "MCP integration for campaign analysis")105 - Provide technical details about your implementation1067. **Submit and wait for approval** (usually 1-3 business days)107108**Note:** You'll initially get a test token with limited functionality. After testing, you can apply for production access.109110### 2.2 Find Your Developer Token111112Once approved:1131. **Return to API Center in Google Ads**1142. **Copy your Developer Token** (format: `XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`)115116## π§ Step 3: Installation & Setup117118### 3.1 Clone and Install119120```bash121# Clone the repository122git clone https://github.com/yourusername/google-ads-mcp-server.git123cd google-ads-mcp-server124125# Create virtual environment (recommended)126python3 -m venv .venv127source .venv/bin/activate # On Windows: .venv\Scripts\activate128129# Install dependencies130pip install -r requirements.txt131```132133### 3.2 Environment Configuration134135Create a `.env` file in your project directory:136137```bash138# Copy the example file139cp .env.example .env140```141142Edit `.env` with your credentials:143144```bash145# Required: Google Ads API Developer Token146GOOGLE_ADS_DEVELOPER_TOKEN=your_developer_token_here147148# Required: Path to OAuth credentials JSON file (downloaded from Google Cloud)149GOOGLE_ADS_OAUTH_CONFIG_PATH=/full/path/to/your/client_secret_file.json150```151152**Example `.env` file:**153```bash154GOOGLE_ADS_DEVELOPER_TOKEN=ABCDEFG1234567890155GOOGLE_ADS_OAUTH_CONFIG_PATH=/Users/john/google-ads-mcp/client_secret_138737274875-abc123.apps.googleusercontent.com.json156```157158## π₯οΈ Step 4: Claude Desktop Integration159160### 4.1 Locate Claude Configuration161162Find your Claude Desktop configuration file:163164**macOS:**165```bash166~/Library/Application Support/Claude/claude_desktop_config.json167```168169**Windows:**170```bash171%APPDATA%\Claude\claude_desktop_config.json172```173174### 4.2 Add MCP Server Configuration175176Edit the configuration file and add your Google Ads MCP server:177178```json179{180 "mcpServers": {181 "google-ads": {182 "command": "/full/path/to/your/project/.venv/bin/python",183 "args": [184 "/full/path/to/your/project/server.py"185 ]186 }187 }188}189```190191**Real Example:**192```json193{194 "mcpServers": {195 "google-ads": {196 "command": "/Users/marble-dev-01/workspace/google_ads_with_fastmcp/.venv/bin/python",197 "args": [198 "/Users/marble-dev-01/workspace/google_ads_with_fastmcp/server.py"199 ]200 }201 }202}203```204205**Important:**206- Use **absolute paths** for all file locations207- On Windows, use forward slashes `/` or double backslashes `\\` in paths208- Replace `your_developer_token_here` with your actual developer token209210### 4.3 Restart Claude Desktop211212Close and restart Claude Desktop to load the new configuration.213214## π Step 5: First-Time Authentication215216### 5.1 Trigger OAuth Flow2172181. **Open Claude Desktop**2192. **Try any Google Ads command**, for example:220 ```221 "List all my Google Ads accounts"222 ```223224### 5.2 Complete Authentication2252261. **Browser opens automatically** to Google OAuth page2272. **Sign in** with your Google account (the one with Google Ads access)2283. **Grant permissions** by clicking "Allow"2294. **Browser shows success page**2305. **Return to Claude** - your command will complete automatically!231232### 5.3 Verify Setup233234After authentication, you should see:235- A `google_ads_token.json` file created in your project directory236- Your Google Ads accounts listed in Claude's response237238## π Usage Examples239240### Basic Account Operations241242```243"List all my Google Ads accounts"244245"Show me the account details and which ones have active campaigns"246```247248### Campaign Analysis249250```251"Show me campaign performance for account 1234567890 in the last 30 days"252253"Get conversion data for all campaigns in the last week"254255"Which campaigns have the highest cost per conversion?"256```257258### Keyword Research259260```261"Generate keyword ideas for 'digital marketing' using account 1234567890"262263"Find keyword opportunities for 'AI automation' with search volume data"264265"Research keywords for the page https://example.com/services"266```267268### Custom GAQL Queries269270```271"Run this GAQL query for account 1234567890:272SELECT campaign.name, metrics.clicks, metrics.cost_micros273FROM campaign274WHERE segments.date DURING LAST_7_DAYS"275276"Get keyword performance data:277SELECT ad_group_criterion.keyword.text, metrics.ctr, metrics.average_cpc278FROM keyword_view279WHERE metrics.impressions > 100"280```281282## π Advanced GAQL Examples283284### Campaign Performance with Revenue285```sql286SELECT287 campaign.id,288 campaign.name,289 metrics.clicks,290 metrics.impressions,291 metrics.cost_micros,292 metrics.conversions,293 metrics.conversions_value294FROM campaign295WHERE segments.date DURING LAST_30_DAYS296ORDER BY metrics.cost_micros DESC297```298299### Keyword Performance Analysis300```sql301SELECT302 campaign.name,303 ad_group_criterion.keyword.text,304 ad_group_criterion.keyword.match_type,305 metrics.ctr,306 metrics.average_cpc,307 metrics.quality_score308FROM keyword_view309WHERE segments.date DURING LAST_7_DAYS310 AND metrics.impressions > 100311ORDER BY metrics.conversions DESC312```313314### Device Performance Breakdown315```sql316SELECT317 campaign.name,318 segments.device,319 metrics.clicks,320 metrics.cost_micros,321 metrics.conversions322FROM campaign323WHERE segments.date DURING LAST_30_DAYS324 AND campaign.status = 'ENABLED'325```326327## π Project Structure328329```330google-ads-mcp-server/331βββ server.py # Main MCP server332βββ oauth/333β βββ __init__.py # Package initialization334β βββ google_auth.py # OAuth authentication logic335βββ google_ads_token.json # Auto-generated token storage (gitignored)336βββ client_secret_[long-string].json # Your OAuth credentials (gitignored)337βββ .env # Environment variables (gitignored)338βββ .env.example # Environment template339βββ .gitignore # Git ignore file340βββ requirements.txt # Python dependencies341βββ LICENSE # MIT License342βββ README.md # This file343```344345## π Security & Best Practices346347### File Security348- β **Credential files are gitignored** - Never committed to version control349- β **Local token storage** - Tokens stored in `google_ads_token.json` locally350- β **Environment variables** - Sensitive data in `.env` file351- β **Automatic refresh** - Minimal token exposure time352353### Recommended File Permissions354```bash355# Set secure permissions for sensitive files356chmod 600 .env357chmod 600 google_ads_token.json358chmod 600 client_secret_*.json359```360361### Production Considerations3621. **Use environment variables** instead of `.env` files in production3632. **Implement rate limiting** to respect API quotas3643. **Monitor API usage** in Google Cloud Console3654. **Secure token storage** with proper access controls3665. **Regular token rotation** for enhanced security367368## π οΈ Troubleshooting369370### Authentication Issues371372| Issue | Symptoms | Solution |373|-------|----------|----------|374| **No tokens found** | "Starting OAuth flow" message | β Normal for first-time setup - complete browser authentication |375| **Token refresh failed** | "Refreshing token failed" error | β Delete `google_ads_token.json` and re-authenticate |376| **OAuth flow failed** | Browser error or no response | Check credentials file path and internet connection |377| **Permission denied** | "Access denied" in browser | Ensure Google account has Google Ads access |378379### Configuration Issues380381| Issue | Symptoms | Solution |382|-------|----------|----------|383| **Environment variables missing** | "Environment variable not set" | Check `.env` file and Claude config `env` section |384| **File not found** | "FileNotFoundError" | Verify absolute paths in configuration |385| **Module import errors** | "ModuleNotFoundError" | Run `pip install -r requirements.txt` |386| **Python path issues** | "Command not found" | Use absolute path to Python executable |387388### Claude Desktop Issues389390| Issue | Symptoms | Solution |391|-------|----------|----------|392| **Server not connecting** | No Google Ads tools available | Restart Claude Desktop, check config file syntax |393| **Invalid JSON config** | Claude startup errors | Validate JSON syntax in config file |394| **Permission errors** | "Permission denied" on startup | Check file permissions and paths |395396### API Issues397398| Issue | Symptoms | Solution |399|-------|----------|----------|400| **Invalid customer ID** | "Customer not found" | Use 10-digit format without dashes: `1234567890` |401| **API quota exceeded** | "Quota exceeded" error | Wait for quota reset or request increase |402| **Invalid developer token** | "Authentication failed" | Verify token in Google Ads API Center |403| **GAQL syntax errors** | "Invalid query" | Check GAQL syntax and field names |404405### Debug Mode406407Enable detailed logging for troubleshooting:408409```python410# Add to server.py for debugging411import logging412logging.basicConfig(level=logging.DEBUG)413```414415### Getting Help416417If you encounter issues:4184191. **Check the error message carefully** - it usually indicates the exact problem4202. **Verify all file paths** are absolute and correct4213. **Ensure environment variables** are properly set4224. **Check Google Cloud Console** for API quotas and billing4235. **Restart Claude Desktop** after any configuration changes424425## π Advanced Configuration426427### HTTP Transport Mode428429For web deployment or remote access:430431```bash432# Start server in HTTP mode433python3 server.py --http434```435436**Claude Desktop config for HTTP:**437```json438{439 "mcpServers": {440 "google-ads": {441 "url": "http://127.0.0.1:8000/mcp"442 }443 }444}445```446447### Custom Token Storage448449Modify token storage location in `oauth/google_auth.py`:450451```python452# Custom token file location453def get_token_path():454 return "/custom/secure/path/google_ads_token.json"455```456457### Manager Account Configuration458459For managing multiple accounts under an MCC:460461```bash462# Add to .env file463GOOGLE_ADS_LOGIN_CUSTOMER_ID=123-456-7890464```465466## π€ Contributing467468We welcome contributions! Here's how to get started:469470### Development Setup471472```bash473# Fork and clone the repository474git clone https://github.com/yourusername/google-ads-mcp-server.git475cd google-ads-mcp-server476477# Create development environment478python3 -m venv .venv479source .venv/bin/activate480481# Install dependencies482pip install -r requirements.txt483484# Set up development environment485cp .env.example .env486# Add your development credentials to .env487```488489### Making Changes4904911. **Create a feature branch:** `git checkout -b feature/amazing-feature`4922. **Make your changes** with appropriate tests4933. **Test thoroughly** with different account configurations4944. **Update documentation** as needed4955. **Commit changes:** `git commit -m 'Add amazing feature'`4966. **Push to branch:** `git push origin feature/amazing-feature`4977. **Open a Pull Request** with detailed description498499### Testing Your Changes500501```bash502# Test authentication flow503python3 server.py --test-auth504505# Test API connectivity506python3 -c "507from oauth.google_auth import get_oauth_credentials508creds = get_oauth_credentials()509print('β Authentication successful!')510"511512# Test with Claude Desktop513# Add your server to Claude config and test various commands514```515516## π API Limits and Quotas517518### Google Ads API Quotas519520- **Basic access:** 15,000 operations per day521- **Standard access:** 40,000 operations per day522- **Request rate:** 1,600 requests per minute per developer token523524### Best Practices for API Usage5255261. **Cache results** when possible to reduce API calls5272. **Use date ranges** to limit data volume5283. **Batch requests** when supported5294. **Monitor usage** in Google Cloud Console5305. **Implement retry logic** for rate limit errors531532### Quota Management533534```bash535# Monitor usage in Google Cloud Console536# Go to APIs & Services β Quotas537# Search for "Google Ads API" to see current usage538```539540## π License541542This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.543544---545546### MIT License547548```549Copyright (c) 2025 Google Ads MCP Server Contributors550551Permission is hereby granted, free of charge, to any person obtaining a copy552of this software and associated documentation files (the "Software"), to deal553in the Software without restriction, including without limitation the rights554to use, copy, modify, merge, publish, distribute, sublicense, and/or sell555copies of the Software, and to permit persons to whom the Software is556furnished to do so, subject to the following conditions:557558The above copyright notice and this permission notice shall be included in all559copies or substantial portions of the Software.560561THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR562IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,563FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE564AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER565LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,566OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE567SOFTWARE.568```569570## π Roadmap571572### Upcoming Features573- π **Enhanced keyword research** with competitor analysis574- π **Built-in data visualization** with charts and graphs575- π€ **AI-powered optimization suggestions**576- π **Campaign creation and management tools**577- π **Advanced reporting capabilities**578- π **Multi-language support**579580---581582**Made with β€οΈ for the MCP community**583584*Connect your Google Ads data directly to AI assistants and unlock powerful advertising insights through natural language conversations.*585
Full transparency β inspect the skill content before installing.