Google Tag Manager MCP
v1.4.0MCP server for the Google Tag Manager API v2: containers, workspaces, tags, triggers, publishing.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
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.
setup_instructions Setup instructions
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 confi…
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.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the client_secret_*.json file downloaded from Google Cloud Console. |
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.
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 unnotice…
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.
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.
| Parameter | Type | Description |
|---|---|---|
page_token | string | Pagination token from a previous response's nextPageToken. Omit for the first page. |
get_account Get a GTM account
Gets one Google Tag Manager account by id. Returns the Account resource: { accountId, name, path, fingerprint, shareData }.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string), e.g. from list_accounts. |
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 }.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
page_token | string | Pagination token from a previous response's nextPageToken. Omit for the first page. |
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.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string), e.g. from list_containers. |
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.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
name * | string | Display name of the new container. |
usage_context * | array | Usage contexts, e.g. ["web"]. Other documented values: androidSdk5, iosSdk5, server. |
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.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string). |
page_token | string | Pagination token from a previous response's nextPageToken. Omit for the first page. |
get_workspace Get a workspace
Gets one workspace by account id + container id + workspace id. Returns the Workspace resource with its fingerprint.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string). |
workspace_id * | string | Workspace id (string), e.g. from list_workspaces. |
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.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string). |
name * | string | Display name of the new workspace. |
description | string | Optional description of what this workspace changes. |
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 }.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string). |
workspace_id * | string | Workspace id (string), e.g. from list_workspaces. |
page_token | string | Pagination token from a previous response's nextPageToken. Omit for the first page. |
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 }.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string). |
workspace_id * | string | Workspace id (string), e.g. from list_workspaces. |
page_token | string | Pagination token from a previous response's nextPageToken. Omit for the first page. |
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 }.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string). |
workspace_id * | string | Workspace id (string), e.g. from list_workspaces. |
page_token | string | Pagination token from a previous response's nextPageToken. Omit for the first page. |
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).
| Parameter | Type | Description |
|---|---|---|
path * | string | API-relative resource path as returned in the resource's own "path" field, e.g. "accounts/1/containers/2/workspaces/3/tags/4". |
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.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
body * | object | The resource JSON to create (name, type, parameter, and for tags firingTriggerId). |
container_id * | string | Container id (string). |
entity_type * | string | Which collection to create in. |
workspace_id * | string | Workspace id (string). |
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.
| Parameter | Type | Description |
|---|---|---|
body * | object | The complete replacement resource JSON. |
path * | string | API-relative resource path as returned in the resource's own "path" field, e.g. "accounts/1/containers/2/workspaces/3/triggers/5". |
fingerprint | string | The fingerprint from the last read of this resource; the update fails if it is stale. |
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.
| Parameter | Type | Description |
|---|---|---|
path * | string | API-relative resource path as returned in the resource's own "path" field, e.g. "accounts/1/containers/2/workspaces/3/variables/7". |
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.
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
action * | string | What to do. |
container_id * | string | Container id (string). |
workspace_id * | string | Workspace id (string). |
types | array | Built-in variable types to enable/disable (required for those actions), e.g. ["pageUrl", "clickText"]. Ignored for "list". |
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).
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
container_id * | string | Container id (string). |
workspace_id * | string | Workspace id (string) to compile. This workspace is deleted afterwards. |
name | string | Version display name. |
notes | string | Version notes (changelog entry). |
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 }).
| Parameter | Type | Description |
|---|---|---|
account_id * | string | GTM account id (string). |
action * | string | What to do. |
container_id * | string | Container id (string). |
fingerprint | string | The version's last-seen fingerprint ("publish" only), for optimistic-concurrency safety. |
version_id | string | Container version id (string). Required for "publish" and "get"; ignored for "live". |
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.
| Parameter | Type | Description |
|---|---|---|
path * | string | API path relative to /tagmanager/v2/, e.g. "accounts/1/containers/2/version_headers". |
body | object | JSON request body (POST/PUT). |
method | string | HTTP method. Defaults to GET. |
query | object | Query parameters; use an array for repeated keys, e.g. { "type": ["pageUrl", "event"] }. |