by gomarble-ai
google-ads-mcp-server is a FastMCP-powered Model Context Protocol server that integrates the Google Ads API with AI assistants like Claude Desktop. It enables users to programmatically access Google Ads data and manage campaigns through natural language conversations.
The google-ads-mcp-server
is a FastMCP-powered Model Context Protocol server designed to integrate the Google Ads API with AI assistants like Claude Desktop. It provides programmatic access to Google Ads data and management features, enabling users to analyze performance data and manage campaigns through natural language conversations.
To use google-ads-mcp-server
, you need to follow a few steps:
client_secret_[long-string].json
file.pip install -r requirements.txt
), and configure the .env
file with your GOOGLE_ADS_DEVELOPER_TOKEN
and GOOGLE_ADS_OAUTH_CONFIG_PATH
.claude_desktop_config.json
) and add the google-ads
MCP server configuration, specifying the absolute paths to your Python executable and server.py
.google_ads_token.json
file will be created locally.Once set up, you can interact with the Google Ads API using natural language queries within Claude Desktop.
list_accounts
, run_gaql
, and run_keyword_planner
for various operations.Q: What are the common authentication issues and how to resolve them?
A: If "No tokens found" appears, it's normal for first-time setup; complete browser authentication. If "Token refresh failed," delete google_ads_token.json
and re-authenticate. For browser errors or no response during OAuth flow, check credentials file path and internet connection. If "Access denied," ensure your Google account has Google Ads access.
Q: How to troubleshoot configuration issues?
A: If "Environment variable not set," check your .env
file and Claude config. For "FileNotFoundError," verify absolute paths. If "ModuleNotFoundError," run pip install -r requirements.txt
. For "Command not found" related to Python, use the absolute path to the Python executable.
Q: What if Claude Desktop is not connecting or showing errors?
A: Restart Claude Desktop and check your configuration file syntax. If permission errors occur, check file permissions and paths.
Q: How to handle API issues like invalid customer ID or quota exceeded?
A: For "Customer not found," use the 10-digit format without dashes (e.g., 1234567890
). If "Quota exceeded," wait for the quota to reset or request an increase. For "Authentication failed" due to an invalid developer token, verify the token in Google Ads API Center. For GAQL syntax errors, check your query syntax and field names.
Q: How can I enable debug mode?
A: Add import logging
and logging.basicConfig(level=logging.DEBUG)
to server.py
for detailed logging.
Q: What are the Google Ads API quotas?
A: Basic access allows 15,000 operations per day, and standard access allows 40,000 operations per day. The request rate is 1,600 requests per minute per developer token.
Q: What are the best practices for API usage?
A: Cache results, use date ranges to limit data, batch requests when supported, monitor usage in Google Cloud Console, and implement retry logic for rate limit errors.
Q: Can I deploy the server for web or remote access?
A: Yes, you can start the server in HTTP mode using python3 server.py --http
and configure Claude Desktop with the appropriate URL (e.g., http://127.0.0.1:8000/mcp
).
Q: How can I customize the token storage location?
A: Modify the get_token_path()
function in oauth/google_auth.py
to return your desired custom path.
Q: How do I configure for a manager account (MCC)?
A: Add GOOGLE_ADS_LOGIN_CUSTOMER_ID=123-456-7890
to your .env
file.
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-use installers:
👉 Download installer - https://gomarble.ai/mcp
👉 Slack Community - AI in Ads
👉 Facebook Ads MCP - Facebook Ads MCP
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!
Before setting up the MCP server, you'll need:
client_secret_[long-string].json
in your project directoryNote: You'll initially get a test token with limited functionality. After testing, you can apply for production access.
Once approved:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
)# 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.txt
Create a .env
file in your project directory:
# Copy the example file
cp .env.example .env
Edit .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.json
Example .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
Find your Claude Desktop configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%\Claude\claude_desktop_config.json
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:
/
or double backslashes \\
in pathsyour_developer_token_here
with your actual developer tokenClose and restart Claude Desktop to load the new configuration.
"List all my Google Ads accounts"
After authentication, you should see:
google_ads_token.json
file created in your project directory"List all my Google Ads accounts"
"Show me the account details and which ones have active campaigns"
"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?"
"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"
"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"
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 DESC
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 DESC
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'
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
google_ads_token.json
locally.env
file# Set secure permissions for sensitive files
chmod 600 .env
chmod 600 google_ads_token.json
chmod 600 client_secret_*.json
.env
files in productionIssue | 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 |
Issue | Symptoms | Solution |
---|---|---|
Environment variables missing | "Environment variable not set" | Check .env file and Claude config env section |
File not found | "FileNotFoundError" | Verify absolute paths in configuration |
Module import errors | "ModuleNotFoundError" | Run pip install -r requirements.txt |
Python path issues | "Command not found" | Use absolute path to Python executable |
Issue | Symptoms | Solution |
---|---|---|
Server not connecting | No Google Ads tools available | Restart Claude Desktop, check config file syntax |
Invalid JSON config | Claude startup errors | Validate JSON syntax in config file |
Permission errors | "Permission denied" on startup | Check file permissions and paths |
Issue | Symptoms | Solution |
---|---|---|
Invalid customer ID | "Customer not found" | Use 10-digit format without dashes: 1234567890 |
API quota exceeded | "Quota exceeded" error | Wait for quota reset or request increase |
Invalid developer token | "Authentication failed" | Verify token in Google Ads API Center |
GAQL syntax errors | "Invalid query" | Check GAQL syntax and field names |
Enable detailed logging for troubleshooting:
# Add to server.py for debugging
import logging
logging.basicConfig(level=logging.DEBUG)
If you encounter issues:
For web deployment or remote access:
# Start server in HTTP mode
python3 server.py --http
Claude Desktop config for HTTP:
{
"mcpServers": {
"google-ads": {
"url": "http://127.0.0.1:8000/mcp"
}
}
}
Modify token storage location in oauth/google_auth.py
:
# Custom token file location
def get_token_path():
return "/custom/secure/path/google_ads_token.json"
For managing multiple accounts under an MCC:
# Add to .env file
GOOGLE_ADS_LOGIN_CUSTOMER_ID=123-456-7890
We welcome contributions! Here's how to get started:
# Fork and clone the repository
git clone https://github.com/yourusername/google-ads-mcp-server.git
cd google-ads-mcp-server
# Create development environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set up development environment
cp .env.example .env
# Add your development credentials to .env
git checkout -b feature/amazing-feature
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
# Test authentication flow
python3 server.py --test-auth
# Test API connectivity
python3 -c "
from oauth.google_auth import get_oauth_credentials
creds = get_oauth_credentials()
print('✅ Authentication successful!')
"
# Test with Claude Desktop
# Add your server to Claude config and test various commands
# Monitor usage in Google Cloud Console
# Go to APIs & Services → Quotas
# Search for "Google Ads API" to see current usage
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Google Ads MCP Server Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Made with ❤️ for the MCP community
Connect your Google Ads data directly to AI assistants and unlock powerful advertising insights through natural language conversations.
Reviews feature coming soon
Stay tuned for community discussions and feedback