@ainative/gtm-mcp
Provides tools for creating and managing Google Ads campaigns, ad groups, ads, bidding strategies, ad extensions, audiences, and conversions.
Provides tools for managing Google Tag Manager containers, tags, triggers, auditing container health, and publishing versions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@@ainative/gtm-mcpList my GTM accounts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@ainative/gtm-mcp
Google Tag Manager and Google Ads MCP server — audit, fix, and manage GTM containers and Google Ads campaigns, budgets, conversions, placements, geo targeting, and auto-apply recommendations from AI agents (Claude, Cursor, and any MCP client).
Part of the AINative open-source tools.
57 tools across 7 categories: accounts, tags, triggers, audit, versions/publishing, and a complete Google Ads lifecycle (39 tools) — build, publish, track, and adjust campaigns end-to-end: create campaigns/ad groups/RSAs/RDAs/HTML5 ads, Performance Max, bidding strategy & bid control, ad extensions (sitelinks/callouts/snippets/call), audiences, offline gclid conversion import, geo/language targeting, budgets, placements, and auto-apply recommendations — fully programmatic, no UI required.
Keywords: google tag manager mcp, google ads mcp, gtm mcp server, google ads api mcp, conversion tracking mcp, campaign budget management, negative placement / click-fraud exclusion, geo targeting, auto-apply recommendations, recommendation subscriptions, conversion goals, Smart Bidding, PPC automation, ad spend control, Claude MCP, model context protocol, AI agent advertising tools.
Quick Start
1. Install
# Claude Code (recommended)
claude mcp add ainative-gtm-mcp npx -- -y @ainative/gtm-mcp \
-e GTM_SERVICE_ACCOUNT_KEY_PATH=/path/to/service-account.json
# Or run directly
npx @ainative/gtm-mcp2. Set up Google Cloud authentication
The server authenticates via a Google Cloud service account with Tag Manager API access. There is no browser OAuth flow — it's designed for headless/agent use.
Step 1 — Enable the Tag Manager API
Go to Google Cloud Console
Select or create a project
Navigate to APIs & Services → Library
Search for Tag Manager API (
tagmanager.googleapis.com) and click Enable
Step 2 — Create a service account
Go to IAM & Admin → Service Accounts
Click Create Service Account
Give it a name (e.g.
gtm-mcp-agent)Skip role assignment at GCP level — GTM has its own permission system
Click Done, then open the service account
Go to Keys → Add Key → Create new key → JSON
Download the JSON key file — keep it safe
Step 3 — Grant the service account access in GTM
This is the step most people miss. The GCP service account needs to be added as a user inside Google Tag Manager separately:
Go to tagmanager.google.com
Click Admin (top nav)
Under Account, click User Management
Click + → Add users
Enter the service account email (e.g.
gtm-mcp-agent@your-project.iam.gserviceaccount.com)Set permission to Publish (required for tag editing and publishing)
Save
Note: If you only need read access (auditing), Read permission is sufficient.
Step 4 — Configure the env var
export GTM_SERVICE_ACCOUNT_KEY_PATH="/path/to/service-account.json"
# Or use inline JSON (useful for CI/CD)
export GTM_SERVICE_ACCOUNT_KEY_JSON='{"type":"service_account","project_id":"...","private_key":"..."}'
# Or use Application Default Credentials
gcloud auth application-default login3. Connect to Claude Code
claude mcp add ainative-gtm-mcp npx -- -y @ainative/gtm-mcp \
-e GTM_SERVICE_ACCOUNT_KEY_PATH=/path/to/service-account.jsonOr add a .mcp.json to your project root:
{
"mcpServers": {
"ainative-gtm-mcp": {
"command": "npx",
"args": ["-y", "@ainative/gtm-mcp"],
"env": {
"GTM_SERVICE_ACCOUNT_KEY_PATH": "/path/to/service-account.json"
}
}
}
}Security: Add
.mcp.jsonto.gitignoreif it contains key paths. Use.mcp.example.jsonas a template for teammates.
4. Verify it works
Ask Claude:
List my GTM accountsExpected: your GTM account name and ID. If you get an empty array [], the service account hasn't been added to GTM yet (Step 3 above).
Related MCP server: Google Ads - AdLoop
Important: GTM vs Google Ads conversions
This MCP server manages Google Tag Manager containers — tags, triggers, variables, and publishing.
If you see events like ads_conversion_PURCHASE_1 in GA4, those may be coming from Google Ads auto-imported conversions (via GA4 ↔ Google Ads account linking), not GTM tags. In that case:
If the event fires via a GTM tag → use
gtm_find_misfiring_conversion_tagsto fix itIf the event is a GA4-imported Google Ads conversion → fix it in Google Ads → Tools → Conversions, not in GTM
To tell the difference: if your GTM container has no tags (gtm_list_tags returns []), the conversion event is coming from outside GTM.
Example: Fix a misfiring conversion tag
The most common GTM billing issue — a Google Ads conversion tag fires on every page view instead of only on purchase confirmation.
1. List your accounts:
"List my GTM accounts"
→ accountId: 123456789
2. List containers:
"List containers for account 123456789"
→ containerId: 987654321, publicId: GTM-XXXXXXX
3. Audit the container:
"Audit container 987654321 in account 123456789"
→ health score, list of issues including misfiring tags
4. Find misfiring conversion tags:
"Find misfiring conversion tags in container 987654321"
→ shows which tags fire on All Pages instead of specific events
5. Fix the tag:
"Fix tag 42 to only fire on the purchase_confirmed event"
→ gtm_fix_conversion_tag_trigger creates a scoped Custom Event trigger
and rewires the tag automatically
6. Review and publish:
"Show pending workspace changes, then publish"
→ gtm_get_workspace_status + gtm_publishTool Reference
Account & Container (3 tools)
Tool | Description |
| List all accessible GTM accounts |
| List containers in an account |
| Get container details |
Tags (4 tools)
Tool | Description |
| List all tags in a workspace |
| Get full tag configuration |
| Update a tag (trigger, params, name) |
| Delete a tag |
Triggers (4 tools)
Tool | Description |
| List all triggers |
| Get trigger configuration |
| Create a new trigger |
| Update an existing trigger |
Audit & Fix (3 tools)
Tool | Description |
| Full container audit — health score 0–100, issues list |
| Find conversion tags firing on All Pages instead of specific events |
| Fix a misfiring tag — creates scoped Custom Event trigger, rewires tag |
Versions & Publishing (4 tools)
Tool | Description |
| List workspaces |
| View pending changes before publishing |
| Create a named version from workspace changes |
| Publish workspace to live |
Google Ads (39 tools)
Full programmatic campaign lifecycle — an agent can build, launch, measure, and optimize a campaign end-to-end with no UI.
Build (campaigns, ad groups, ads, assets)
Tool | Description |
| Create a Search/Display campaign with a dedicated budget + correct network settings |
| One-call Performance Max builder — campaign + budget + asset group (headlines, descriptions, images, logo) in a single call; Google's AI optimizes across Search/Display/YouTube/Gmail |
| Create an ad group inside a campaign |
| Create an RSA (3–15 headlines, 2–4 descriptions, length-validated) |
| Create a responsive display ad |
| Create an HTML5 upload (animated) display ad from a media bundle |
| Upload an image asset by URL |
| Upload an HTML5 media-bundle (zip) asset |
Bidding & bids
Tool | Description |
| Swap bidding strategy (Maximize Clicks / Maximize Conversions / Target CPA / Target ROAS / Manual CPC) — reads back the change to confirm it landed (empty-payload swaps silently no-op) |
| Set an ad group's default max CPC bid |
| Set a specific keyword's max CPC bid |
Ad control
Tool | Description |
| Pause / enable / remove an individual ad |
| Request re-review (appeal) of a disapproved/limited ad where API-appealable; honest result for UI-only policy topics |
Ad extensions (assets)
Tool | Description |
| Create + attach a sitelink |
| Create + attach a callout (e.g. "7-Day Free Trial") |
| Create + attach a structured snippet |
| Create + attach a call (phone) extension |
Audiences & conversions (attribution)
Tool | Description |
| Attach a user-list audience (observation or targeting) |
| Create an offline (UPLOAD_CLICKS) conversion action for gclid import |
| Upload an offline conversion keyed by gclid — ties a real signup back to the ad click that drove it |
Conversions & reporting
Tool | Description |
| List all conversion actions — name, ID, counting type, status, category |
| Fix counting type (ONE_PER_CLICK vs MANY_PER_CLICK) for a conversion action |
| Audit all conversion goals — find misconfigured counting, inactive conversions |
| Include/exclude a conversion action from the primary Conversions metric & Smart Bidding (e.g. stop a PAGE_VIEW action inflating conversions) |
| Account-level performance — impressions, clicks, cost, conversions by date range |
Campaigns & budgets
Tool | Description |
| Set a campaign's daily budget (scale spend up or down) |
| Pause a campaign — stop ad serving immediately |
| Add a keyword to an ad group |
| Remove (pause) a keyword from an ad group |
Targeting & fraud protection
Tool | Description |
| Remove a campaign criterion (targeted geo/placement/keyword) by ID — e.g. stop targeting a country sending invalid traffic |
| Exclude a website/app placement (block click-fraud sites like quiz farms and junk apps) |
| Add a geo target (presence-only by default — the India-fraud-safe setting) |
| Force presence-only geo targeting on a campaign |
| Add a campaign-level negative keyword |
| Add a language target to a campaign |
Auto-apply recommendations
Tool | Description |
| List auto-apply recommendation subscriptions and their status (audit what auto-applies) |
| Turn auto-apply recommendations ON/OFF (pause budget/bid recommendations that can silently raise spend) |
Google Ads Authentication
The Google Ads tools use OAuth2 credentials. Provide them via environment variables or your ADC file:
# Option A: Explicit env vars
export GADS_CLIENT_ID="your-client-id"
export GADS_CLIENT_SECRET="your-client-secret"
export GADS_REFRESH_TOKEN="your-refresh-token"
export GOOGLE_ADS_DEVELOPER_TOKEN="your-developer-token"
export GOOGLE_ADS_CUSTOMER_ID="1234567890"
# Option B: Use Application Default Credentials (gcloud OAuth)
# Run: gcloud auth application-default login
# The server reads ~/.config/gcloud/application_default_credentials.json automatically
export GOOGLE_ADS_DEVELOPER_TOKEN="your-developer-token"
export GOOGLE_ADS_CUSTOMER_ID="1234567890"Developer token: Get yours at Google Ads API Center. A test token works for sandbox accounts; a standard token is required for production.
Note on GA4-imported conversions: If you see events like
ads_conversion_PURCHASE_1in GA4 butgads_list_conversion_actionsreturns an empty list, those conversions are GA4-imported into Google Ads (configured under Google Ads → Tools → Conversions). They are not standalone conversion actions and must be managed through the Google Ads UI.
Troubleshooting
Symptom | Cause | Fix |
| Service account not added to GTM | Add service account email in GTM → Admin → User Management |
| API not enabled | Enable at console.cloud.google.com → APIs & Services → Tag Manager API |
| Service account has Read-only | Upgrade to Publish permission in GTM User Management |
| Workspace is empty (no tags published) | Check a different workspaceId, or confirm tags exist in GTM dashboard |
Conversion event in GA4 but no matching GTM tag | Event comes from Google Ads auto-import | Fix in Google Ads → Tools → Conversions, not in GTM |
Development
git clone https://github.com/AINative-Studio/core
cd packages/mcp-servers/ainative-gtm-mcp
npm install
npm run build
npm run devLicense
MIT — AINative Studio
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
Flicense-qualityFmaintenanceMCP server for managing Google Ads, Meta Ads, LinkedIn Ads, and TikTok Ads via AI. 210+ tools including account audits, wasted spend detection, and PMax insights.Last updated2- AlicenseAqualityAmaintenanceAn MCP server that gives your AI assistant read + write access to Google Ads and GA4 — with safety guardrails that prevent accidental spend.Last updated67223MIT
- AlicenseAqualityAmaintenanceMCP server for Google Tag Manager and GA4, enabling tag management, consent auditing, workspace versioning, and analytics reporting through natural language.Last updated18642MIT
- Flicense-qualityBmaintenanceA remote MCP server for Google Tag Manager that enables AI assistants to manage GTM accounts, containers, tags, triggers, variables, and more via OAuth or service account authentication.Last updated1
Related MCP Connectors
SEO MCP server: crawl your site, find AI-visibility gaps, and ship the fix from your coding agent.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Hosted Amazon Seller Central and Amazon Ads MCP server for Claude, ChatGPT, Cursor, and agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/AINative-Studio/ainative-gtm-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server