Google Tag Manager MCP
Google Tag Manager MCP
English | Русский
A1 Google Tag Manager MCP を使用すると、AI アプリが平易な言葉で Google Tag Manager コンテナを調査・管理できます。ページ上で何が発火するかを確認し、ドラフトワークスペースでタグ、トリガー、変数を操作し、準備ができたら意図的にバージョンをコンパイルして公開できます。
Google アカウントを通じて Google Tag Manager API v2 に接続します。AI に GTM 構成を推測させるのとは異なり、選択した実際のコンテナ、ワークスペース、バージョンに対して動作します。
19 のツール。 10 の操作は GTM データの読み取りのみ、4 つはドラフトの作成または組み込み変数の変更、5 つは本番設定の変更、削除、コンパイル、公開を行います。
ドラフト優先。 タグ、トリガー、変数はワークスペース内で作成されます。公開は別の、明示的に破壊的な操作です。
クォータ対応。 GTM はプロジェクトごとに 1 秒あたり 0.25 リクエストを許可しています。サーバーは API を圧迫せず、リクエスト間隔を少なくとも 4.2 秒確保します。
あなたの Google アクセス。 サーバーはあなたの OAuth 認証情報を使用し、読み取り、編集、バージョン管理、公開に必要な Tag Manager スコープのみをリクエストします。
読み取り専用の質問から始めましょう。
私のコンテナ内のどのタグがページビュートリガーで発火しますか?
サーバーに接続 · ユースケースを確認 · 技術ドキュメントを開く
1 分で動作を確認
あなた: 私の GTM コンテナを一覧表示し、ページビューで発火するタグを表示してください。
アシスタント: コンテナ、そのワークスペース、関連するトリガー、それらに接続されたタグを一覧表示します。何も変更しません。
あなた:
GTM-ABC123のデフォルトワークスペースで、全ページの測定 IDG-XXXXXXX用の GA4 設定タグを準備してください。アシスタント: ワークスペース、提案されたタグとトリガー構成を表示し、ドラフト作成前に確認を求めます。
あなた: ドラフトを確認します。
アシスタント: ワークスペース内にタグを作成します。コンテナは公開しません。バージョンのコンパイルと公開は別のステップです。
Related MCP server: unboundai-gtm-mcp-server
目次
クイックスタート
Node.js 20+、GTM コンテナにアクセスできる Google アカウント、および Tag Manager API が有効になっている Google Cloud プロジェクトの OAuth 認証情報が必要です。
AI アプリにサーバーを追加します。
上記の読み取り専用の質問から始めます。
アプリ内:
設定 → プラグイン → MCP サーバーを開きます。
サーバーを追加を選択します。
以下の 3 つの環境変数とともに
npx -y mcp-google-tagmanager@latestを追加します。
変数 | 値 |
| あなたの Google OAuth クライアント ID |
| あなたの Google OAuth クライアントシークレット |
| あなたの Google OAuth リフレッシュトークン |
コマンドラインから:
codex mcp add google-tagmanager \
--env GOOGLE_TAGMANAGER_CLIENT_ID=your_client_id \
--env GOOGLE_TAGMANAGER_CLIENT_SECRET=your_client_secret \
--env GOOGLE_TAGMANAGER_REFRESH_TOKEN=your_refresh_token \
-- npx -y mcp-google-tagmanager@latestcodex mcp listclaude mcp add \
--env GOOGLE_TAGMANAGER_CLIENT_ID=your_client_id \
--env GOOGLE_TAGMANAGER_CLIENT_SECRET=your_client_secret \
--env GOOGLE_TAGMANAGER_REFRESH_TOKEN=your_refresh_token \
--transport stdio \
--scope user \
google-tagmanager \
-- npx -y mcp-google-tagmanager@latestclaude mcp list設定 → 開発者 → 設定を編集を開きます。
このエントリを
mcpServersに追加します。
{
"mcpServers": {
"google-tagmanager": {
"command": "npx",
"args": ["-y", "mcp-google-tagmanager@latest"],
"env": {
"GOOGLE_TAGMANAGER_CLIENT_ID": "your_client_id",
"GOOGLE_TAGMANAGER_CLIENT_SECRET": "your_client_secret",
"GOOGLE_TAGMANAGER_REFRESH_TOKEN": "your_refresh_token"
}
}
}
}設定を編集 が利用できない場合は、macOS では ~/Library/Application Support/Claude/claude_desktop_config.json、Windows では %APPDATA%\Claude\claude_desktop_config.json を編集します。
macOS/Linux では ~/.cursor/mcp.json、Windows では %USERPROFILE%\.cursor\mcp.json にユーザーレベルのサーバーを追加します:
{
"mcpServers": {
"google-tagmanager": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-google-tagmanager@latest"],
"env": {
"GOOGLE_TAGMANAGER_CLIENT_ID": "your_client_id",
"GOOGLE_TAGMANAGER_CLIENT_SECRET": "your_client_secret",
"GOOGLE_TAGMANAGER_REFRESH_TOKEN": "your_refresh_token"
}
}
}
}コマンドパレットから MCP: ユーザー設定を開く を実行して追加します:
{
"servers": {
"google-tagmanager": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-google-tagmanager@latest"],
"env": {
"GOOGLE_TAGMANAGER_CLIENT_ID": "${input:gtm_client_id}",
"GOOGLE_TAGMANAGER_CLIENT_SECRET": "${input:gtm_client_secret}",
"GOOGLE_TAGMANAGER_REFRESH_TOKEN": "${input:gtm_refresh_token}"
}
}
},
"inputs": [
{ "type": "promptString", "id": "gtm_client_id", "description": "Google OAuth client ID" },
{ "type": "promptString", "id": "gtm_client_secret", "description": "Google OAuth client secret", "password": true },
{ "type": "promptString", "id": "gtm_refresh_token", "description": "Google OAuth refresh token", "password": true }
]
}MCP: サーバー一覧 で確認します。
依頼できること
現在の設定を把握する
アクセスできる GTM アカウントとコンテナを一覧表示します。
このワークスペースではどのタグがページビューで発火しますか?
このタグのトリガーと変数の構成を表示します。
どの組み込み変数が有効になっていますか?
ドラフトでトラッキング変更を準備する
チェックアウトトラッキング変更用のワークスペースを作成します。
特定のイベント用の GA4 タグとトリガーを準備します。
このトリガーに必要なクリック変数を有効にします。
完全な置き換え構成を表示した上で、このタグを更新します。
意図的にバージョンをリリースする
このワークスペースを
April releaseという名前のバージョンにコンパイルします。コンパイラエラーがあれば表示します。
バージョンとその変更内容を確認した後、バージョン
42を公開します。
GTM の変更がどのように接続されるか
GTM には明確なリリースパスがあります。
アカウントには 1 つ以上のコンテナが含まれます。
コンテナにはドラフト変更用のワークスペースがあります。
タグ、トリガー、変数はワークスペースに属します。
ワークスペースをコンパイルするとコンテナバージョンが作成され、元のワークスペースは削除されます。GTM は代替ワークスペースを提供します。
公開すると、選択したコンテナバージョンが本番に反映されます。
このサーバーは各ステップを検査できます。ドラフトをリリースとは見なさず、バージョン作成と公開は別々の操作です。
変更できるもの
操作 | 結果 | 確認の境界 |
アカウント、コンテナ、ワークスペース、タグ、トリガー、変数、バージョンの一覧表示 | GTM 設定を読み取ります | 変更なし |
コンテナまたはワークスペースの作成 | 新しい GTM オブジェクトを追加します | GTM が変更される |
タグ、トリガー、変数の作成 | ワークスペースにドラフトオブジェクトを追加します | ドラフトワークスペースが変更される |
組み込み変数の有効化または無効化 | ワークスペースの設定を変更します | ドラフトワークスペースが変更される |
タグ、トリガー、変数の更新 | フィンガープリントで保護された完全なリソースを置き換えます | 破壊的な可能性あり |
タグ、トリガー、変数の削除 | 選択したオブジェクトを削除します | 破壊的 |
ワークスペースのコンパイル | バージョンを作成し、元のワークスペースを削除します | 破壊的 |
バージョンの公開 | 選択したバージョンを本番に反映します | 破壊的 |
生の API リクエスト | 専用ツールなしで API メソッドを呼び出せます | 破壊的な可能性あり |
AI クライアントは確認の求め方を決定します。サーバーは読み取り専用、書き込み、破壊的操作をマークし、クライアントが調査と実際の変更を区別できるようにします。
アクセス権の取得
サーバーは Google OAuth 2.0 を使用します。Google Tag Manager はこのユーザーデータ用の API キーを提供しません。
Google Cloud プロジェクトを作成または選択し、Tag Manager API を有効にします。この API が有効でないプロジェクトにはクォータが割り当てられません。
OAuth 同意画面を設定し、OAuth クライアントを作成します。ローカルでの使用には デスクトップアプリ クライアントが適しています。
Google アカウントを承認し、リフレッシュトークンを取得します。OAuth 2.0 Playground で 独自の OAuth 認証情報を使用 を有効にすると、これを行うことができます。
次のスコープをまとめてリクエストします。
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
スコープはそれぞれ独立しています。読み取り、編集、バージョンのコンパイル、公開には、それぞれ対応する権限が必要です。クライアントシークレットとリフレッシュトークンはパスワードと同じように扱ってください。
設定
変数 | 必須 | 説明 |
| はい* | OAuth クライアント ID。 |
| はい* | OAuth クライアントシークレット。 |
| はい* | OAuth リフレッシュトークン。 |
| はい* | OAuth 3 点セットに代わる短時間有効なトークン。 |
| いいえ | Tag Manager API のベース URL を上書きします。 |
| いいえ | リクエストごとのタイムアウト。デフォルトは |
| いいえ | 一時的な障害時の最大再試行回数。デフォルトは |
| いいえ | リクエストの最小間隔。デフォルトは |
* OAuth 3 点セットまたはアクセストークンのいずれかを指定します。アクセストークンは約 1 時間で有効期限が切れ、自動的には更新されません。
データとテレメトリ
サーバーはローカルで実行され、GTM API リクエストと OAuth 更新リクエストを Google に送信します。匿名テレメトリには、ランダムなインストール ID、パッケージバージョン、AI クライアント、Node.js/オペレーティングシステムのバージョン、ツール名が含まれます。OAuth トークン、GTM データ、ツール引数、プロンプトは送信されません。
A1 MCP サーバーのテレメトリを無効にするには:
ASKADS_TELEMETRY=0制限とバックグラウンド処理
GTM はレート制限があります。 API はプロジェクトごとに 1 秒あたり 0.25 リクエストしか許可しないため、サーバーは呼び出しを少なくとも 4.2 秒間隔で直列化します。そのため、広範囲の監査には時間がかかる場合があります。
一時的な制限は慎重に再試行されます。
429と Google のクォータ403応答には指数バックオフとRetry-Afterを使用します。読み取りはネットワークおよび5xx障害の後に再試行されます。書き込みは不確実な障害の後に再実行されません。バックグラウンド監視はありません。 サーバーは AI アプリが呼び出したときだけ実行されます。アプリがスケジュールタスクをサポートしている場合は、コンテナまたはその本番バージョンを定期的に検査できます。
ワークスペースはコンパイル時に削除されます。
create_versionを呼び出す前に、ワークスペースから必要なものを保存し、返された置き換えワークスペースのパスを確認してください。
技術ドキュメント
MCP 機能カタログ — すべてのツール向けのタスク指向ページ。
サポート
Available Tools
25 toolsauth_statusGoogle connection statusARead-onlyIdempotent
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.
Inputs: no named parameters.
create_containerCreate a containerA
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.
Inputs: name (required), account_id (required), usage_context (required).
create_entityCreate a tag, trigger or variableA
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.
Inputs: body (required), account_id (required), entity_type (required), container_id (required), +1 more.
create_versionCreate a container version from a workspaceADestructive
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).
Inputs: account_id (required), container_id (required), workspace_id (required), name, +1 more.
create_workspaceCreate a workspaceA
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.
Inputs: name (required), account_id (required), container_id (required), description.
delete_entityDelete a tag, trigger or variableADestructiveIdempotent
Deletes a tag, trigger or variable by its API path. The response is empty on success. Requires the tagmanager.edit.containers scope.
Inputs: path (required).
finish_loginFinish the Google loginAIdempotent
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.
Inputs: no named parameters.
get_accountGet a GTM accountARead-onlyIdempotent
Gets one Google Tag Manager account by id. Returns the Account resource: { accountId, name, path, fingerprint, shareData }.
Inputs: account_id (required).
get_containerGet a containerARead-onlyIdempotent
Gets one container by account id + container id. Returns the Container resource including publicId (the GTM-XXXXXX snippet id), usageContext and fingerprint.
Inputs: account_id (required), container_id (required).
get_resourceGet any resource by pathARead-onlyIdempotent
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).
Inputs: path (required).
get_workspaceGet a workspaceARead-onlyIdempotent
Gets one workspace by account id + container id + workspace id. Returns the Workspace resource with its fingerprint.
Inputs: account_id (required), container_id (required), workspace_id (required).
list_accountsList GTM accountsARead-onlyIdempotent
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.
Inputs: page_token.
list_containersList containersARead-onlyIdempotent
Lists the containers of a GTM account. Returns { container: [{ containerId, name, publicId (e.g. GTM-XXXXXX), usageContext, path, fingerprint, tagManagerUrl }], nextPageToken }.
Inputs: account_id (required), page_token.
list_tagsList tagsARead-onlyIdempotent
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 }.
Inputs: account_id (required), container_id (required), workspace_id (required), page_token.
list_triggersList triggersARead-onlyIdempotent
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 }.
Inputs: account_id (required), container_id (required), workspace_id (required), page_token.
list_variablesList variablesARead-onlyIdempotent
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 }.
Inputs: account_id (required), container_id (required), workspace_id (required), page_token.
list_workspacesList workspacesARead-onlyIdempotent
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.
Inputs: account_id (required), container_id (required), page_token.
logoutDisconnect from GoogleADestructive
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.
Inputs: no named parameters.
manage_built_in_variablesList/enable/disable built-in variablesAIdempotent
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.
Inputs: action (required), account_id (required), container_id (required), workspace_id (required), +1 more.
publish_versionPublish, inspect or fetch the live container versionADestructive
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 }).
Inputs: action (required), account_id (required), container_id (required), version_id, +1 more.
raw_requestRaw Tag Manager API callADestructive
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.
Inputs: path (required), body, query, method.
set_clientSave the OAuth clientAIdempotent
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.
Inputs: path (required).
setup_instructionsSetup instructionsARead-onlyIdempotent
This server ships with a built-in OAuth client, so connecting normally needs only start_login + finish_login; call this for the details or to switch to your own client. The checklist adapts to the client in use: with the built-in client it is just the two login calls, and it adds the steps for your OWN client — 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; with your own client already configured it shortens to 'enable the API + log in' (one client serves the whole mcp-google-* line). Never asks the user to paste secrets into the chat.
Inputs: no named parameters.
start_loginStart the Google loginAIdempotent
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.
Inputs: no named parameters.
update_entityUpdate a tag, trigger or variableADestructiveIdempotent
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.
Inputs: body (required), path (required), fingerprint.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Most tools target distinct resources and actions (list/get/create per account, container, workspace, tag, trigger, variable), and the auth lifecycle tools are clearly separate. However, get_resource overlaps with get_container/get_workspace, and create_entity/update_entity/delete_entity share conceptual ground with the specific container/workspace CRUD tools — descriptions clarify the boundaries but some confusion is possible.
Strong snake_case verb_noun pattern throughout (list_accounts, get_container, create_workspace, delete_entity). Minor deviations: setup_instructions and auth_status are noun phrases rather than verb_object, logout lacks an object, and publish_version actually performs publish/get/live actions, making the name slightly misleading.
25 tools sits at the top of a reasonable band; the deep GTM hierarchy (account > container > workspace > tags/triggers/variables/versions) plus a required OAuth flow justifies most tools. It is on the heavy side, but each tool earns its place and there is little gratuitous duplication.
Core lifecycle is well covered: auth, accounts, containers, workspaces, tags/triggers/variables CRUD, version create/publish, and built-in variables. Gaps exist (no delete/update for containers or workspaces, no dedicated environments/folders/templates/zones tools), but the raw_request escape hatch lets agents reach these endpoints.
Maintenance
Related MCP Connectors
Hosted Google Tag Manager MCP server, with each action switched on or off per account.
Google Ads MCP server — manage campaigns, keywords, and metrics.
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
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.-
- AlicenseAqualityDmaintenanceMCP server for Google Tag Manager API, enabling users to manage containers, tags, and triggers through natural language using Google Application Default Credentials.1854 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceMCP server for Google Tag Manager API v2, enabling programmatic management of accounts, containers, workspaces, tags, triggers, variables, and version workflows.34 npm16MIT
- FlicenseNot gradedqualityBmaintenanceA 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-