The Google Ads MCP Server enables MCP clients to interact with the Google Ads API through natural language prompts, providing comprehensive authentication management, data querying, and GAQL assistance.
Authentication Management: Check auth status, switch/refresh gcloud configurations, or complete OAuth login via device flow. Supports multiple authentication methods including Application Default Credentials (ADC), existing authorized_user JSON files, and interactive OAuth device flow.
Resource Discovery: List accessible Google Ads accounts and discover GAQL queryable resources (e.g., campaign, ad_group) using the
list_resourcestool.Data Querying: Execute raw GAQL queries with pagination support and multiple output formats (table, JSON, CSV) via
execute_gaql_query.Performance Reporting: Retrieve performance metrics at various levels (account, campaign, ad_group, ad) with common filters like status, name, minimum clicks, or impressions using
get_performance.GAQL Assistance: Access offline-first cheat sheets and official documentation snippets for syntax help, best practices, and query examples through the
gaql_helptool.Flexible Deployment: Easy installation and execution as an NPM package (via
npxor global install) or direct execution from source code.Environment Configuration: Key settings like
GOOGLE_ADS_DEVELOPER_TOKENand authentication credential paths are configurable via environment variables.
Provides comprehensive tools for managing Google Ads campaigns through the Google Ads API, including GAQL query execution with pagination, performance data retrieval with filtering and currency conversion, resource discovery, and account management with GCloud/ADC authentication support.
MCP Server for Google Ads
TypeScript implementation of an MCP server for Google Ads API with GCloud/ADC authentication. Provides tools for campaign management, performance reporting, and account operations with Multi-Customer Center (MCC) support.
Table of Contents
Prerequisites
Node.js 18+ and npm
A GCP project with the Google Ads API enabled
Ensure the credentials you use (user/ADC) have the Service Usage Consumer role on that project (grants
serviceusage.services.use)A Google Ads Developer Token is required:
Quick Start
Using npx (Recommended)
Authentication
The server uses Google Application Default Credentials (ADC) for secure authentication. This is the recommended approach as it provides automatic token refresh and secure credential management.
How Authentication Works
Application Default Credentials (ADC): The server first attempts to use ADC, which automatically finds credentials in this order:
Environment variable
GOOGLE_APPLICATION_CREDENTIALSpointing to a credential fileUser credentials from
gcloud auth application-default loginService account attached to the compute resource (GCE, Cloud Functions, etc.)
CLI Token Fallback: If enabled with
GOOGLE_ADS_GCLOUD_USE_CLI=true, the server can fall back to usinggcloud auth print-access-tokenfor authenticationAutomatic Token Refresh: Both methods handle token refresh automatically
Setting Up Authentication
Method 1: ADC via gcloud (Recommended)
Method 2: Existing ADC File
Place your ADC file at .auth/adc.json in the project directory, or set GOOGLE_APPLICATION_CREDENTIALS to point to your authorized_user JSON file.
Method 3: OAuth Device Flow
Use manage_auth { "action": "oauth_login" } with GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables to create an ADC file interactively.
Environment Variables
Required
GOOGLE_ADS_DEVELOPER_TOKEN: Your Google Ads API developer token (required for all API calls)
Optional
GOOGLE_ADS_ACCOUNT_ID(optional): Default Google Ads account ID (10-digit customer ID without dashes). Used as the default customer for all operations when not specified explicitly.GOOGLE_ADS_MANAGER_ACCOUNT_ID(optional): For Multi-Customer Center (MCC) accounts - the manager account ID that acts as the login customer. Required when accessing accounts under an MCC. This is typically your MCC account ID (10-digit numeric ID, no dashes). Note: you can override this per call using thelogin_customer_id(aka MCC/manager account id) parameter in tools likeexecute_gaql_queryandget_performance.GOOGLE_APPLICATION_CREDENTIALS(optional): Path to an ADC credentials file (authorized_user JSON). Takes precedence over default ADC locations.GOOGLE_ADS_QUOTA_PROJECT_ID(optional): GCP project ID used for quota/billing. Helps avoid 403 errors due to missing quota. Typically your active gcloud project ID.GOOGLE_ADS_API_VERSION(optional): API version string (e.g., v20, v21, v22). Defaults to v21 if unset. Supports format normalization ("21" → "v21").GOOGLE_OAUTH_CLIENT_IDandGOOGLE_OAUTH_CLIENT_SECRET(optional): Desktop OAuth client credentials used bymanage_authwithaction: "oauth_login"to create local ADC. Only needed if you cannot use gcloud.GOOGLE_ADS_ACCESS_TOKEN(optional): Used by unit tests; for mocked tests this can be any non-empty string. When set, bypasses ADC. For real API calls prefer ADC; if used, this must be a real OAuth 2.0 access token with the Google Ads scope and will not auto-refresh.
Example Configuration
Client-Specific Instructions
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\\Claude\\claude_desktop_config.json (Windows):
Claude Code
Install and configure with a single command:
For more details, see the Claude Code MCP documentation.
Cursor
Add to your MCP settings in Cursor. Go to Cursor Settings > Features > Model Context Protocol:
For detailed setup instructions, see the Cursor MCP documentation.
VS Code
Install the MCP extension and add the server configuration:
Install the "MCP Manager" extension from the marketplace
Open Command Palette (
Ctrl+Shift+P/Cmd+Shift+P)Run "MCP: Add Server"
Configure the server:
For more information, see the VS Code MCP documentation.
Local Installation
For local development or when you want to run from source:
1. Clone and Build
2. Configure Your MCP Client
3. Development Mode
For development with auto-reload:
Multi-Tenant Mode
Multi-tenant mode allows hosted deployments to accept Google Ads credentials at connection time (no filesystem storage) and keep them immutable for the session lifecycle.
Enable via environment:
ENABLE_RUNTIME_CREDENTIALS=true(default: false)RUNTIME_CREDENTIAL_TTLSession TTL in seconds (default: 3600)MAX_CONNECTIONSMaximum in-memory sessions (default: 1000)CONNECTION_SWEEP_INTERVALCleanup interval in seconds (default: 300)VERIFY_TOKEN_SCOPEOptional. Whentrue, validates Ads scope at session establishmentALLOWED_CUSTOMER_IDSOptional allowlist of customer IDs (comma-separated)GOOGLE_OAUTH_CLIENT_ID/GOOGLE_OAUTH_CLIENT_SECRETOptional, for refresh flowsHTTPS_PROXYOptional proxy for outbound requestsNODE_TLS_REJECT_UNAUTHORIZEDFor proxy/cert handling when requiredSTRICT_IMMUTABLE_AUTHOptional. Whentrue, blocks re-setting credentials for an existing session (default allows overwrite with a warning)OBSERVABILITY_ENABLEDOptional. Set tofalseto disable structured JSON logs (default enabled). Alternatively setOBSERVABILITY=off.
Behavioral differences when enabled:
Credentials must be provided via
set_session_credentialsNo fallback to ADC/env credentials
manage_authis disabledEach tool call must include
session_keyDeveloper token is required in provided credentials
Sticky sessions required for multi-process deployments
Session tools:
set_session_credentialsRequest:
Response:
{ "status": "success", "session_key": "...", "expires_in": 3600 }
get_credential_statusRequest:
{ "session_key": "f47ac10b-58cc-4372-a567-0e02b2c3d479" }Response:
{ "has_credentials": true, "expires_in": 3542, "has_refresh_token": true, "masked_token": "ya29****abcd" }
end_sessionRequest:
{ "session_key": "f47ac10b-58cc-4372-a567-0e02b2c3d479" }Response:
{ "status": "session_ended" }
Using standard tools in multi-tenant mode: include session_key in inputs. Example:
Client usage examples
Establish session, then execute a GAQL query and get performance with
session_key:
refresh_access_token
When a refresh_token is provided and OAuth client env is set, this tool refreshes the access token for the session.
Request
Response (success)
Response (invalid grant)
Observability
The server emits structured JSON events to stderr (12-factor style) for application-side collection. Each event includes:
Control via env:
OBSERVABILITY_ENABLED=false(disable)OBSERVABILITY=off(disable)
Error Payloads
All tools return structured error payloads when failures occur:
Common codes include: ERR_INPUT, ERR_NOT_ENABLED, ERR_IMMUTABLE_AUTH, ERR_INVALID_GRANT, ERR_INSUFFICIENT_SCOPE, and HTTP_<status> for API responses.
Live Multi-Tenant Integration Test (optional)
You can run a live multi-tenant test flow using environment-provided credentials. Recommended gating:
Set
VITEST_REAL=1andENABLE_RUNTIME_CREDENTIALS=trueProvide runtime test credentials via env (examples):
TEST_ACCESS_TOKEN,TEST_REFRESH_TOKEN,TEST_DEVELOPER_TOKENTEST_LOGIN_CUSTOMER_ID,TEST_QUOTA_PROJECT_ID
Steps:
Call
set_session_credentialswith test env valuesRun
execute_gaql_queryandget_performancewithsession_keyOptionally call
refresh_access_tokento validate token refreshOptionally set
VERIFY_TOKEN_SCOPE=trueto validate scope against live APIOptionally pass
ALLOWED_CUSTOMER_IDSto validate allowlist enforcement
Keep the existing single-tenant live tests as primary validation; multi-tenant live tests are optional and depend on environment-provided credentials.
Per-Session Rate Limiting (Optional)
Token-bucket rate limiting protects quotas on a per-session basis when multi-tenant mode is enabled.
Env (defaults in parentheses):
ENABLE_RATE_LIMITING(true)REQUESTS_PER_SECOND(10)RATE_LIMIT_BURST(20)
Error payload on limit:
Rate limiting is enforced only in multi-tenant mode and only for session-bound tools.
Available Tools
1. manage_auth - Authentication management
Note: When ENABLE_RUNTIME_CREDENTIALS=true (multi-tenant mode), this tool is disabled and returns an error. Use the session tools instead.
Comprehensive authentication management tool with multiple actions:
action: 'status' (default)
Environment inspection: Shows all Google Ads environment variables
ADC file discovery: Locates and validates Application Default Credentials files
Token validation: Checks access token presence and scopes via Google OAuth2 API
Scope verification: Tests Google Ads API access by calling
listAccessibleCustomersAccount enumeration: Counts accessible customer accounts under current credentials
Troubleshooting hints: Provides guidance when authentication issues are detected
action: 'oauth_login'
Device OAuth flow: Interactive browser-based authentication using OAuth client credentials
Requires env vars:
GOOGLE_OAUTH_CLIENT_IDandGOOGLE_OAUTH_CLIENT_SECRETSaves ADC file: Creates
authorized_userJSON at.auth/adc.jsonScope validation: Automatically verifies Google Ads API access after completion
Sets credentials: Updates
GOOGLE_APPLICATION_CREDENTIALSfor immediate use
action: 'switch'
Configuration switching: Changes active gcloud configuration
Requires:
config_nameparameterAuto-execution: Runs
gcloud config configurations activate <name>whenallow_subprocess=trueGuidance: Provides next steps for refreshing ADC credentials with correct scopes
action: 'refresh'
Credential refresh: Re-authenticates ADC with required Google Ads scopes
Auto-execution: Runs
gcloud auth application-default loginwith proper scopesToken verification: Prints access token to verify successful authentication
Scope testing: Validates Google Ads API access after refresh
action: 'set_project'
Project configuration: Sets default GCP project for gcloud
Requires:
project_idparameterCommand:
gcloud config set project <project_id>
action: 'set_quota_project'
Quota project setup: Sets ADC quota project for billing attribution
Requires:
project_idparameterCommand:
gcloud auth application-default set-quota-project <project_id>
Safety Features
Dry-run mode: Set
allow_subprocess: falseto see planned commands without executiongcloud detection: Automatically checks for gcloud CLI availability before execution
Error handling: Provides clear error messages and installation links when gcloud is missing
Timeout protection: Commands have built-in timeouts to prevent hanging
Example user prompts:
2. list_resources - List Google Ads resources
Lists various Google Ads resources with support for hierarchical relationships and multiple output formats.
Supported resource types:
accounts- List accessible customer accountscampaigns- List campaignsad_groups- List ad groupsads- List adskeywords- List keywordsextensions- List ad extensions
Example user prompts:
3. execute_gaql_query - Execute Google Ads Query Language queries
Executes custom GAQL queries for advanced data retrieval and analysis with automatic pagination support.
Example user prompts:
4. get_performance - Get performance metrics
Retrieves performance metrics and reports for campaigns, ad groups, ads, and keywords with flexible filtering and segmentation.
Example user prompts:
5. gaql_help - Google Ads Query Language reference
Provides interactive help and documentation for Google Ads Query Language (GAQL), including available resources, fields, functions, and operators.
Example user prompts:
Development
Setup
Running Tests
Project Structure
License
MIT
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables interaction with Google Ads through the Google Ads API using GCloud authentication. Supports GAQL query execution, performance data retrieval, account management, and resource discovery with pagination and multiple output formats.