Google Ads + AI Agents: MCP Integration Guide
How to set up AI agents for Google Ads management using the Model Context Protocol (MCP). Covers Claude Desktop setup, common workflows, and automated optimization.
AI Agents for Google Ads
Google Ads management involves a repeating cycle: review search term reports, adjust bids, add negative keywords, test new ad copy, reallocate budgets, and check conversion tracking. Each task requires navigating the Google Ads UI or writing GAQL queries against the API. AI agents can handle most of this through natural conversation.
This guide shows how to connect AI agents to Google Ads using the Model Context Protocol (MCP) and Xylo. If you are new to MCP, read our MCP protocol explainer first.
Why MCP for Google Ads?
The Google Ads API is particularly challenging for AI agents to use directly:
-
GAQL requirement. The Google Ads API uses a custom query language. Asking an AI to write valid GAQL from scratch is error-prone -- small syntax mistakes cause failures.
-
Micros conversion. All monetary values are in micros (1,000,000 = $1.00). AI models frequently miscalculate these conversions.
-
Complex authentication. Four separate credentials are needed. Managing this in an AI agent context adds unnecessary complexity.
-
Enum-heavy responses. Status values like
ENABLED,PAUSED, campaign types likeSEARCH,DISPLAY-- AI models work better with clean, lowercase values.
MCP solves these problems by providing typed tools with clear schemas. The AI does not need to know GAQL, handle micros, or manage authentication. It calls tools like list_campaigns and gets normalized, readable data.
Setting Up Claude Desktop
Prerequisites
- A Xylo account with a connected Google Ads account
- A Xylo API key (generate from the dashboard)
- Claude Desktop installed (version 3.0 or later)
Configuration
Open your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json
Add the Xylo MCP server:
{
"mcpServers": {
"xylo-ads": {
"command": "npx",
"args": ["-y", "@xylo/mcp-server"],
"env": {
"XYLO_API_KEY": "xylo_live_your_key_here",
"XYLO_AD_ACCOUNT": "customers/1234567890"
}
}
}
}
Restart Claude Desktop. The Xylo tools will appear in the tools panel. The same tools work for Google Ads, Meta, and TikTok -- the x-ad-account format tells Xylo which platform to query.
Google Ads Workflows with AI
Search Campaign Review
You: How are my search campaigns performing this week?
Claude: [Calls list_campaigns with date_preset=last_7d]
Here is your search campaign performance for the past 7 days:
Campaign Spend Clicks Conversions CPA CTR Brand Terms $342.10 4,521 189 $1.81 18.2% Competitor Terms $567.30 1,234 23 $24.67 4.1% Generic - Running Shoes $1,203.40 3,456 45 $26.74 3.2% Long Tail - Specific Models $234.50 876 34 $6.90 7.8% Brand terms are performing well with a $1.81 CPA. The Competitor Terms campaign has a high CPA at $24.67 -- you may want to review which competitor terms are converting and pause the rest.
Budget Reallocation
You: Move $200 daily budget from the Generic campaign to Long Tail -- it has much better CPA.
Claude: [Calls get_campaign for both campaigns]
Current budgets:
- Generic - Running Shoes: $300/day
- Long Tail - Specific Models: $50/day
I will reduce Generic to $100/day and increase Long Tail to $250/day.
[Calls update_campaign for both]
Done. Updated budgets:
- Generic - Running Shoes: $100/day (was $300)
- Long Tail - Specific Models: $250/day (was $50)
Note: Large budget changes can disrupt Google's bidding algorithm. Monitor the Long Tail campaign's CPA over the next 2-3 days to ensure it holds as spend scales.
Performance Troubleshooting
You: My conversion rate dropped this week. What might be causing it?
Claude: Let me pull some data to investigate.
[Calls list_campaigns with date_preset=last_7d] [Calls list_campaigns with date_preset=previous_7d]
Comparing this week to last week:
Metric Last Week This Week Change Impressions 245,000 312,000 +27% Clicks 12,300 14,100 +15% Conversions 423 389 -8% Conv. Rate 3.44% 2.76% -20% Spend $2,145 $2,567 +20% A few observations:
- Impressions grew faster than clicks, and clicks grew faster than conversions. This suggests you are reaching a broader, less qualified audience.
- The Generic campaign increased spend by 35% but conversions stayed flat -- this is likely the main driver.
- Check if any ad groups shifted to broader match types recently, which would explain the audience expansion.
Automated Google Ads Optimization
Beyond interactive conversations, you can build automated workflows using Xylo's MCP server programmatically.
Daily Bid Adjustment Script
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "npx",
args: ["-y", "@xylo/mcp-server"],
env: {
XYLO_API_KEY: process.env.XYLO_API_KEY!,
XYLO_AD_ACCOUNT: "customers/1234567890",
},
});
const client = new Client({ name: "google-ads-optimizer", version: "1.0.0" });
await client.connect(transport);
// Pull campaign performance
const result = await client.callTool({
name: "list_campaigns",
arguments: { date_preset: "last_7d", status: "active" },
});
const campaigns = JSON.parse(result.content[0].text);
const TARGET_CPA = 20.00;
for (const campaign of campaigns.data) {
const { conversions, cost_per_conversion, spend } = campaign.insights;
// Scale campaigns beating CPA target
if (conversions >= 10 && cost_per_conversion < TARGET_CPA * 0.7) {
const newBudget = Math.min(campaign.daily_budget * 1.15, 500);
await client.callTool({
name: "update_campaign",
arguments: { campaign_id: campaign.id, daily_budget: newBudget },
});
console.log(`Scaled ${campaign.name}: $${campaign.daily_budget} -> $${newBudget}`);
}
// Reduce campaigns significantly above CPA target
if (conversions >= 5 && cost_per_conversion > TARGET_CPA * 1.5) {
const newBudget = Math.max(campaign.daily_budget * 0.8, 10);
await client.callTool({
name: "update_campaign",
arguments: { campaign_id: campaign.id, daily_budget: newBudget },
});
console.log(`Reduced ${campaign.name}: $${campaign.daily_budget} -> $${newBudget}`);
}
// Pause campaigns with high spend and no conversions
if (spend > 100 && conversions === 0) {
await client.callTool({
name: "update_campaign",
arguments: { campaign_id: campaign.id, status: "paused" },
});
console.log(`Paused ${campaign.name}: $${spend} spent, 0 conversions`);
}
}
Weekly Reporting Agent
// Fetch cross-platform data for weekly report
const googleCampaigns = await client.callTool({
name: "list_campaigns",
arguments: { date_preset: "last_7d" },
});
// Generate summary
const data = JSON.parse(googleCampaigns.content[0].text);
const totalSpend = data.data.reduce((sum: number, c: any) => sum + c.insights.spend, 0);
const totalConversions = data.data.reduce((sum: number, c: any) => sum + c.insights.conversions, 0);
const blendedCPA = totalConversions > 0 ? totalSpend / totalConversions : 0;
console.log(`Google Ads Weekly Summary:`);
console.log(` Spend: $${totalSpend.toFixed(2)}`);
console.log(` Conversions: ${totalConversions}`);
console.log(` Blended CPA: $${blendedCPA.toFixed(2)}`);
Cross-Platform AI Management
One of the key advantages of using Xylo's MCP server is cross-platform management. The same AI agent can manage Google Ads and Meta Ads in a single conversation:
You: Compare my Google and Meta campaign performance this month.
Claude: [Calls list_campaigns for both accounts]
Platform Spend Conversions CPA Best Campaign Google Ads $4,823 312 $15.46 Brand Terms ($1.81) Meta Ads $3,247 287 $11.32 Retargeting ($6.45) Total $8,070 599 $13.47 Meta is delivering 27% lower CPA overall. However, Google's Brand Terms campaign has the best individual CPA across both platforms. You might consider shifting some Meta prospecting budget to Google's Long Tail campaign, which has similar performance characteristics.
Security Best Practices
When giving AI agents access to live Google Ads accounts:
- Start read-only. Use Xylo's MCP server for reporting before enabling write operations.
- Set budget limits. Configure maximum daily budgets in Google Ads as a hard safety net.
- Use separate API keys. Create dedicated Xylo API keys for automated agents versus interactive use.
- Log all changes. Review the Xylo usage dashboard regularly to audit agent actions.
- Create in paused state. Have agents create new campaigns as paused and require human approval.
Getting Started
- Sign up for Xylo and connect your Google Ads account.
- Generate an API key from the dashboard.
- Configure the MCP server in Claude Desktop (see setup section above).
- Start with reporting queries, then graduate to budget management.
For Google Ads API fundamentals, read our getting started guide. For GAQL details, see the GAQL reference. For Meta Ads AI agents, see building AI agents for Facebook ads.
Check the API documentation for the complete endpoint reference.
Ready to simplify your ads API integration?
Get started with Xylo in minutes. One API key for every ad platform.