gtm-tag-architect
This MCP server lets you audit, fix, and enhance Google Tag Manager containers through a set of automated GTM tools.
Audit a GTM container — detects duplicate tags, missing triggers, unconsented pixels, and blocking scripts (local JSON or live API).
Deduplicate tags — removes duplicate GA4 and Meta Pixel tags and consolidates triggers.
Apply Consent Mode v2 — configures default consent state and enforces consent requirements on analytics/marketing tags.
Add tag recipes — quickly add pre-configured GA4, Meta Pixel, LinkedIn Insight, or PostHog tags with your IDs.
Generate dataLayer types — creates TypeScript definitions and helper push functions for E-commerce, SaaS, Lead Gen, or Content tracking.
Audits and manages Google Ads pixels within GTM, ensuring proper tagging and consent compliance.
Provides tools for managing Google Tag Manager containers, diagnosing tag/trigger defects, enforcing Consent Mode v2, and generating dataLayer contracts.
Audits and manages Meta (Facebook) pixels, deduplicates tags, and ensures Consent Mode v2 compliance.
Integrates PostHog tracking into GTM, providing diagnostic and remediation capabilities for PostHog tags.
Click on "Deploy 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., "@gtm-tag-architect audit my GTM container"
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.
gtm-tag-architect
A public, production-ready plugin for Google Antigravity, Claude Code, and Cursor that connects to Google Tag Manager via the Model Context Protocol (MCP).
It provides an interactive /setup command that interviews developers and marketers about their site, diagnoses container defects (duplicates, missing triggers, Consent Mode v2 violations), and generates optimized tracking taxonomies and dataLayer contracts for both TypeScript (Next.js/React) and PHP (WordPress/Laravel/Symfony).
Features
/setupInteractive Command: Guides you through a 3-stage interview and audit workflow.Deep Container Diagnostics: Audits duplicate GA4/Meta tags, orphaned triggers, unconsented marketing pixels, and render-blocking scripts.
Automated Remediation: Deduplicates tags and enforces Google Consent Mode v2 (or provides an explicit opt-out bypass for internal/US tools).
Multi-Framework dataLayer Contracts: Generates typed TypeScript definitions (
dataLayer.d.ts) or native PHP classes (GtmDataLayer.php) for WordPress, Laravel, Symfony, and custom backends.Industry Tracking Matrices: Pre-built taxonomy runbooks for E-Commerce, SaaS/PLG, B2B Lead Gen, and Technical Portfolios.
Dual-Mode MCP Server: Runs live against Google Tag Manager REST API v2 or audits local exported container JSON files offline (Zero API setup).
Related MCP server: mcp-gtm-ga4
Documentation & Guides
📖 Complete GTM MCP Setup & Credentials Guide: Detailed walkthrough for obtaining Google Cloud Service Account keys, GTM container permissions, GA4 Measurement IDs, Meta Pixels, LinkedIn Insight tags, and PostHog keys.
Quickstart: How to Connect via MCP
Mode 1: Offline JSON Export (Zero API Setup)
In GTM, go to Admin > Export Container and save as
container.json.Configure your MCP client to point to the file via
GTM_OFFLINE_CONTAINER_PATH.
Mode 2: Live Google Tag Manager API
Enable Tag Manager API in Google Cloud Console.
Create a Service Account, download the JSON key, and add the service account email in GTM Admin > User Management with Read or Edit permissions.
Set
GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json.
(See the Complete Setup Guide for step-by-step instructions with screenshots and permission configurations.)
MCP Client Configuration
For Google Antigravity
Clone or place this repository into your workspace or global customizations directory:
# In your project's .agents/plugins/ or ~/.gemini/config/plugins/
git clone https://github.com/jarnielcataluna/gtm-tag-architect.gitAntigravity will automatically discover the plugin, expose the /setup slash command, and register the MCP server defined in mcp_config.json.
For Claude Code / Claude Desktop
Register the server in your claude_desktop_config.json or project MCP settings:
{
"mcpServers": {
"gtm-tag-architect": {
"command": "node",
"args": ["/path/to/gtm-tag-architect/bin/gtm-mcp.js"],
"env": {
"GTM_OFFLINE_CONTAINER_PATH": "./fixtures/sample-ecommerce-container.json"
}
}
}
}For Cursor IDE
Open Cursor Settings > Features > MCP Servers.
Click + Add New MCP Server.
Name:
gtm-tag-architect| Type:command| Command:node /path/to/gtm-tag-architect/bin/gtm-mcp.js
Usage
Run the /setup Command
Inside Antigravity or Claude Code:
/setupThe agent will interview you about:
Site Type & Industry: E-Commerce, SaaS, Lead Gen, Content, Portfolio
Framework: Next.js/React, WordPress, Laravel, Symfony, or Vanilla PHP
Required Pixels: GA4, Meta, LinkedIn, Google Ads, PostHog
Privacy Strategy: Enforce Consent Mode v2 (Strict GDPR) vs. Opt-Out / Direct Firing
It then performs a diagnostic audit and presents you with an action menu to fix defects, apply consent rules, and export clean dataLayer contracts.
Testing & Local Audit
You can run the offline diagnostic test harness against the included test fixture:
npm install
npm run audit-fixtureLicense
MIT
Available Tools
5 toolsgtm_add_tag_recipeB
Adds a pre-configured tag recipe (GA4 Core, Meta Pixel, PostHog, or LinkedIn) to the container workspace.
Inputs: recipe (required), pixelId, containerPath, measurementId.
gtm_apply_consent_modeA
Configures Google Consent Mode v2 on all analytics and marketing tags (requiring ad_storage, ad_user_data, and analytics_storage).
Inputs: defaultState, containerPath.
gtm_audit_containerA
Runs a deep diagnostic audit on a Google Tag Manager container. Identifies duplicate tags, missing triggers, unconsented tracking (Consent Mode v2), and heavy blocking scripts.
Inputs: containerPath.
gtm_deduplicate_tagsA
Deduplicates GA4 configuration and Meta Pixel tags in the GTM container, consolidating firing triggers and pruning duplicate base tags.
Inputs: containerPath.
gtm_generate_datalayer_typesA
Generates production TypeScript type definitions and helper push functions for developers (E-commerce, SaaS, or Lead Gen).
Inputs: industry (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct action in the GTM workflow—audit, deduplicate, apply consent, add recipe, generate types—so an agent can usually pick the right one. Minor overlap exists where audit surfaces duplicates and consent gaps that deduplicate and apply_consent_mode then fix, but the strong action verbs keep the boundaries clear.
All tool names follow the identical `gtm_<verb>_<object>` snake_case pattern with perfect consistency. The `gtm_` prefix scopes everything to the domain, and every verb is a single lowercase action word.
Five tools is a well-scoped surface for a GTM tag-management assistant. Each tool addresses a distinct stage of the tag lifecycle—audit, cleanup, compliance, templating, and developer handoff—without feature bloat.
The core architecture workflow is well covered: audit, deduplicate, configure consent, add standard tags, and generate TypeScript datalayer helpers. Publication/preview submission and tag removal are missing, so agents may need workarounds, but the primary setup path is fully covered.
Maintenance
Related MCP Connectors
Hosted Google Tag Manager MCP server, with each action switched on or off per account.
Hosted MCP server for marketing analytics: plan tracking, draft GTM tags, audit tags. Free in beta
Hosted MCP server for GA4, Google Ads and Search Console. Google OAuth, nothing to install.
Hosted Google Analytics 4 MCP server, with each action switched on or off per account.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP Server that provides a conversational interface to Google Tag Manager API, allowing users to manage tags, triggers, variables, and containers through natural language.-
- AlicenseAqualityBmaintenanceMCP server for Google Tag Manager and GA4, enabling tag management, consent auditing, workspace versioning, and analytics reporting through natural language.11345 npm3MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for Google Tag Manager API v2, enabling programmatic management of accounts, containers, workspaces, tags, triggers, variables, and version workflows.40 npm15MIT
- AlicenseAqualityFmaintenanceAn MCP server for the Google Tag Manager API v2 that enables AI assistants to query GTM accounts, containers, tags, triggers, variables, and unpublished changes.241Apache 2.0