SuperAPI AI Directory

mcp-google-tagmanager

Google Tag Manager: inspect containers, prepare workspace changes and publish when ready.

Open website

About this tool

Purpose

A1 Google Tag Manager MCP is an MCP server that lets AI applications inspect and manage Google Tag Manager containers using natural language. It connects to the Google Tag Manager API v2 through your Google account, directly operating on the actual container, workspace, and version you select, rather than having the AI guess at GTM configurations.

Main capabilities

The server provides 25 tools, divided into three categories by the nature of the operation:

  • 10 read-only operations: read GTM data, such as listing accounts and containers, viewing tag, trigger, and variable configurations, checking built-in variables, etc.
  • 4 operations that create drafts or modify built-in variables: create tags, triggers, and variables in a workspace, or enable built-in variables.
  • 5 operations that can change, delete, compile, or publish live configurations: these operations are destructive and require explicit confirmation.

Typical use cases include:

  • Understanding the current setup: list accessible GTM accounts and containers, see which tags fire on page views, display tag trigger and variable configurations, view enabled built-in variables.
  • Preparing tracking changes in a draft: create a workspace, prepare a GA4 tag and triggers for specific events, enable the required click variables, update a tag after showing the full replacement configuration.
  • Publishing a version deliberately: compile a workspace into a version with a specified name, show compilation errors, publish the version after confirming the version and its changes.

How to use

Requires Node.js 20+ and a Google account. No credentials are needed at installation time; the server connects from the conversation.

Connect from the conversation (recommended)

Say "connect Google Tag Manager" to the assistant, and the assistant will guide you through the process:

  1. setup_instructions prints a checklist: create or select a Google Cloud project, enable the Tag Manager API, configure the consent screen and create a desktop app OAuth client.
  2. Download the JSON file for that client and provide the path to the assistant—set_client stores it with owner-only permissions. The secret does not pass through the conversation.
  3. start_login returns a Google consent link. Open it locally and approve; the code returns through a one-time listener on 127.0.0.1 (PKCE), not through the chat.
  4. finish_login exchanges the code and saves the token to ~/.config/mcp-google-tagmanager/credentials.json (permissions 0600), and verifies it with a real Tag Manager API call—if the API is not yet enabled, that is caught here.

The token is re-read on every call, so the connection takes effect immediately without restarting the AI application. auth_status shows what is connected, and logout revokes and deletes it.

Environment variables (CI, unattended installation)

  1. Create or select a Google Cloud project and enable the Tag Manager API. Projects without that API enabled will not get quota.
  2. Configure the OAuth consent screen and create an OAuth client. A desktop app client is suitable for local use.
  3. Authorize your Google account and obtain a refresh token. If "Use your own OAuth credentials" is enabled, the OAuth 2.0 Playground can do this.
  4. Request these scopes together:
    • https://www.googleapis.com/auth/tagmanager.readonly
    • https://www.googleapis.com/auth/tagmanager.edit.containers
    • https://www.googleapis.com/auth/tagmanager.edit.containerversions
    • https://www.googleapis.com/auth/tagmanager.publish

These scopes are separate: reading, editing, compiling versions, and publishing each require their respective permissions. Treat the client secret and refresh token as passwords.

Each variable is optional—if none are provided, the server connects from the session.

  • Provide an OAuth triplet or an access token. Access tokens expire after about one hour and are not refreshed automatically.

Add to an AI app

  • In the AI app's settings, open MCP servers, choose add server, choose STDIO, enter npx -y mcp-google-tagmanager@latest and the three environment variables, save, and restart.
  • Command line: refer to the Codex MCP documentation and the Claude Code MCP documentation.
  • Claude Desktop: the current official path is Settings → Extensions. For custom desktop extensions, open Advanced settings → Extension Developer → Install Extension…, select the .mcpb file, and follow the prompts. This repository currently publishes an npm stdio package and does not include a .mcpb bundle. For Claude Desktop builds that still support local configuration, a JSON stdio configuration can be used as a fallback, saved to ~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows.
  • Cursor: add a user-level server in ~/.cursor/mcp.json on macOS/Linux or %USERPROFILE%.cursor\mcp.json on Windows.
  • VS Code: run MCP: Open User Configuration from the command palette and add the configuration, then check with MCP: List Servers.

When to use it

  • Marketing and data analysis staff need to quickly understand the configuration of tags, triggers, and variables in a GTM container.
  • You need to prepare tracking changes (such as GA4 configuration or event triggers) but want to preview and confirm them in a workspace draft first.
  • You need to compile and publish a GTM version in a controlled way, ensuring that publishing is a separate and explicit action.
  • In CI or unattended environmentsconfigure the connection via environment variables.

Limitations

  • GTM has rate limits: the API allows 0.25 requests per second per project, and the server spaces calls at least 4.2 seconds apart, so extensive audits may take time.
  • Temporary limits are retried cautiously: 429 and Google quota 403 responses use exponential backoff and Retry-After. Reads are retried after network and 5xx failures; writes are not replayed after an uncertain failure.
  • There is no background monitoring. The server runs only when the AI app calls it. If the app supports scheduled tasks, it can periodically check the container or its live version.
  • The workspace disappears at compile time. Before calling create_version, save anything you need from the workspace, and check the returned replacement workspace path.
  • The server runs locally and sends GTM API requests and OAuth refresh requests to Google. Its anonymous telemetry includes a random installation ID, package version, AI client and Node.js/OS versions, and tool names. It does not send OAuth tokens, GTM data, tool parameters, or prompts. Telemetry can be disabled via an environment variable.
  • Requires Node.js 20+ and a Google account.
  • Access tokens expire after about one hour and are not refreshed automatically.
  • This repository currently publishes an npm stdio package and does not include a .mcpb bundle.