Skip to main content
Glama
tagmanager-mcp

tagmanager-mcp

by jinchliu

Google Tag Manager MCP Server (Alpha)

🚀 Empower your AI agents to handle the whole Google Tag Manager workflow!

This repo contains the source code for running a local MCP server that interacts with APIs for Google Tag Manager.

Features

  • No frequent authentication. Standard Google ADC with your own OAuth client is all you need. Everything runs on your machine, straight against the GTM API.

  • No service account required. The server runs as you, with the GTM permissions your account already has.

  • Built for LLM context windows. A single GTM tag can be hundreds of lines of JSON; list_* tools return slim skeletons and get_* fetches full detail only when asked.

Related MCP server: unboundai-gtm-mcp-server

Tools

The server uses the Google Tag Manager API to provide Tools for use with LLMs. The most frequently used tools are:

Tool

Purpose

list_containers

Containers in an account — where every session starts

list_tags

Tags in the workspace as slim skeletons

get_tag

One tag's full configuration, on demand

get_workspace_status

Unpublished changes and merge conflicts

create_tag

Add a tag to the workspace draft

update_tag

Merge partial changes into a tag (fingerprint-checked)

delete_tag

Remove a tag (requires confirm=true)

Triggers and variables have the same four tools as tags, and versioning and publishing have their own. See Appendix I for the full list.

The write safety model:

  • Editing and going live are separate. Create/update/delete only touch the workspace draft; only publish_version changes the live site.

  • Updates are merge patches. The model sends just the fields it changes, and the server submits the entity's fingerprint, so a concurrent edit fails cleanly instead of being clobbered.

  • Deletes and publishing need confirm=true, and every destructive tool is declared with destructiveHint.

  • No blind retries on writes. Rate-limit rejections are retried, ambiguous 5xx errors are not, so a create is never silently duplicated.

Prerequisites

  • Python 3.10+

  • pipx or uv

  • The gcloud CLI

  • A Google account with access to your GTM containers

  • A GCP project (used only for quota attribution)

Setup instructions

1. Install

pipx install tagmanager-mcp

or, with uv:

uv tool install tagmanager-mcp

Either one puts a tagmanager-mcp executable on your PATH.

2. Enable the Tag Manager API on your quota project

gcloud services enable tagmanager.googleapis.com --project=YOUR_PROJECT

3. Create a Desktop OAuth client

Check out Manage OAuth Clients for how to create an OAuth client. Two choices matter here: pick application type Desktop app, and publish the app to Production, because an app left in Testing issues refresh tokens that expire after 7 days. Download the client JSON at the end — step 4 needs it.

Why your own client? Google may block gcloud's built-in one for Tag Manager scopes ("This app is blocked"), and that block is not something you can work around from your side.

4. Log in

gcloud auth application-default login \
  --client-id-file=path/to/your-client.json \
  --scopes=\
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,\
https://www.googleapis.com/auth/cloud-platform

gcloud auth application-default set-quota-project YOUR_PROJECT

The browser will warn "Google hasn't verified this app" — it is your own app; choose Advanced → Continue.

Those scopes unlock everything. Drop the lines you do not want:

Scope

Unlocks

tagmanager.readonly

Every read tool

tagmanager.edit.containers

Create / update / delete in a workspace

tagmanager.edit.containerversions

create_version

tagmanager.publish

publish_version

cloud-platform

Nothing in GTM — needed by set-quota-project

Tools outside your granted scopes fail with a clear re-login hint, and everything else keeps working.

Connect an MCP client

Configure Claude Code

claude mcp add --scope user tagmanager-mcp -- tagmanager-mcp

--scope user registers the server for every project instead of just the current directory. Verify with claude mcp list, or run /mcp inside a session.

Configure Claude Desktop

Claude Desktop needs the absolute path to the executable. Print it:

which tagmanager-mcp

Open Settings → Developer → Edit Config, which reveals claude_desktop_config.json (~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows), and add the server with the path you just printed:

{
  "mcpServers": {
    "tagmanager-mcp": {
      "command": "/Users/you/.local/bin/tagmanager-mcp"
    }
  }
}

Save the file and restart Claude Desktop — it reads the config only at startup. The tools then appear under the tools icon in the chat box.

Example prompts

  • "Which GTM accounts and containers do I have?"

  • "How many tags are in container GTM-XXXXXXX, grouped by type?"

  • "Show me the purchase tag's config and which triggers fire it."

  • "Does the current workspace have unpublished changes?"

  • "Pause every tag that fires on the checkout trigger."

  • "Create a custom-event trigger for sign_up and a GA4 event tag that fires on it."

Note on quota

The GTM API allows 10,000 requests/day and 25 requests per 100 seconds per GCP project; per-user overrides do not raise it. Ordinary audit conversations fit comfortably — just avoid sweeping every tag across many containers at once.

Appendix I: A Full List of Tools

Read

Tool

Purpose

list_accounts

GTM accounts you can access (optionally Google Tag accounts)

list_containers

Containers in an account

list_workspaces

Workspaces in a container

get_workspace_status

Unpublished changes and merge conflicts

list_tags / get_tag

Tags — skeleton list / full configuration

list_triggers / get_trigger

Triggers — skeleton list / full configuration

list_variables / get_variable

Variables — skeleton list / full configuration

list_versions

Container version headers — skeleton list

get_version / get_live_version

One version / the currently live version, with slimmed contents

Write

Tool

Purpose

create_tag / create_trigger / create_variable

Create an entity in the workspace draft

update_tag / update_trigger / update_variable

Merge partial changes into an entity

delete_tag / delete_trigger / delete_variable

Delete an entity (requires confirm=true)

create_version

Snapshot the workspace into a version (consumes the workspace; returns newWorkspacePath)

publish_version

Publish a version live (requires confirm=true)

Available Tools

24 tools
create_tagA

Creates a tag in the workspace draft.

Changes stay in the workspace until a version is published; nothing goes live. Returns the created tag including its tagId.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. tag: Tag resource body. Requires 'name' and 'type'; most types also need 'parameter' (list of {'type', 'key', 'value'} dicts) and 'firingTriggerId' (list of trigger ID strings). Minimal example: {'name': 'Hello', 'type': 'html', 'parameter': [{'type': 'template', 'key': 'html', 'value': '...'}], 'firingTriggerId': ['2147479553']} (2147479553 is the built-in All Pages trigger; built-in triggers do not appear in list_triggers).

Inputs: tag (required), account_id (required), container_id (required), workspace_id (required). Returns: object

create_triggerA

Creates a trigger in the workspace draft.

Changes stay in the workspace until a version is published; nothing goes live. Returns the created trigger including its triggerId.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. trigger: Trigger resource body. Requires 'name' and 'type' (e.g. 'pageview', 'domReady', 'click', 'customEvent'). Minimal example: {'name': 'DOM Ready', 'type': 'domReady'}. A customEvent trigger also needs 'customEventFilter', e.g. [{'type': 'equals', 'parameter': [{'type': 'template', 'key': 'arg0', 'value': '{{_event}}'}, {'type': 'template', 'key': 'arg1', 'value': 'my_event'}]}].

Inputs: trigger (required), account_id (required), container_id (required), workspace_id (required). Returns: object

create_variableA

Creates a variable in the workspace draft.

Changes stay in the workspace until a version is published; nothing goes live. Returns the created variable including its variableId.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. variable: Variable resource body. Requires 'name' and 'type'; most types also need 'parameter' (list of {'type', 'key', 'value'} dicts). Data layer variable example: {'name': 'DL - user_id', 'type': 'v', 'parameter': [{'type': 'integer', 'key': 'dataLayerVersion', 'value': '2'}, {'type': 'template', 'key': 'name', 'value': 'user_id'}]}.

Inputs: variable (required), account_id (required), container_id (required), workspace_id (required). Returns: object

create_versionA
Destructive

Snapshots a workspace into a new container version.

WARNING: this consumes the workspace. The workspace is deleted and a fresh empty one is created; its path is returned as newWorkspacePath. Use that path for any further edits — the workspace_id passed here is gone afterwards. Nothing goes live yet; publish_version does that.

Check the result before publishing: if compilerError is true or syncStatus reports a conflict, the version has problems. Fix them in the new workspace and create another version rather than publishing.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. name: Optional name for the version. notes: Optional notes describing the version.

Inputs: account_id (required), container_id (required), workspace_id (required), name, +1 more. Returns: object

delete_tagA
Destructive

Deletes a tag from the workspace draft.

Requires explicit confirmation: ask the user first, then call again with confirm=True. The removal stays in the workspace until a version is published.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. tag_id: Numeric tag ID; find it via list_tags. confirm: Must be True to actually delete.

Inputs: tag_id (required), account_id (required), container_id (required), workspace_id (required), +1 more. Returns: object

delete_triggerA
Destructive

Deletes a trigger from the workspace draft.

Requires explicit confirmation: ask the user first, then call again with confirm=True. Check first (via list_tags) that no tag still references the trigger. The removal stays in the workspace until a version is published.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. trigger_id: Numeric trigger ID; find it via list_triggers. confirm: Must be True to actually delete.

Inputs: account_id (required), trigger_id (required), container_id (required), workspace_id (required), +1 more. Returns: object

delete_variableA
Destructive

Deletes a variable from the workspace draft.

Requires explicit confirmation: ask the user first, then call again with confirm=True. Check first that no tag, trigger or variable still references it as {{Variable Name}}. The removal stays in the workspace until a version is published.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. variable_id: Numeric variable ID; find it via list_variables. confirm: Must be True to actually delete.

Inputs: account_id (required), variable_id (required), container_id (required), workspace_id (required), +1 more. Returns: object

get_live_versionA
Read-only

Gets the container version currently published (live).

Returns metadata plus slimmed contents, like get_version. Useful to see what is live before publishing a new version.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path.

Inputs: account_id (required), container_id (required). Returns: object

get_tagA
Read-only

Gets the full configuration of one tag, including parameters.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. tag_id: Numeric tag ID; find it via list_tags.

Inputs: tag_id (required), account_id (required), container_id (required), workspace_id (required). Returns: object

get_triggerA
Read-only

Gets the full configuration of one trigger, including filters.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. trigger_id: Numeric trigger ID; find it via list_triggers.

Inputs: account_id (required), trigger_id (required), container_id (required), workspace_id (required). Returns: object

get_variableA
Read-only

Gets the full configuration of one variable.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. variable_id: Numeric variable ID; find it via list_variables.

Inputs: account_id (required), variable_id (required), container_id (required), workspace_id (required). Returns: object

get_versionA
Read-only

Gets one container version: metadata plus slimmed contents.

The embedded tags, triggers and variables are reduced to their skeleton (name + id); a full version can otherwise run to thousands of lines. Use get_tag/get_trigger/get_variable for full entity configs, but note those read the workspace draft, not this version.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. version_id: Numeric version ID; find it via list_versions.

Inputs: account_id (required), version_id (required), container_id (required). Returns: object

get_workspace_statusB
Read-only

Shows unpublished changes and merge conflicts in a workspace.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces.

Inputs: account_id (required), container_id (required), workspace_id (required). Returns: object

list_accountsA
Read-only

Lists all Google Tag Manager accounts accessible to the caller.

Args: include_google_tags: Also include Google Tag accounts in the results.

Inputs: include_google_tags. Returns: object

list_containersA
Read-only

Lists all containers in a Google Tag Manager account.

Args: account_id: Numeric GTM account ID (e.g. 6000000000) or a full path like 'accounts/6000000000'.

Inputs: account_id (required). Returns: object

list_tagsA
Read-only

Lists tags in a workspace, skeleton fields only.

Returns tagId, name, type, firingTriggerId, blockingTriggerId, paused and fingerprint per tag. Use get_tag for the full configuration of a specific tag.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces.

Inputs: account_id (required), container_id (required), workspace_id (required). Returns: object

list_triggersA
Read-only

Lists triggers in a workspace, skeleton fields only.

Returns triggerId, name, type and fingerprint per trigger. Use get_trigger for the full configuration of a specific trigger.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces.

Inputs: account_id (required), container_id (required), workspace_id (required). Returns: object

list_variablesA
Read-only

Lists variables in a workspace, skeleton fields only.

Returns variableId, name, type and fingerprint per variable. Use get_variable for the full configuration of a specific variable.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces.

Inputs: account_id (required), container_id (required), workspace_id (required). Returns: object

list_versionsA
Read-only

Lists container version headers, skeleton fields only.

Returns containerVersionId, name, deleted and entity counts per version. Use get_version for the full contents of one version, or get_live_version for the one currently published.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path.

Inputs: account_id (required), container_id (required). Returns: object

list_workspacesA
Read-only

Lists workspaces in a container.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID (e.g. 200001) or a full path like 'accounts/123/containers/200001'.

Inputs: account_id (required), container_id (required). Returns: object

publish_versionA
Destructive

Publishes a container version, making it live on the site.

This is the only operation that changes what runs on the live site. Requires explicit confirmation: ask the user first, then call again with confirm=True. Publish a version you have already checked for compiler errors (see create_version).

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. version_id: Numeric version ID; find it via list_versions. confirm: Must be True to actually publish.

Inputs: account_id (required), version_id (required), container_id (required), confirm. Returns: object

update_tagA

Updates a tag by merging changes into its current configuration.

The merge is shallow: each top-level key in changes replaces the current value, a null value removes the key, and lists are replaced whole (e.g. firingTriggerId must be the complete new list). The current config is re-read in the same call and its fingerprint sent along, so concurrent edits fail cleanly instead of being clobbered. Changes stay in the workspace draft until a version is published. Returns the updated tag.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. tag_id: Numeric tag ID; find it via list_tags. changes: Partial tag body, e.g. {'paused': True} or {'firingTriggerId': ['5', '7']}.

Inputs: tag_id (required), changes (required), account_id (required), container_id (required), +1 more. Returns: object

update_triggerA

Updates a trigger by merging changes into its current config.

The merge is shallow: each top-level key in changes replaces the current value, a null value removes the key, and lists are replaced whole (e.g. a filter list must be passed complete). The current config is re-read in the same call and its fingerprint sent along, so concurrent edits fail cleanly instead of being clobbered. Changes stay in the workspace draft until a version is published. Returns the updated trigger.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. trigger_id: Numeric trigger ID; find it via list_triggers. changes: Partial trigger body, e.g. {'name': 'New name'}.

Inputs: changes (required), account_id (required), trigger_id (required), container_id (required), +1 more. Returns: object

update_variableA

Updates a variable by merging changes into its current config.

The merge is shallow: each top-level key in changes replaces the current value, a null value removes the key, and lists are replaced whole (e.g. the parameter list must be passed complete). The current config is re-read in the same call and its fingerprint sent along, so concurrent edits fail cleanly instead of being clobbered. Changes stay in the workspace draft until a version is published. Returns the updated variable.

Args: account_id: Numeric account ID or full resource path. container_id: Numeric container ID or full resource path. workspace_id: Numeric workspace ID; find it via list_workspaces. variable_id: Numeric variable ID; find it via list_variables. changes: Partial variable body, e.g. {'name': 'New name'}.

Inputs: changes (required), account_id (required), variable_id (required), container_id (required), +1 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 24 tools

    Disambiguation5/5

    Each tool targets a distinct GTM entity and action. Tags, triggers, variables each have their own create/get/list/update/delete, and workspace/version lifecycle tools are clearly separate.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with snake_case. Verbs like create, list, get, update, delete, publish are used uniformly across entities.

    Tool Count5/5

    24 tools cover the core GTM workflow without bloat: account/container/workspace listing, version management, and full CRUD for tags, triggers, variables. Each tool earns its place.

    Completeness4/5

    The tool set provides full lifecycle management for tags, triggers, variables, and versions. Missing account/container creation is acceptable as these are typically managed outside CI/CD.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server for Google Tag Manager API, enabling users to manage containers, tags, and triggers through natural language using Google Application Default Credentials.
      18
      54 npm
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for Google Tag Manager API v2, enabling programmatic management of accounts, containers, workspaces, tags, triggers, variables, and version workflows.
      46 npm
      15
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      A 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.
      1
      -