Google Tag Manager MCP

io.github.A1-x-TechPublished by GitHub account A1-x-Techv1.3.2Updated Nov 7, 2026

MCP server for the Google Tag Manager API v2: containers, workspaces, tags, triggers, publishing.

VerifiedSTDIODesktop onlyDeveloper ToolsBusiness & Commerce

Overview

AI-generated overview

Local MCP server for the Google Tag Manager API v2, letting an assistant inspect accounts, containers and workspaces and draft, compile and publish tags…

What you can do
  • List and read GTM accounts, containers, workspaces, tags, triggers, variables and versions
  • Create containers and workspaces, and create, update or delete tags, triggers and variables in a workspace draft
  • Enable or disable built-in variables in a workspace
  • Compile a workspace into a container version and publish or fetch versions
  • Check connection status, run the in-chat OAuth login, log out, and call any other Tag Manager API v2 path directly
When to use it
Useful when you want an assistant to audit what fires in a real GTM container, prepare tracking changes in a draft workspace, and then deliberately compile and publish a version, instead of guessing at a setup.
Requirements
Node.js 20+ and a Google account. Either connect from the chat (OAuth client JSON path, browser consent on the same machine) or set GOOGLE_TAGMANAGER_CLIENT_ID, GOOGLE_TAGMANAGER_CLIENT_SECRET and GOOGLE_TAGMANAGER_REFRESH_TOKEN, or a short-lived GOOGLE_TAGMANAGER_ACCESS_TOKEN. The Tag Manager API must be enabled in a Google Cloud project; OAuth scopes for reading, editing, versioning and publishing are granted separately.
Before you install
Write and destructive operations exist: updating replaces the whole resource, deleting removes objects, create_version deletes the source workspace, and publish_version replaces the live configuration on every site using the container. The client secret and refresh token are passwords; the server asks for the client JSON by file path rather than pasted into chat. Anonymous telemetry is sent unless disabled with ASKADS_TELEMETRY=0, and error excerpts may include values from your request.

Installation

In SourceWeft

  1. Open Google Tag Manager MCP in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

[A1] Google Tag Manager MCP

English | Русский

[npm] [Glama] [CI] [License: MIT]

A1 Google Tag Manager MCP lets an AI app inspect and manage Google Tag Manager containers in plain language. See what fires on a page, work with tags, triggers and variables in a draft workspace, then deliberately compile and publish a version when you are ready.

It connects to the Google Tag Manager API v2 through your Google account. The difference from asking an AI to guess a GTM setup is that it works with the actual container, workspace and version you choose.

  • 25 tools. 10 operations only read GTM data; 4 create drafts or change built-in variables; 5 can alter, delete, compile or publish live configuration.
  • Connects from the conversation. Say "connect Google Tag Manager": the server walks you through the OAuth client, catches Google's redirect on 127.0.0.1 with PKCE and keeps the tokens itself — no config files, no restart.
  • Draft first. Tags, triggers and variables are created in a workspace. Publishing is a separate, explicitly destructive operation.
  • Quota-aware. GTM permits 0.25 requests per second per project; the server spaces requests by at least 4.2 seconds instead of overwhelming the API.
  • Your Google access. The server uses your OAuth credentials and requests only the Tag Manager scopes needed for reading, editing, versioning and publishing.

Start with a read-only question:

Which tags in my containers fire on the page-view trigger?

Connect the server · Explore use cases · Open technical documentation


See it work in a minute

You: List my GTM containers and show which tags fire on page view.

Assistant: Lists the containers, their workspaces, relevant triggers and the tags attached to them. Nothing changes.

You: In the Default Workspace of GTM-ABC123, prepare a GA4 configuration tag for measurement ID G-XXXXXXX on all pages.

Assistant: Shows the workspace, proposed tag and trigger configuration, then asks for confirmation before creating the draft.

You: Confirm the draft.

Assistant: Creates the tag in the workspace. It does not publish the container; compiling and publishing a version remains a separate step.

Contents

Quick start

You need Node.js 20+ and a Google account. Credentials are not required at install time — the server connects from the conversation.

  1. Add the server to your AI app.
  2. Say "connect Google Tag Manager": the assistant walks you through creating the OAuth client and approving access without editing config files.
  3. Start with the read-only question above.
Codex

In the app:

  1. Open Settings → MCP servers.
  2. Select Add server.
  3. Choose STDIO, then enter npx -y mcp-google-tagmanager@latest and the three environment variables below.
VariableValue
GOOGLE_TAGMANAGER_CLIENT_IDYour Google OAuth client ID
GOOGLE_TAGMANAGER_CLIENT_SECRETYour Google OAuth client secret
GOOGLE_TAGMANAGER_REFRESH_TOKENYour Google OAuth refresh token
  1. Select Save, then Restart.

From the command line:

bash
codex mcp add google-tagmanager \  -- npx -y mcp-google-tagmanager@latest
bash
codex mcp list

Codex MCP documentation

Claude Code
bash
claude mcp add \  --transport stdio \  --scope user \  google-tagmanager \  -- npx -y mcp-google-tagmanager@latest
bash
claude mcp list

Claude Code MCP documentation

Claude Desktop

The current official path is Settings → Extensions. For a custom desktop extension, open Advanced settings → Extension Developer → Install Extension…, select a .mcpb file and follow the prompts.

This repository currently publishes an npm stdio package and does not contain a .mcpb bundle. For Claude Desktop builds that still support local configuration, use the following JSON stdio configuration as a fallback:

json
{  "mcpServers": {    "google-tagmanager": {      "command": "npx",      "args": ["-y", "mcp-google-tagmanager@latest"]    }  }}

In those builds, save it to ~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows.

Claude Desktop MCP documentation

Cursor

Add a user-level server to ~/.cursor/mcp.json on macOS/Linux or %USERPROFILE%\.cursor\mcp.json on Windows:

json
{  "mcpServers": {    "google-tagmanager": {      "type": "stdio",      "command": "npx",      "args": ["-y", "mcp-google-tagmanager@latest"]    }  }}

Cursor MCP documentation

VS Code

Run MCP: Open User Configuration from the Command Palette and add:

json
{  "servers": {    "google-tagmanager": {      "type": "stdio",      "command": "npx",      "args": ["-y", "mcp-google-tagmanager@latest"]    }  }}

Check it with MCP: List Servers.

VS Code MCP documentation

What you can ask it to do

Understand the current setup

  • List the GTM accounts and containers I can access.
  • Which tags fire on page view in this workspace?
  • Show the trigger and variable configuration for this tag.
  • Which built-in variables are enabled?

Prepare tracking changes in a draft

  • Create a workspace for the checkout tracking change.
  • Prepare a GA4 tag and a trigger for a specific event.
  • Enable the click variables needed for this trigger.
  • Update this tag after showing me the complete replacement configuration.

Release a version deliberately

  • Compile this workspace into a version named April release.
  • Show the compiler errors, if any.
  • Publish version 42 after I confirm the version and its changes.

How GTM changes are connected

GTM has a clear release path:

  1. An account contains one or more containers.
  2. A container has workspaces for draft changes.
  3. Tags, triggers and variables belong to a workspace.
  4. Compiling a workspace creates a container version and removes the source workspace. GTM provides a replacement workspace.
  5. Publishing makes a selected container version live.

This server can inspect each step. It does not treat a draft as a release: version creation and publishing are separate operations.

What can change

OperationWhat happensConfirmation boundary
List accounts, containers, workspaces, tags, triggers, variables and versionsReads GTM configurationNo change
Create a container or workspaceAdds a new GTM objectChanges GTM
Create a tag, trigger or variableAdds a draft object to a workspaceChanges a draft workspace
Enable or disable built-in variablesChanges the workspace configurationChanges a draft workspace
Update a tag, trigger or variableReplaces the complete resource, protected by its fingerprintPotentially destructive
Delete a tag, trigger or variableRemoves the selected objectDestructive
Compile a workspaceCreates a version and deletes the source workspaceDestructive
Publish a versionMakes a selected version liveDestructive
Raw API requestCan call API methods without a dedicated toolPotentially destructive

The AI client decides how it asks for confirmation. The server marks read-only, write and destructive operations so the client can distinguish inspection from a real change.

Getting access

Google Tag Manager requires OAuth 2.0; an API key is not enough. There are two ways in, and the first one needs no configuration files.

Connect from the chat (recommended)

Say "connect Google Tag Manager" and the assistant runs the flow with you:

  1. setup_instructions prints the checklist: create or select a Google Cloud project, enable Tag Manager API, configure the consent screen and create a Desktop app OAuth client.
  2. Download that client's JSON ("Download JSON") and give the assistant its path — set_client stores it owner-only. The secret never goes through the conversation.
  3. start_login returns a Google consent link. Open it on this machine and approve; the code comes back to a one-shot listener on 127.0.0.1 (PKCE), never through the chat.
  4. finish_login exchanges the code and saves the tokens to ~/.config/mcp-google-tagmanager/credentials.json (mode 0600) and verifies them with a real Tag Manager API call — so an API that is still switched off is caught right there.

The tokens are re-read on every call, so the connection works immediately — no restart of the AI app. auth_status shows what is connected, logout revokes and deletes it.

Environment variables (CI, unattended installs)

  1. Create or select a Google Cloud project and enable the Tag Manager API. A project without that API enabled receives no 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. The OAuth 2.0 Playground can do this if you enable Use your own OAuth credentials.

  4. Request these scopes together:

    text
    https://www.googleapis.com/auth/tagmanager.readonlyhttps://www.googleapis.com/auth/tagmanager.edit.containershttps://www.googleapis.com/auth/tagmanager.edit.containerversionshttps://www.googleapis.com/auth/tagmanager.publish

The scopes are separate: reading, editing, compiling versions and publishing each need their corresponding permission. Treat the client secret and refresh token as passwords.

Configuration

Every variable is optional — with none of them the server connects from the chat.

VariableRequiredDescription
GOOGLE_TAGMANAGER_CLIENT_IDNo*OAuth client ID.
GOOGLE_TAGMANAGER_CLIENT_SECRETNo*OAuth client secret.
GOOGLE_TAGMANAGER_REFRESH_TOKENNo*OAuth refresh token.
GOOGLE_TAGMANAGER_ACCESS_TOKENNo*Short-lived alternative to the OAuth trio.
GOOGLE_TAGMANAGER_OAUTH_PORTNoFixed loopback port for the in-chat login; useful over SSH port forwarding.
GOOGLE_TAGMANAGER_API_BASENoTag Manager API base URL override.
GOOGLE_TAGMANAGER_TIMEOUT_MSNoPer-request timeout; default 60000 ms.
GOOGLE_TAGMANAGER_MAX_RETRIESNoMaximum retries on temporary failures; default 3.
GOOGLE_TAGMANAGER_MIN_INTERVAL_MSNoMinimum request spacing; default 4200 ms.

* Provide either the OAuth trio or an access token. Access tokens expire in about an hour and are not refreshed automatically.

Data and telemetry

The server runs locally and sends GTM API requests and OAuth refresh requests to Google. Its anonymous telemetry contains a random installation ID, package version, AI client and Node.js/operating-system versions, and tool names. It does not send OAuth tokens, GTM data, tool arguments or prompts. For each tool call it also sends the outcome and, on failure, an excerpt of the error text with e-mails, addresses, tokens, numbers of 4+ digits and quoted text replaced by #; a value from your request can appear in it if the error text contains it.

Disable telemetry for A1 MCP servers with:

bash
ASKADS_TELEMETRY=0

Limits and background work

  • GTM is rate-limited. The API allows 0.25 requests per second per project, so the server serializes calls at least 4.2 seconds apart. Broad audits can therefore take time.
  • Temporary limits are retried carefully. 429 and Google quota 403 responses use exponential backoff and Retry-After. Reads retry after network and 5xx failures; writes are not replayed after an uncertain failure.
  • There is no background monitoring. The server runs only when your AI app calls it. If the app supports scheduled tasks, it can periodically inspect a container or its live version.
  • A workspace disappears when compiled. Before calling create_version, save anything you need from the workspace and inspect the returned replacement workspace path.

Technical documentation

Support

Found a bug or need a scenario? Create an issue or write in Telegram.


[Две Моны дают пять]

You made it to the end!

Source: README.md at commit a196bd7

Tools

25

auth_status

Google connection status

Shows whether this server is connected to Google: token presence and source (env variables or a stored in-chat login), expiry, the Google account email, granted vs missing OAuth scopes, where the credentials file lives and where the OAuth client comes from. Makes no network calls and never returns the token itself. Call it first when other tools report the server is not connected.

Takes no parameters.

setup_instructions

Setup instructions

Step-by-step checklist for connecting this server to Google: creating a Google Cloud project and a Desktop-app OAuth client, publishing the consent screen (mandatory — Testing-mode refresh tokens die after 7 days), downloading the client JSON and handing its PATH to set_client. Works without any credentials; the checklist shortens to 'enable the API + log in' when an OAuth client is already configured (one client serves the whole mcp-google-* line). Never asks the user to paste secrets into the chat.

Takes no parameters.

set_client

Save the OAuth client

Saves the OAuth client credentials from the JSON file downloaded from Google Cloud Console ('Download JSON' on a Desktop-app client). Pass the file PATH — the secret must never be pasted into the chat. The client is stored once in the shared ~/.config/mcp-google-auth/client.json (owner-only) and reused by every mcp-google-* server; tokens stay per-server. After this, call start_login.

Parameterspathrequired

start_login

Start the Google login

First step of connecting from the chat, without editing config files or restarting the client. Returns authorizeUrl — show it to the user as a clickable link and ask them to open it in the browser ON THIS MACHINE, pick the Google account and approve access. A one-shot listener on 127.0.0.1 catches Google's redirect; the code is exchanged locally and never passes through the chat. Does not open the browser itself. The attempt lives 10 minutes; when the browser shows the success page, call finish_login.

Takes no parameters.

finish_login

Finish the Google login

Second step: waits up to 20 s for the browser consent to finish, saves the tokens to an owner-only file and verifies the login with a read-only identity call, returning the account email and the granted scopes. After success every tool works immediately — no client restart. If the user granted only part of the requested permissions, the login is still saved and missingScopes lists what will not work. Logging in under a different Google account replaces the previous login (its refresh token is revoked best-effort) and the response carries previousAccountEmail so the change never goes unnoticed.

Takes no parameters.

logout

Disconnect from Google

Revokes the stored token at Google (oauth2.googleapis.com/revoke) and deletes the local credentials file. Tokens supplied via env variables are NOT touched — remove them from the MCP client config manually; envTokenStillSet in the response says whether any are still in effect.

Takes no parameters.

list_accounts

List GTM accounts

Lists all Google Tag Manager accounts the authorized user can access. Returns { account: [{ accountId, name, path, fingerprint }], nextPageToken }. All ids are strings. This is the entry point: every other tool needs an accountId (or a path) from here.

Parameterspage_token

get_account

Get a GTM account

Gets one Google Tag Manager account by id. Returns the Account resource: { accountId, name, path, fingerprint, shareData }.

Parametersaccount_idrequired

list_containers

List containers

Lists the containers of a GTM account. Returns { container: [{ containerId, name, publicId (e.g. GTM-XXXXXX), usageContext, path, fingerprint, tagManagerUrl }], nextPageToken }.

Parametersaccount_idrequiredpage_token

get_container

Get a container

Gets one container by account id + container id. Returns the Container resource including publicId (the GTM-XXXXXX snippet id), usageContext and fingerprint.

Parametersaccount_idrequiredcontainer_idrequired

create_container

Create a container

Creates a new container in a GTM account. usage_context declares the platform, e.g. ["web"]; other values include androidSdk5, iosSdk5, server. Returns the created Container with its server-assigned containerId and publicId. Requires the tagmanager.edit.containers scope.

Parametersnamerequiredaccount_idrequiredusage_contextrequired

list_workspaces

List workspaces

Lists the workspaces of a container. Returns { workspace: [{ workspaceId, name, description, path, fingerprint }], nextPageToken }. Workspaces are mandatory in GTM v2: every tag/trigger/variable operation needs a workspaceId, and a "Default Workspace" always exists — call this first.

Parametersaccount_idrequiredpage_tokencontainer_idrequired

get_workspace

Get a workspace

Gets one workspace by account id + container id + workspace id. Returns the Workspace resource with its fingerprint.

Parametersaccount_idrequiredcontainer_idrequiredworkspace_idrequired

create_workspace

Create a workspace

Creates a new workspace in a container — an isolated draft where tags, triggers and variables are edited before being compiled into a version. Returns the created Workspace with its server-assigned workspaceId. Requires the tagmanager.edit.containers scope.

Parametersnamerequiredaccount_idrequireddescriptioncontainer_idrequired

list_tags

List tags

Lists the tags of a workspace. Returns { tag: [{ tagId, name, type (e.g. html, gaawe), parameter: [{ type, key, value, list, map }], firingTriggerId, blockingTriggerId, paused, path, fingerprint, tagManagerUrl }], nextPageToken }.

Parametersaccount_idrequiredpage_tokencontainer_idrequiredworkspace_idrequired

list_triggers

List triggers

Lists the triggers of a workspace. Returns { trigger: [{ triggerId, name, type (e.g. pageview, click, customEvent), filter/customEventFilter (conditions of { type, parameter }), path, fingerprint }], nextPageToken }.

Parametersaccount_idrequiredpage_tokencontainer_idrequiredworkspace_idrequired

list_variables

List variables

Lists the user-defined variables of a workspace (built-in variables live in manage_built_in_variables). Returns { variable: [{ variableId, name, type (e.g. v = data layer, jsm = custom JS, c = constant), parameter, path, fingerprint }], nextPageToken }.

Parametersaccount_idrequiredpage_tokencontainer_idrequiredworkspace_idrequired

get_resource

Get any resource by path

Generic getter for any GTM resource by its API-relative path — tags, triggers, variables, versions, containers, workspaces. Prefer echoing the `path` field from a previous response over assembling the string yourself. Returns the full resource JSON including its current fingerprint (needed for update_entity).

Parameterspathrequired

create_entity

Create a tag, trigger or variable

Creates a tag, trigger or variable in a workspace. `body` is the resource JSON: minimally { name, type } plus type-specific parameter entries; tags also take firingTriggerId (array of trigger id strings). Example tag body: { "name": "GA4 event", "type": "gaawe", "parameter": [...], "firingTriggerId": ["12"] }. Returns the created resource with its server-assigned id and fingerprint. Requires the tagmanager.edit.containers scope.

Parametersbodyrequiredaccount_idrequiredentity_typerequiredcontainer_idrequiredworkspace_idrequired

update_entity

Update a tag, trigger or variable

Updates a tag, trigger or variable by its API path. PUT semantics: this is a FULL REPLACE, not a patch — fetch the current resource with get_resource, modify it, and send the whole object back. Pass the resource's last-seen fingerprint for optimistic-concurrency safety; a mismatch fails the request. Requires the tagmanager.edit.containers scope.

Parametersbodyrequiredpathrequiredfingerprint

delete_entity

Delete a tag, trigger or variable

Deletes a tag, trigger or variable by its API path. The response is empty on success. Requires the tagmanager.edit.containers scope.

Parameterspathrequired

manage_built_in_variables

List/enable/disable built-in variables

Manages a workspace's built-in variables (pageUrl, clickText, event, ...). These are toggles, not records: action "list" returns the currently enabled ones ({ builtInVariable: [...] }), "enable" and "disable" take `types` (BuiltInVariableType enum values) and switch them on/off. Enable/disable require the tagmanager.edit.containers scope.

Parameterstypesactionrequiredaccount_idrequiredcontainer_idrequiredworkspace_idrequired

create_version

Create a container version from a workspace

Compiles a workspace into an immutable Container Version (the unit that gets published). SIDE EFFECT: the source workspace is DELETED and replaced by a fresh one — the response's newWorkspacePath points to the replacement; use it for any further edits, or old workspace paths will 404. Returns { containerVersion (with containerVersionId and full tag/trigger/variable snapshots), syncStatus, newWorkspacePath }. A compile failure comes back as compilerError=true with HTTP 200 and is reported as an error. Requires the tagmanager.edit.containerversions scope (edit.containers is NOT sufficient).

Parametersnamenotesaccount_idrequiredcontainer_idrequiredworkspace_idrequired

publish_version

Publish, inspect or fetch the live container version

Container-version operations. action "publish" pushes a version live (replacing the currently published one; requires the tagmanager.publish scope; version_id required, fingerprint recommended). action "get" fetches one version by version_id. action "live" fetches the currently published version of the container (no version_id needed). Publish responses can carry compilerError=true with HTTP 200 — reported as an error. Returns the ContainerVersion (publish wraps it as { containerVersion, compilerError }).

Parametersactionrequiredaccount_idrequiredversion_idfingerprintcontainer_idrequired

raw_request

Raw Tag Manager API call

Escape hatch to call any Google Tag Manager API v2 path directly, for endpoints without a dedicated tool (environments, folders, templates, zones, workspace :sync / :quick_preview, version_headers, ...). `path` is relative to /tagmanager/v2/, e.g. "accounts/1/containers/2/environments". `query` values may be arrays for repeated params. Requests go through the same OAuth, rate limiter and retries as every other tool.

Parametersbodypathrequiredquerymethod

Version history

5
  1. v1.3.2LatestNov 5, 2026
  2. v1.3.1Oct 31, 2026
  3. v1.3.0Oct 31, 2026
  4. v1.2.0Sep 21, 2026
  5. v1.1.0Sep 16, 2026

Score

90% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts
  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts