Google Ads MCP Server
repository·main·Indexed 20 days ago
https://github.com/googleads/google-ads-mcpAn implementation of the Model Context Protocol (MCP) that provides an interface for LLMs and AI agents to interact with the Google Ads API. It enables automated querying, metadata discovery, and reporting through tools like search, get_resource_metadata, and list_accessible_customers, as well as resources for metrics, segments, and release notes.
What's inside google-ads-mcp
- The Google Ads MCP Server is an implementation of the Model Context Protocol (MCP) that allows LLMs and AI agents to interact with the Google Ads API. It provides a set of Tools and Resources that enable agents to search for account information, retrieve metadata about API resources, and access discovery documents or metrics.
Identify Lost Opportunities via Impression Share
mainTo find opportunities lost due to ad rank, bids, or budgets, analyze impression share metrics using the
searchtool:- Query Impression Share:
- Resource:
campaign. - Fields:
campaign.name,metrics.search_impression_share,metrics.search_rank_lost_impression_share, andmetrics.search_budget_lost_impression_share.
- Resource:
- Analyze Results:
- Budget Issues: High
search_budget_lost_impression_sharesuggests the budget is too low. - Rank Issues: High
search_rank_lost_impression_sharesuggests issues with bids or ad quality.
- Budget Issues: High
- Query Impression Share:
Configure Credentials using Application Default Credentials (ADC)
mainYou can use
gcloudto set up Application Default Credentials. Ensure the credentials include the Google Ads API scope:https://www.googleapis.com/auth/adwords.Set up ADC with user credentials:
gcloud auth application-default login \ --scopes https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform \ --client-id-file=YOUR_CLIENT_JSON_FILESet up ADC with service account impersonation:
gcloud auth application-default login \ --impersonate-service-account=SERVICE_ACCOUNT_EMAIL \ --scopes=https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platformAfter running the command, note the
PATH_TO_CREDENTIALS_JSONprovided in the output for use in your MCP client configuration.gcloud auth application-default login \ --scopes https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform \ --client-id-file=YOUR_CLIENT_JSON_FILEInstall Agent Skills for Google Ads
mainThis repository provides specialized workflows called Agent Skills. The available skill is:
account-performance-diagnostics: Located inads_mcp/skills/account-performance-diagnostics. It diagnoses issues like conversion loss, low lead flow, and lost opportunities.
To use these skills, point your skills-compatible AI agent (such as Claude Code, Cursor, or Antigravity CLI) to the skill directory. For Antigravity CLI, you can copy the folder to your skills directory or reference it.
Deploy Google Ads MCP Server to Google Cloud Run
mainYou can host the Google Ads MCP server on Google Cloud Run to share it across different agents or run it as a web service. This deployment method requires authentication via an OAuth Client ID and Client Secret pair through an OAuth proxy.
Prerequisites
- A Google Cloud project.
gcloudCLI installed, authenticated, and the active project set usinggcloud config set project YOUR_PROJECT_ID.
Deployment Steps
1. Build and Push Docker Image
Use Cloud Build to push the image to Artifact Registry:
- Create a repository:
gcloud artifacts repositories create mcp-servers --repository-format=docker --location=us-central1 - Submit the build:
gcloud builds submit --tag us-central1-docker.pkg.dev/YOUR_PROJECT_ID/mcp-servers/google-ads-mcp:latest .
2. Deploy to Cloud Run
Deploy the image using
gcloud run deploy. You must provide several environment variables for the server to function correctly.3. Configure MCP Client
Update your MCP client configuration to point to the newly assigned Cloud Run URL.
gcloud run deploy google-ads-mcp \ --image us-central1-docker.pkg.dev/YOUR_PROJECT_ID/mcp-servers/google-ads-mcp:latest \ --platform managed \ --region us-central1 \ --allow-unauthenticated \ --set-env-vars="GOOGLE_PROJECT_ID=YOUR_PROJECT_ID,GOOGLE_ADS_DEVELOPER_TOKEN=YOUR_DEVELOPER_TOKEN,GOOGLE_ADS_MCP_OAUTH_CLIENT_ID=YOUR_CLIENT_ID,GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET=YOUR_CLIENT_SECRET,GOOGLE_ADS_MCP_BASE_URL=YOUR_BASE_URL,GOOGLE_ADS_MCP_JWT_SIGNING_KEY=YOUR_JWT_SIGNING_KEY,FASTMCP_HOST=0.0.0.0"Setup Google Ads MCP Server
mainTo set up the server, follow these high-level steps:
- Configure Python: Install
pipx. - Configure Developer Token: Obtain a Google Ads Developer Token with at least Explorer access.
- Enable APIs: Enable the Google Ads API in your Google Cloud project.
- Configure Credentials: Choose one of three methods:
- FastMCP OAuth Proxy: For web service deployments using dynamic user authentication.
- Application Default Credentials (ADC): Using
gcloudto authenticate locally or via service account impersonation. - Google Ads API Python Client Library: Reusing an existing
google-ads.yamlconfiguration.
- Configure MCP Client: Add the server to your client (e.g., Claude Code, Cursor, VS Code) using the appropriate configuration format.
- Configure Python: Install
Diagnose Conversion and Conversion Value Loss
mainWhen conversions or conversion value decline, follow these steps using the Google Ads MCP server:
- Discover Fields: Use
get_resource_metadatawith thecampaignorad_groupresource to verify correct field names. - Query Performance: Use the
searchtool to retrieve data.- Resource:
campaignorad_group. - Fields: Use
campaign.name,metrics.conversions,metrics.conversion_value, andmetrics.cost_micros. - Segments: Include
segments.date,segments.device, orsegments.conversion_actionto isolate the cause. - Conditions: Use date filters (e.g.,
segments.date >= 'YYYY-MM-DD') to compare periods.
- Resource:
- Analyze: Determine if the loss is isolated to specific devices or conversion actions.
- Check Uploads: If using offline conversions, inspect
offline_conversion_upload_conversion_action_summaryfor upload errors.
- Discover Fields: Use
Diagnose Low Lead Flow
mainIf lead flow has dropped, follow this systematic diagnostic approach:
- Confirm the Drop: Query conversions segmented by
segments.datefor the recent period versus the previous period. - Isolate the Cause:
- Traffic Drop: If clicks or impressions decreased, check Impression Share metrics (Budget vs. Rank) or general search volume trends.
- Conversion Rate Drop: If the ratio of conversions to clicks decreased, check breakdowns by
segments.deviceorsegments.conversion_action.
- Check Account Changes: Query the
change_eventresource to identify recent modifications to bids, budgets, or targeting that coincide with the performance drop.
Important Constraint: Queries to the
change_eventresource must include aLIMITof 10,000 or less.- Confirm the Drop: Query conversions segmented by
Configure MCP Client (Antigravity / Claude / Cursor)
mainAdd the server to your MCP client configuration. The
mcpServersblock format is standard across clients like Claude Code, Cursor, and VS Code.Example: Using Application Default Credentials (ADC) Replace
PATH_TO_CREDENTIALS_JSONandYOUR_PROJECT_IDwith your actual values.{ "mcpServers": { "google-ads-mcp": { "command": "pipx", "args": [ "run", "--spec", "git+https://github.com/googleads/google-ads-mcp.git", "google-ads-mcp" ], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON", "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID", "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN" } } } }Example: Using FastMCP OAuth Proxy (SSE/HTTP) If running as a separate process via HTTP:
{ "mcpServers": { "google-ads-mcp": { "httpUrl":"http://localhost:8080/mcp", "env": { "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID", "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN" } } } }Note on Manager Accounts: If accessing accounts through a manager account, add
GOOGLE_ADS_LOGIN_CUSTOMER_IDto yourenvobject with your manager customer ID.{ "mcpServers": { "google-ads-mcp": { "command": "pipx", "args": [ "run", "--spec", "git+https://github.com/googleads/google-ads-mcp.git", "google-ads-mcp" ], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON", "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID", "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN", "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "YOUR_MANAGER_CUSTOMER_ID" } } } }Environment variables for Google Ads MCP Cloud Run deployment
mainWhen deploying to Google Cloud Run, the following environment variables must be configured:
Variable Description GOOGLE_PROJECT_IDYour Google Cloud project ID GOOGLE_ADS_DEVELOPER_TOKENThe Google Ads developer token GOOGLE_ADS_MCP_OAUTH_CLIENT_IDThe OAuth Client ID GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRETThe OAuth Client secret GOOGLE_ADS_MCP_BASE_URLThe base URL where the MCP server is accessible (assigned by Cloud Run) GOOGLE_ADS_MCP_JWT_SIGNING_KEY(Recommended) Persistent JWT signing key across instances GOOGLE_ADS_MCP_STORAGE_TYPE(Recommended) Storage backend (e.g., redis) to persist OAuth tokensGOOGLE_ADS_MCP_STORAGE_REDIS_URL(Recommended) URL for the Redis storage backend FASTMCP_HOSTSet to 0.0.0.0to allow FastMCP to accept connections from all IP addressesConfigure Credentials using FastMCP OAuth Proxy
mainWhen running the server as a web service, you can use FastMCP's OAuth proxy for dynamic authentication. Setting these variables automatically switches the server from
stdiotransport tostreamable-http(SSE/HTTP).Required Environment Variables:
GOOGLE_ADS_MCP_OAUTH_CLIENT_ID: Your Google Cloud OAuth 2.0 Client ID.GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET: Your Google Cloud OAuth 2.0 Client Secret.GOOGLE_ADS_MCP_BASE_URL: (Optional) Base URL (defaults tohttp://localhost:8080).
Other optional variables:
GOOGLE_ADS_MCP_JWT_SIGNING_KEY: Secret key for signing FastMCP JWT tokens.GOOGLE_ADS_MCP_STORAGE_TYPE: Storage backend (filetree,redis, ormemory).GOOGLE_ADS_MCP_STORAGE_PATH: Path forfiletreestorage.GOOGLE_ADS_MCP_STORAGE_REDIS_URL: URL forredisstorage.GOOGLE_ADS_MCP_STORAGE_ENCRYPTION_KEY: Encryption key for stored tokens.GOOGLE_ADS_MCP_STORAGE_DISABLE_ENCRYPTION: Set totrueto disable encryption.
Configure and Namespace Tools via tools_config.yaml
mainYou can selectively enable/disable tools or entire categories (namespaces) and customize their prefixes using a
tools_config.yamlfile.Resolution order for configuration:
- Path specified by
GOOGLE_ADS_MCP_TOOLS_CONFIGenvironment variable. tools_config.yamlin the current working directory.- Default
tools_config.yamlbundled with the package.
If an explicitly requested file is missing or invalid, the server will fail to start.
namespaces: # Enable category 'customers' with default prefix -> "customers_list_accessible_customers" customers: true # Enable category 'search' with a custom prefix -> "query_search" search: "query" # Fine-grained control over tools in a category metadata: enabled: true prefix: "metadata" enabled_tools: - get_resource_metadata: true- Path specified by