Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
An MCP server for Google Tag Manager. Connect it to your LLM, authenticate once, and start managing GTM through natural language.
Jump to setup instructionsNo tool list is on record. This does not mean the server has no tools. Tools were not run.
No setup evidence yet No matching config or report on record. This does not mean the server is incompatible.
Same catalog task: AI & machine learning.
.prompts, the home to all your AI prompts, everywhere you need them.
Same catalog task: AI & machine learning.
Real MCP server (stdio + @modelcontextprotocol/sdk) that exposes x402-paywalled HTTP endpoints as MCP tools. Drop into Claude Desktop, Cursor, or any MCP client.
Same catalog task: AI & machine learning.
Standalone MCP (Model Context Protocol) server - stdio/http/websocket transports, connection pooling, tool registry
Fetched from the repository for this visit.
[!IMPORTANT] The hosted instance at
mcp.gtmeditor.comwas shut down during the night of 20–21 November 2026. There is no longer a public endpoint: to keep using the server, self-host it. Removehttps://mcp.gtmeditor.comfrom every MCP client configuration. The domain is not being renewed, so a future owner could serve something else at that address. See #139 for background. Thanks to everyone who used it!
[!NOTE] This project is in maintenance mode. It is feature-complete and will not get new features. Only security fixes will be merged. If you want an actively maintained GTM MCP server, or a hosted endpoint with no setup, use stape-io/google-tag-manager-mcp-server. See Alternatives.
GTM MCP Server connects MCP clients to the Google Tag Manager API. It can inspect containers, create and update workspace entities, create versions, and publish a selected version after explicit confirmation.
The repository also ships gtm-cli, a command-line tool
that gives people and agents direct GTM access with no server to host.
It authenticates either with browser-based Google OAuth (each user acts with their own Google identity and GTM permissions) or with a Google service account (one shared identity, for automation or a single local user).
| Item | Current state |
|---|---|
Version in server.json | 1.15.0 |
| Transport | MCP Streamable HTTP, or stdio for local service-account use |
| Runtime tools | 64 GTM tools by default; 94 with GTM_TOOL_GROUPS=all; plus 2 utility tools in both cases |
| MCP resources | 8 resource definitions (2 resources, 6 URI templates) |
| MCP prompts | 6 prompts |
| Official GTM API coverage | 101 of 106 methods |
| Hosted endpoint | None. mcp.gtmeditor.com was shut down on 20–21 November 2026 |
| Maintenance | Feature-complete. Security fixes only |
The project implements 101 methods from Google's 106-method GTM v2 discovery
surface. The five accounts.user_permissions methods are intentionally
excluded: granting and revoking GTM access is security-sensitive and should not
be managed by an LLM.
gtm-cli calls the Tag Manager API from your own machine, for shells, scripts and
agents such as Claude Code, Codex and Cursor. There is no server, MCP client
configuration or API key. It covers account, container and workspace discovery,
tag, trigger and variable create, read, update and delete, workspace status, and
version creation and publication. The MCP server covers the rest of the API.
With Go 1.26 or later:
go install github.com/paolobietolini/gtm-mcp-server/cmd/gtm-cli@latest
Releases also attach prebuilt archives named
gtm-cli_<version>_<os>_<arch> to the
release page. From a
clone:
go build -o bin/gtm-cli ./cmd/gtm-cli
Enable the Tag Manager API in a Google
Cloud project. gtm-cli finds credentials as stdio mode does:
GOOGLE_SERVICE_ACCOUNT_KEY_JSON, then Application Default Credentials (the file
in GOOGLE_APPLICATION_CREDENTIALS, then the gcloud login file, then the service
account attached on Google Cloud).
The plain gcloud login is not enough. gcloud auth application-default login
does not request Tag Manager scopes by default. Adding them to --scopes uses
gcloud's own OAuth client, which Google can reject with "This app is blocked"
(troubleshooting).
Use one of these instead.
Option 1: your own OAuth client, to act as yourself. In the Google Cloud project, configure the OAuth consent screen, create an OAuth client of type Desktop app and download its JSON file. While an external consent screen is in Testing, add yourself as a test user; Google expires those logins after 7 days.
SCOPES=https://www.googleapis.com/auth/cloud-platform
SCOPES+=,https://www.googleapis.com/auth/userinfo.email
for s in delete.containers edit.containers edit.containerversions manage.accounts publish; do
SCOPES+=,https://www.googleapis.com/auth/tagmanager.$s
done
gcloud auth application-default login \
--client-id-file=client_secret.json --scopes="$SCOPES"
Request fewer tagmanager scopes to limit what the CLI can do, for example only
tagmanager.readonly for audits.
Option 2: a service account, for automation. Create it and add it to GTM as in step 2b, then either point to its key file:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa.json
or impersonate it without a key. This needs the IAM Service Account Credentials API and the Service Account Token Creator role on that account:
gcloud auth application-default login \
--impersonate-service-account=gtm-mcp@PROJECT_ID.iam.gserviceaccount.com
Check the result:
gtm-cli auth status
It prints the credential source and type, the account email when Google reports one, the quota project, and granted and missing scopes. It exits with code 3 if the credentials have no Tag Manager scope.
If a request fails for lack of a quota project, run
gcloud auth application-default set-quota-project PROJECT_ID.
gtm-cli accounts list --output table
gtm-cli containers list --account 123
gtm-cli workspaces list --account 123 --container 456
export GTM_ACCOUNT_ID=123 GTM_CONTAINER_ID=456 GTM_WORKSPACE_ID=7
gtm-cli tags list
gtm-cli tags create --file tag.json --dry-run
gtm-cli tags create --file tag.json
gtm-cli tags delete --tag-id 12 --confirm
gtm-cli workspaces status
gtm-cli versions create --name "Add sign_up event" --notes "GA4 sign_up on form submit"
gtm-cli versions publish --version-id 9 --confirm
gtm-cli versions get --live
gtm-cli help lists every command and gtm-cli <noun> <verb> --help its flags. A command
gtm-cli <nouns> <verb> matches the MCP tool verb_noun.
Missing --account, --container and --workspace flags are read from the
environment variables above, then from $XDG_CONFIG_HOME/gtm-cli/config.json
(normally ~/.config/gtm-cli/config.json), or from the file named by GTM_CONFIG:
{"accountId": "123", "containerId": "456", "workspaceId": "7"}
No configuration is read from the working directory, including .env.
--file takes a JSON object (- reads stdin):
{
"name": "HTML - Banner",
"type": "html",
"firingTriggerId": ["12"],
"parameter": [{"type": "template", "key": "html", "value": "<script></script>"}]
}
Parameter and condition shapes are in
tool-input-formats.md; the
gtm-cli skill lists the keys for each entity.
Unknown keys are rejected. On update, tags keep every omitted key; triggers and
variables require name and type and keep other omitted keys.
gtm-cli workspaces status lists each entity the workspace adds, updates or
deletes, and each merge conflict:
{"status": {"hasChanges": true, "hasConflicts": false, "changeCount": 1, "conflictCount": 0,
"changes": [{"type": "tag", "id": "4", "name": "GA4 - purchase", "changeStatus": "updated"}],
"conflicts": []}}
--entities adds each entity in full, in the shape of the collections that
gtm-cli versions get --latest returns, so the two can be compared field by
field. examples/workspace-diff.sh pairs them and
runs diff -u on each changed entity:
--- tag/4 "GA4 - purchase" in the latest version
+++ tag/4 "GA4 - purchase" in the workspace (updated)
@@ -14,7 +14,7 @@
{
"key": "measurementIdOverride",
"type": "template",
- "value": "G-OLD"
+ "value": "G-NEW"
}
The comparison is with the latest version, which the workspace is based on, not with the live version. Update an out-of-date workspace first.
API commands print JSON with the same shape as the matching MCP tool's output;
--output table is for reading. Errors are JSON on stderr:
{"error": {"code": "not_found", "message": "resource not found: ..."}}
| Exit | error.code |
|---|---|
| 0 | success |
| 1 | api_error, cancelled, error |
| 2 | usage, invalid_input, invalid_request |
| 3 | auth |
| 4 | permission_denied |
| 5 | not_found |
| 6 | conflict, precondition_failed |
| 7 | rate_limited |
| 8 | confirmation_required |
A command gives up after two minutes. If a write ends in exit code 1, check the container before retrying: the change may have been applied.
delete and publish commands require --confirm.versions create refuses a workspace without changes or with merge conflicts.--dry-run, which prints the request and
sends no write. An update still reads the current entity, to show the full body
that would be sent. A dry run needs no --confirm.| Mode | Who it is for | Google identity used | How the client authenticates |
|---|---|---|---|
| stdio | One person, on their own machine | A service account | None: the MCP client starts the binary as a local process |
| HTTP + OAuth | Teams and agencies; every user keeps their own GTM permissions | Each user's own Google account | Browser sign-in with Google, handled by the MCP client |
| HTTP + service account | Automation, CI, agents, or a team that deliberately shares one identity | One service account for every caller | Static header Authorization: Bearer <SERVICE_ACCOUNT_API_KEY> |
| HTTP + OAuth + service account | Both of the above on one server | Per request: the API key selects the service account, any other bearer token is an OAuth user | Either of the two above |
Where the client connects from matters for remote (HTTP) deployments:
The steps below describe a production deployment on your own server (VPS,
virtual machine, or on-premises host). Every value written as
gtm-mcp.example.com, PROJECT_ID, or <...> is a placeholder to replace.
go.mod declares go 1.26.0).gtm-mcp.example.com)
with HTTPS. The server listens on plain HTTP only, so TLS is terminated by a
reverse proxy in front of it.Constraints that follow from how the server works:
/,
/authorize, /oauth/callback, /token, /register, /health, and
/.well-known/...) are registered at the root. A path prefix such as
https://example.com/gtm is not supported.401 responses. Service-account-only
deployments have no such state and can run several replicas.TOKEN_STORE_PATH, every restart or
redeploy signs all OAuth users out. Platforms with an ephemeral filesystem
that scale instances up and down (for example Cloud Run) are therefore a poor
fit for OAuth mode; they work for service-account mode.In the Google Cloud console, open APIs & Services → Library, search for Tag Manager API, and click Enable. With the gcloud CLI:
gcloud services enable tagmanager.googleapis.com --project=PROJECT_ID
No Google Cloud IAM role is needed to call the Tag Manager API. What a credential can do in GTM is decided only by GTM's own user management.
Skip this step if you use only service-account mode.
In the Google Cloud console, open Google Auth Platform (formerly "OAuth consent screen").
Branding: set the app name users will see on the consent screen, a user support email, and a developer contact email.
Audience: choose who may sign in. This is the server's only sign-in restriction: the server itself has no allowlist of users or domains.
Data Access (recommended): declare the scopes the server requests, so the consent screen and any verification request match what users see:
https://www.googleapis.com/auth/tagmanager.delete.containers
https://www.googleapis.com/auth/tagmanager.edit.containers
https://www.googleapis.com/auth/tagmanager.edit.containerversions
https://www.googleapis.com/auth/tagmanager.manage.accounts
https://www.googleapis.com/auth/tagmanager.publish
These five scopes are hard-coded in the server and cannot be reduced by configuration. What a user can actually do is still limited by that user's GTM permissions.
Clients → Create client:
Application type: Web application.
Authorized JavaScript origins: leave empty.
Authorized redirect URIs: add exactly one URI, BASE_URL followed by
/oauth/callback:
https://gtm-mcp.example.com/oauth/callback
For a server running on your own computer, add
http://localhost:8080/oauth/callback instead (or as well).
Click Create and copy the client ID and client secret. Google shows the secret only at creation time. Store both in your secret manager.
Google's rules for the redirect URI, which explain most
redirect_uri_mismatch errors:
BASE_URL + /oauth/callback character for character: scheme,
host, port, and path. The server always builds it this way; there is no
separate setting for it.https://. Only localhost is allowed over http://.gtm-mcp.example.com that resolves only
inside your network is accepted; gtm-mcp.corp.local is not.Skip this step if you use only OAuth mode.
Create the service account:
gcloud iam service-accounts create gtm-mcp \
--display-name="GTM MCP Server" \
--project=PROJECT_ID
Its email address is gtm-mcp@PROJECT_ID.iam.gserviceaccount.com.
Give it access in GTM: in Tag Manager open Admin → User Management (account level, or container level for a single container), click Add, enter the service account email, and grant the lowest permission that covers your use: container Read for audits, Edit to change workspaces, Approve to create versions, Publish to publish. Grant account Administrator only if the server must create or delete containers.
Choose how the server obtains the service account credentials:
On Google Cloud (Compute Engine, GKE, Cloud Run): attach the service account to the workload. The server uses Application Default Credentials, and no key file is needed.
Anywhere else: create a JSON key:
gcloud iam service-accounts keys create sa.json \
--iam-account=gtm-mcp@PROJECT_ID.iam.gserviceaccount.com
Many organizations block key creation with the organization policy
iam.disableServiceAccountKeyCreation (enforced by default in newer
organizations). If the command is refused, ask your Google Cloud
administrator for an exception or run the server on Google Cloud with an
attached service account. Treat sa.json as a password: anyone holding
it has the service account's GTM permissions.
For HTTP mode, generate the API key that clients will send:
openssl rand -hex 32
Anyone who has this key acts as the service account in GTM. Share it only through a secret manager and rotate it by changing the value and restarting the server.
The server is configured only through environment variables. They can also be
placed in a .env file; the full list is in the
configuration reference.
OAuth mode for a team (.env):
BASE_URL=https://gtm-mcp.example.com
GOOGLE_CLIENT_ID=<client-id>.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=<client-secret>
TOKEN_STORE_PATH=/data/tokens.json
TRUST_PROXY=true
Service-account mode (.env):
BASE_URL=https://gtm-mcp.example.com
SERVICE_ACCOUNT_API_KEY=<output of openssl rand -hex 32>
GOOGLE_APPLICATION_CREDENTIALS=/secrets/sa.json
TRUST_PROXY=true
For both modes on one server, combine the two files. Omit
GOOGLE_APPLICATION_CREDENTIALS when the server runs on Google Cloud with an
attached service account.
Rules that avoid the most common mistakes:
BASE_URL is the public HTTPS URL users and clients reach, with no
trailing slash and no path. A trailing slash produces URLs such as
https://gtm-mcp.example.com//oauth/callback, which do not match the
redirect URI registered with Google.docker run --env-file passes quotes
through as part of the value.ACCESS_TOKEN_TTL, AUTH_AUTO_REFRESH_MAX_AGE) must use Go
duration syntax such as 8h, 90m, or 168h (7d is not valid);
booleans accept true/false or 1/0. An unknown name in
GTM_TOOL_GROUPS or MCP_TRANSPORT instead stops the server at startup.TRUST_PROXY=true is correct only with exactly one reverse proxy in
front of the server that sets X-Forwarded-For (the setups below). Without
a proxy, leave it false.No authentication configured. Never expose open mode beyond your
own machine.Pick one of the three options.
Caddy terminates HTTPS and obtains certificates automatically. On the server:
git clone https://github.com/paolobietolini/gtm-mcp-server.git
cd gtm-mcp-server
git checkout v1.15.0 # use the latest tag from the release page
Create .env as in step 3 (with TOKEN_STORE_PATH=/data/tokens.json for
OAuth mode). The repository's .gitignore already excludes .env,
docker-compose.yml, and Caddyfile.
Create docker-compose.yml:
services:
gtm-mcp:
build: .
image: gtm-mcp-server:local
restart: unless-stopped
env_file: .env
volumes:
- gtm-mcp-data:/data
# Service-account mode with a key file only:
# - ./secrets/sa.json:/secrets/sa.json:ro
caddy:
image: caddy:2
restart: unless-stopped
depends_on:
- gtm-mcp
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy-data:/data
- caddy-config:/config
volumes:
gtm-mcp-data:
caddy-data:
caddy-config:
Create Caddyfile:
gtm-mcp.example.com {
reverse_proxy gtm-mcp:8080
}
Start it:
docker compose up -d --build
docker compose logs -f gtm-mcp
Notes for this setup:
gtm-mcp service publishes no port; only Caddy is reachable from
outside.gtm-mcp.example.com
resolves publicly to this machine and ports 80 and 443 are reachable from the
internet. For a host reachable only internally, replace the site block's
automatic certificate with your organization's certificate
(tls /path/to/cert.pem /path/to/key.pem, mounted into the Caddy container)
or use a Caddy DNS-challenge plugin.PORT unset (8080) inside the container: the image's HEALTHCHECK
always probes http://localhost:8080/health.appuser and creates /data owned by
that user with mode 700. A named volume, as above, inherits that ownership
on first use. If you bind-mount a host directory to /data instead, make it
owned by the container user's UID.sa.json must be readable by the container user. Find its UID
with docker compose run --rm --no-deps --entrypoint id gtm-mcp, then run
sudo chown <uid> secrets/sa.json && chmod 400 secrets/sa.json.git fetch --tags && git checkout <new tag> && docker compose up -d --build.
Tokens survive in the gtm-mcp-data volume.If you already run a reverse proxy on the host, skip Caddy and publish the server on the loopback interface only:
docker build -t gtm-mcp-server:local .
docker run -d \
--name gtm-mcp-server \
--restart unless-stopped \
-p 127.0.0.1:8080:8080 \
--env-file .env \
-v gtm-mcp-data:/data \
gtm-mcp-server:local
VERSION=1.15.0 # latest version from the release page
ARCH=amd64 # or arm64
curl -fsSLO "https://github.com/paolobietolini/gtm-mcp-server/releases/download/v${VERSION}/gtm-mcp-server_${VERSION}_linux_${ARCH}.tar.gz"
curl -fsSLO "https://github.com/paolobietolini/gtm-mcp-server/releases/download/v${VERSION}/gtm-mcp-server_${VERSION}_checksums.txt"
sha256sum --check --ignore-missing "gtm-mcp-server_${VERSION}_checksums.txt"
tar -xzf "gtm-mcp-server_${VERSION}_linux_${ARCH}.tar.gz"
sudo install -m 0755 gtm-mcp-server /usr/local/bin/gtm-mcp-server
Create a system user, a data directory, and the configuration file:
sudo useradd --system --home-dir /var/lib/gtm-mcp --shell /usr/sbin/nologin gtm-mcp
sudo install -d -o gtm-mcp -g gtm-mcp -m 0700 /var/lib/gtm-mcp
sudo install -d -o root -g gtm-mcp -m 0750 /etc/gtm-mcp
sudoedit /etc/gtm-mcp/gtm-mcp.env
sudo chown root:gtm-mcp /etc/gtm-mcp/gtm-mcp.env
sudo chmod 0640 /etc/gtm-mcp/gtm-mcp.env
Use the content from step 3 in /etc/gtm-mcp/gtm-mcp.env, with
TOKEN_STORE_PATH=/var/lib/gtm-mcp/tokens.json and, for a key file,
GOOGLE_APPLICATION_CREDENTIALS=/etc/gtm-mcp/sa.json (owner root:gtm-mcp,
mode 0640).
Create /etc/systemd/system/gtm-mcp.service:
[Unit]
Description=GTM MCP Server
After=network-online.target
Wants=network-online.target
[Service]
User=gtm-mcp
Group=gtm-mcp
WorkingDirectory=/var/lib/gtm-mcp
EnvironmentFile=/etc/gtm-mcp/gtm-mcp.env
ExecStart=/usr/local/bin/gtm-mcp-server
Restart=on-failure
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/gtm-mcp
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now gtm-mcp
journalctl -u gtm-mcp -f
The binary listens on PORT (default 8080) on all interfaces. Put a reverse
proxy in front of it (see below) and block direct access to that port with
your firewall.
Requires Go 1.26 or later.
git clone https://github.com/paolobietolini/gtm-mcp-server.git
cd gtm-mcp-server
git checkout v1.15.0 # or stay on main for unreleased changes
go build -o gtm-mcp-server .
./gtm-mcp-server
The server reads .env from the current working directory, then
.env.local. Variables already set in the process environment take
precedence over .env, and .env.local overrides both. Both files are ignored
by Git. For quick local testing, go run . with this .env is enough:
BASE_URL=http://localhost:8080
GOOGLE_CLIENT_ID=<client-id>.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=<client-secret>
TOKEN_STORE_PATH=./data/tokens.json
Any reverse proxy works if it:
Authorization header through;text/event-stream (Server-Sent Events) response;X-Forwarded-For (required for per-client rate limits with
TRUST_PROXY=true).Caddy does all of this with the two-line reverse_proxy configuration above.
For nginx:
server {
listen 443 ssl;
server_name gtm-mcp.example.com;
ssl_certificate /etc/ssl/gtm-mcp/fullchain.pem;
ssl_certificate_key /etc/ssl/gtm-mcp/privkey.pem;
client_max_body_size 5m;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 1h;
}
}
X-Forwarded-For $remote_addr overwrites any value sent by the client, which
is what the server expects with one proxy hop. If a load balancer or CDN sits
in front of this proxy, the rightmost X-Forwarded-For entry is that
intermediary's address, so all users share one rate-limit bucket: configure
your proxy to restore the real client address first.
Health check, which needs no authentication:
curl -sS https://gtm-mcp.example.com/health
Expected: {"service":"gtm-mcp-server","status":"healthy","version":"1.15.0"}.
OAuth metadata (OAuth mode):
curl -sS https://gtm-mcp.example.com/.well-known/oauth-protected-resource
resource must be https://gtm-mcp.example.com/ and
authorization_servers must contain https://gtm-mcp.example.com. If they
show http:// or another host, BASE_URL is wrong.
Unauthenticated MCP request:
curl -sS -i -X POST https://gtm-mcp.example.com/
Expected: HTTP/... 401 with the header
WWW-Authenticate: Bearer resource_metadata="https://gtm-mcp.example.com/.well-known/oauth-protected-resource".
Any other status means the server is running in open mode.
API key (service-account mode):
curl -sS https://gtm-mcp.example.com/ \
-H "Authorization: Bearer $SERVICE_ACCOUNT_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}'
Expected: a JSON-RPC result containing "serverInfo":{"name":"gtm-mcp-server",...},
possibly wrapped in an SSE data: line. This checks the API key only, not
the Google credentials.
Startup log lines to look for (JSON on stderr):
OAuth configured and token persistence enabled in OAuth mode;s2s_mode_enabled with credential_source key_json or
workload_identity (the latter also covers GOOGLE_APPLICATION_CREDENTIALS)
in service-account mode. If the credentials cannot be loaded, the server
logs s2s_mode_failed and exits.End-to-end: connect a client (next section) and ask it to "List my GTM accounts. Do not make changes." An empty list means the authenticated Google identity has no GTM access yet (step 2b, item 2, for a service account). An error saying the Tag Manager API is disabled or has not been used in the project means step 1 was skipped for the project that owns the OAuth client or service account.
TOKEN_STORE_PATH holds every user's MCP tokens and Google
OAuth tokens, including Google refresh tokens, as plain JSON (file mode
0600, written atomically). Treat it like a password database: restrict
access to the host, and exclude it from unencrypted backups. Deleting it
signs everyone out.ACCESS_TOKEN_TTL (8 hours by
default). After expiry the server renews them silently while the Google
refresh token is valid, for at most AUTH_AUTO_REFRESH_MAX_AGE (7 days)
after issue; then the client must complete a refresh, or a new sign-in./authorize, /oauth/callback, and /token allow 10
requests per second per client IP (burst 20); /register allows 2 per
second (burst 5).LOG_LEVEL=debug for per-request authentication details.
Authentication logs identify tokens by a fingerprint, not by their value.For one person on their own machine, the MCP client can start the server as a
local process over stdin/stdout. No HTTP server, OAuth client, reverse proxy,
or API key is involved. Stdio mode always uses service-account credentials
(step 2b): GOOGLE_SERVICE_ACCOUNT_KEY_JSON, or a key file named by
GOOGLE_APPLICATION_CREDENTIALS, or Application Default Credentials.
Install the binary (Option B above, first block only), then test it:
GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa.json gtm-mcp-server --stdio
The process waits for MCP messages on stdin; stop it with Ctrl+C.
Claude Code example (.mcp.json):
{
"mcpServers": {
"gtm": {
"command": "/usr/local/bin/gtm-mcp-server",
"args": ["--stdio"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/sa.json",
"GTM_TOOL_GROUPS": "all"
}
}
}
}
MCP_TRANSPORT=stdio is equivalent to the --stdio argument. Logs go to
stderr; stdout carries only MCP messages. The server also reads .env from the
directory the client starts it in.
Set DASHBOARD_ENABLED=true and restart the server to expose /dashboard/.
The page shows the canonical MCP endpoint, server version, authentication setup
status, and connection instructions. It is disabled by default.
The dashboard is public when enabled. It deliberately excludes tokens, sessions, account names, container data, and other GTM content. It reports server configuration only and does not verify the visitor's Google session.
The MCP endpoint is your BASE_URL itself, for example
https://gtm-mcp.example.com. In OAuth mode the client discovers the OAuth
metadata, opens Google sign-in in the browser, and reconnects with the issued
bearer token. In service-account mode the client sends the API key in the
Authorization header on every request.
# OAuth mode
claude mcp add --transport http gtm https://gtm-mcp.example.com
# Service-account mode
claude mcp add --transport http gtm https://gtm-mcp.example.com \
--header "Authorization: Bearer <SERVICE_ACCOUNT_API_KEY>"
gemini mcp add --transport http gtm https://gtm-mcp.example.com
Or in settings.json (remove headers for OAuth mode):
{
"mcpServers": {
"gtm": {
"httpUrl": "https://gtm-mcp.example.com",
"headers": {
"Authorization": "Bearer <SERVICE_ACCOUNT_API_KEY>"
}
}
}
}
Add the following to .cursor/mcp.json (remove headers for OAuth mode):
{
"mcpServers": {
"gtm": {
"url": "https://gtm-mcp.example.com",
"headers": {
"Authorization": "Bearer <SERVICE_ACCOUNT_API_KEY>"
}
}
}
}
Add the following to .vscode/mcp.json (OAuth mode):
{
"servers": {
"gtm": {
"type": "http",
"url": "https://gtm-mcp.example.com"
}
}
}
Add a custom or remote MCP connection in the client and use your BASE_URL as
the server URL. Web connectors require a server reachable from the public
internet and OAuth mode. Product menus change more often than this server, so
refer to the client's current MCP connection instructions if the label
differs.
After connecting, try:
List my GTM accounts, containers, and workspaces. Do not make changes.
The Google identity used (the account chosen at sign-in, or the service account) determines which GTM accounts the server can access.
list_accounts, list_containers, and list_workspaces to discover
IDs. Do not guess IDs.audit_container prompt.get_workspace_status and resolve conflicts before versioning.create_version to snapshot the workspace.get_version.publish_version with confirm: true only when the selected version
is ready to go live.get_live_version.Example requests:
All GTM tools use the authenticated Google identity from the current MCP request. Inputs and outputs are structured JSON.
Tools marked opt-in belong to a tool group that is not enabled by default.
Enable it through GTM_TOOL_GROUPS (see Tool groups).
Always available, regardless of GTM_TOOL_GROUPS.
| Tool | Purpose |
|---|---|
ping | Test MCP connectivity |
auth_status | Check whether the current request is authenticated |
| Tool | Purpose |
|---|---|
list_accounts | List accessible GTM accounts |
update_account | Rename an account |
list_containers | List containers and their public IDs and settings |
lookup_container | Find a container by destination ID or GTM public tag ID |
get_container_snippet | Get a web install snippet or server-container configuration |
create_container | Create a web, app, AMP, or server container |
update_container | Rename a container while preserving its other settings |
delete_container | Permanently delete a container; requires confirm: true |
combine_containers | Merge a source container into a target; requires confirm: true. Opt-in: container-admin |
move_tag_id | Move a tag ID into a new container; requires confirmation and terms acceptance. Opt-in: container-admin |
| Tool | Purpose |
|---|---|
list_workspaces | List workspaces in a container |
create_workspace | Create a workspace |
get_workspace | Get workspace metadata and its current fingerprint |
update_workspace | Update selected workspace fields |
delete_workspace | Delete a workspace; requires confirm: true |
quick_preview_workspace | Compile an ephemeral preview without saving or publishing |
get_workspace_status | List the entities added, updated or deleted, and merge conflicts |
bulk_update_workspace | Apply multiple entity changes; requires confirm: true. Opt-in: workspace-admin |
resolve_workspace_conflict | Replace a conflict with a resolved entity; requires confirm: true. Opt-in: workspace-admin |
sync_workspace | Synchronize with the latest container version; requires confirm: true. Opt-in: workspace-admin |
Bulk update and conflict resolution accept raw GTM Entity JSON so every entity type supported by the official API remains available.
| Tool | Purpose |
|---|---|
list_tags | List workspace tags |
get_tag | Get complete tag details |
create_tag | Create a tag |
update_tag | Update a tag with fingerprint-based concurrency control |
delete_tag | Delete a tag; requires confirm: true |
| Tool | Purpose |
|---|---|
list_triggers | List workspace triggers |
get_trigger | Get complete trigger details |
create_trigger | Create a trigger |
update_trigger | Update a trigger with fingerprint-based concurrency control |
delete_trigger | Delete a trigger; requires confirm: true |
For update_trigger, omit filterJson, customEventFilterJson,
autoEventFilterJson, or parameterJson to preserve the current field. Pass
the JSON string "[]" to clear a field, or a non-empty JSON array to replace
it. For click, link-click, and form-submission triggers, use filterJson because
GTM drops autoEventFilter for those trigger types.
| Tool | Purpose |
|---|---|
list_variables | List workspace variables |
get_variable | Get complete variable details |
create_variable | Create a variable |
update_variable | Update a variable with fingerprint-based concurrency control |
delete_variable | Delete a variable; requires confirm: true |
| Tool | Purpose |
|---|---|
list_folders | List workspace folders |
get_folder_entities | List tags, triggers, and variables assigned to a folder |
get_folder | Get complete folder metadata. Opt-in: folder-admin |
create_folder | Create a folder. Opt-in: folder-admin |
update_folder | Update a folder with fingerprint protection. Opt-in: folder-admin |
delete_folder | Delete a folder; requires confirm: true. Opt-in: folder-admin |
move_entities_to_folder | Move tags, triggers, and variables; requires confirm: true. Opt-in: folder-admin |
revert_folder | Discard workspace folder changes; requires confirm: true. Opt-in: folder-admin |
list_built_in_variables | List enabled built-in variables |
enable_built_in_variables | Enable built-in variable types |
disable_built_in_variables | Disable built-in variable types; requires confirm: true |
Use revert_workspace_entity (opt-in group reverts) to discard changes to a
built-in variable.
| Tool | Purpose |
|---|---|
list_zones | List all zones across every result page |
get_zone | Get boundary, child-container, and type-restriction configuration |
create_zone | Create a workspace zone |
update_zone | Update selected fields with fingerprint concurrency control |
delete_zone | Delete a zone; requires confirm: true |
Use revert_workspace_entity (opt-in group reverts) to discard changes to a
zone.
All tools in this section are opt-in (group environments).
| Tool | Purpose |
|---|---|
list_environments | List all container environments across every result page |
get_environment | Get environment configuration and authorization metadata |
create_environment | Create a user environment |
update_environment | Update selected fields with fingerprint concurrency control |
reauthorize_environment | Rotate the authorization code; requires confirm: true |
delete_environment | Delete a user environment; requires confirm: true |
The Live and Latest environments are managed by GTM. Creation and deletion apply to user environments; GTM permits URL and debug updates on other types.
All tools in this section are opt-in: the destination tools are in group
destinations, the Google tag configuration tools in group gtag.
| Tool | Purpose |
|---|---|
list_destinations | List Google tag destinations linked to a container |
get_destination | Get a destination by its link ID |
link_destination | Move a destination to a container; requires confirm: true |
list_google_tag_configs | List Google tag configurations in a workspace |
get_google_tag_config | Get a Google tag configuration |
create_google_tag_config | Create a Google tag configuration |
update_google_tag_config | Update a configuration with fingerprint protection |
delete_google_tag_config | Delete a configuration; requires confirm: true |
Container combine, tag-ID move, and destination link operations do not copy or enable user permissions. Account permission management remains outside the current parity target.
| Tool | Purpose |
|---|---|
list_templates | List custom templates |
get_template | Get template metadata and template code |
create_template | Create a custom template from .tpl code |
update_template | Update template code |
delete_template | Delete an unused template; requires confirm: true |
import_gallery_template | Import a Community Template Gallery template |
get_tag_templates | Return compact GA4 and Custom HTML input examples |
get_trigger_templates | Return compact trigger input examples |
The full JSON examples live in the
gtm://best-practices/tool-input-formats resource so every tool listing does
not repeat them.
| Tool | Purpose |
|---|---|
list_clients | List server-container clients |
get_client | Get a client |
create_client | Create a client |
update_client | Update a client |
delete_client | Delete a client; requires confirm: true |
list_transformations | List transformations |
get_transformation | Get a transformation |
create_transformation | Create a transformation |
update_transformation | Update a transformation |
delete_transformation | Delete a transformation; requires confirm: true |
Use revert_workspace_entity (opt-in group reverts) to discard changes to a
client or transformation.
| Tool | Purpose |
|---|---|
list_versions | List all saved version headers across every result page |
get_latest_version_header | Get the latest saved header, which may differ from live |
get_version | Get a saved version and its complete entity collections |
get_live_version | Get the currently published version and its entities |
create_version | Create a version from a conflict-free workspace |
publish_version | Publish a selected version; requires confirm: true |
update_version | Update a saved version's name or description. Opt-in: version-admin |
delete_version | Soft-delete a version; requires confirm: true. Opt-in: version-admin |
undelete_version | Restore a soft-deleted version; requires confirm: true. Opt-in: version-admin |
set_latest_version | Make a version Latest without publishing; requires confirm: true. Opt-in: version-admin |
Opt-in (group reverts).
| Tool | Purpose |
|---|---|
revert_workspace_entity | Discard workspace changes to a built-in variable, client, tag, template, transformation, trigger, variable, or zone; requires confirm: true |
The tool fetches the current entity fingerprint before calling the matching
official revert method. A successful result can have existsAfterRevert: false
when the entity does not exist in the latest container version.
confirm: true (--confirm in the CLI).create_version first checks that the workspace has changes and no merge
conflicts./token and /register accept at
most 1 MiB and, with the other OAuth endpoints, are rate limited per client
IP.Most entity edits affect a workspace and are not live until a version is published. Account and container operations act directly on those resources. Always review the target IDs and the generated version before publication.
The server exposes two concrete resources and six URI templates. Resources and
prompts are always available, regardless of GTM_TOOL_GROUPS.
| URI | Content |
|---|---|
gtm://accounts | Accessible accounts |
gtm://accounts/{accountId}/containers | Containers |
gtm://accounts/{accountId}/containers/{containerId}/workspaces | Workspaces |
gtm://accounts/{accountId}/containers/{containerId}/workspaces/{workspaceId}/tags | Tags |
gtm://accounts/{accountId}/containers/{containerId}/workspaces/{workspaceId}/triggers | Triggers |
gtm://accounts/{accountId}/containers/{containerId}/workspaces/{workspaceId}/variables | Variables |
gtm://best-practices | Best-practice topic index |
gtm://best-practices/{topic} | One embedded guidance document |
Best-practice topics include naming and organization, safe edits, GA4 and consent, server-side containers, and detailed tool input formats.
| Prompt | Purpose |
|---|---|
audit_container | Review tags, triggers, and variables for quality problems |
generate_tracking_plan | Build a Markdown tracking plan from a workspace |
suggest_ga4_setup | Recommend a GA4 structure from stated goals |
find_gallery_template | Guide Community Gallery discovery and import |
best_practices_review | Score a workspace against embedded guidance |
plan_safe_edit | Produce a staged edit/version/publish plan |
Prompts prepare context and instructions for the model. They do not bypass tool authentication or mutation safeguards.
skills/ holds Agent Skills with the GTM
know-how, usable without this server. The know-how skills work with the MCP tools,
with the gtm-cli for the operations it covers, or with
a container export (GTM > Admin > Export Container) pasted or attached in a chat.
| Skill | Use it for |
|---|---|
gtm-container-audit | Audit and scored best-practices review |
gtm-safe-edit | Planning, applying, publishing and rolling back changes |
gtm-tracking-plan | Tracking plans and data layer specs |
gtm-ga4-consent | GA4 setup and debugging, consent mode v2 |
gtm-server-side | Server containers, data flow, transformations |
gtm-mcp | Operating this server's tools; only useful with the server |
gtm-cli | Operating the gtm-cli command-line tool |
Each skill folder is self-contained: install all of them or only some.
Install them as a plugin from this repository:
/plugin marketplace add paolobietolini/gtm-mcp-server
/plugin install gtm-skills@gtm-mcp-server
Plugin skills are namespaced, for example /gtm-skills:gtm-safe-edit. The
plugin install copies the whole repository into Claude Code's plugin cache.
Alternatively, from a clone, copy the folders into your personal skills
directory (or into .claude/skills/ of a project):
mkdir -p ~/.claude/skills
cp -r skills/gtm-* ~/.claude/skills/
Code execution and file creation must be enabled (Settings > Capabilities; on Team and Enterprise plans an owner controls this and can turn off custom skills). Build one ZIP per skill, with the skill folder at the ZIP root:
mkdir -p dist
(cd skills && for s in gtm-*; do zip -qr "../dist/$s.zip" "$s"; done)
Then open Customize > Skills, click +, choose Create skill > Upload a skill, upload a ZIP, and turn the skill on.
Copy the skills/gtm-* folders into the directory your client reads:
| Client | Project | Personal |
|---|---|---|
| Codex | .agents/skills/ | ~/.agents/skills/ |
| VS Code / GitHub Copilot | .github/skills/ | ~/.copilot/skills/ |
For other clients that support the standard, see their documentation and the Agent Skills site.
All settings are environment variables, optionally loaded from .env and
.env.local (see Option C for precedence).
| Variable | Default | Purpose |
|---|---|---|
PORT | 8080 | HTTP listen port (all interfaces). Leave at 8080 in Docker |
BASE_URL | http://localhost:8080 | Public URL of the server, no trailing slash. Used for OAuth metadata and as the base of the redirect URI BASE_URL/oauth/callback |
MCP_TRANSPORT | http | http (Streamable HTTP) or stdio; the --stdio argument overrides it |
MCP_STATELESS_HTTP | true | Disable in-memory MCP HTTP sessions; required for MCP 2026-07-28 |
DASHBOARD_ENABLED | false | Expose the public connection setup page at /dashboard/ |
GOOGLE_CLIENT_ID | empty | Google OAuth web-client ID. With GOOGLE_CLIENT_SECRET, enables OAuth mode |
GOOGLE_CLIENT_SECRET | empty | Google OAuth web-client secret |
ACCESS_TOKEN_TTL | 8h | Lifetime of MCP access tokens (Go duration) |
AUTH_AUTO_REFRESH_MAX_AGE | 168h | Maximum age of a bearer token that is still renewed silently (Go duration) |
TOKEN_STORE_PATH | empty | File that persists issued tokens across restarts; empty keeps them in memory only. The directory is created with mode 0700 if missing |
SERVICE_ACCOUNT_API_KEY | empty | Bearer API key that enables service-account mode over HTTP |
GOOGLE_SERVICE_ACCOUNT_KEY_JSON | empty | Service-account key as a JSON string. Takes precedence over Application Default Credentials |
GOOGLE_APPLICATION_CREDENTIALS | empty | Standard Google variable: path to a service-account key file, used through Application Default Credentials |
ALLOWED_HOSTS | empty | Comma-separated extra host[:port] values trusted for URL resolution (Docker-internal names) |
TRUST_PROXY | false | Use the rightmost X-Forwarded-For entry as the client IP for rate limiting |
LOG_LEVEL | info | debug enables debug logs; any other value means info |
GTM_TOOL_GROUPS | 11 default groups | Comma-separated tool groups advertised through MCP, or all |
GOOGLE_REDIRECT_URI and JWT_SECRET are read for backward compatibility but
have no effect.
Service-account credentials are looked up in this order:
GOOGLE_SERVICE_ACCOUNT_KEY_JSON, then Application Default Credentials (the
file in GOOGLE_APPLICATION_CREDENTIALS, then the file created by
gcloud auth application-default login, then the service account attached on
Google Cloud). In HTTP mode they are loaded
only when SERVICE_ACCOUNT_API_KEY is set; in stdio mode they are always
required.
Streamable HTTP is stateless by default: the server keeps no in-memory MCP
session and ignores Mcp-Session-Id, so MCP requests survive a restart. This
is required for MCP 2026-07-28 tool requests; legacy MCP 2025-11-25
clients remain supported. Stateless mode does not disable authentication:
clients send credentials on every MCP request. OAuth tokens are still held by
a single process (see Self-hosting). Set
MCP_STATELESS_HTTP=false only if a client depends on HTTP sessions or the
GET event stream; this server makes no server-to-client requests.
TRUST_PROXY=true is appropriate only when a trusted reverse proxy overwrites
or appends X-Forwarded-For. The implementation uses the rightmost value,
which assumes exactly one proxy hop. With several hops, configure and test the
trust boundary before relying on per-client rate limits.
ALLOWED_HOSTS is a comma-separated allowlist used when the same server is
reached through trusted internal Docker hostnames (for example
gtm-mcp:8080). For a request whose Host header is on the list, OAuth
metadata is built from that host instead of BASE_URL. Do not add arbitrary
public hosts.
GTM_TOOL_GROUPS controls schema size for clients that need only part of the
API. Names are case-insensitive; an unknown name stops the server at startup.
| Group | Enabled by default | GTM tools |
|---|---|---|
accounts | yes | 8 |
workspaces | yes | 13 (workspaces plus list_versions, get_latest_version_header, get_version, get_live_version, create_version, publish_version) |
tags | yes | 5 |
triggers | yes | 5 |
variables | yes | 5 |
folders | yes | 2 |
builtins | yes | 3 |
zones | yes | 5 |
templates | yes | 6 |
server | yes | 10 |
guidance | yes | 2 |
environments | no | 6 |
destinations | no | 3 |
gtag | no | 5 |
container-admin | no | 2 |
folder-admin | no | 6 |
workspace-admin | no | 3 |
version-admin | no | 4 |
reverts | no | 1 |
Leaving the variable unset enables the 11 default groups (64 tools). An explicit list replaces the defaults instead of adding to them, so to keep the defaults and add one opt-in group, list them all:
GTM_TOOL_GROUPS=accounts,workspaces,tags,triggers,variables,folders,builtins,zones,templates,server,guidance,environments
Use all to enable every group (94 tools), including groups added in future
versions. A subset is also valid:
GTM_TOOL_GROUPS=accounts,workspaces,tags,triggers,variables
The two utility tools, the resources, and the prompts are always available.
server.json is the source of truth for the runtime version. It is embedded in
the Go binary and returned by /health; there is no second version constant in
Go code.
To publish a release:
server.json.v1.15.0.The release workflow rejects a tag that does not match server.json, then
creates cross-platform archives of the server (gtm-mcp-server_*) and the CLI
(gtm-cli_*) plus a checksums file with GoReleaser and attaches them to the GitHub
release. It does not deploy anything.
Recent commits on main can be newer than the latest tagged release. Check the
release page when
you need a reproducible published artifact.
go test ./... -count=1
go vet ./...
staticcheck ./...
go run ./cmd/tool-schema-report
go run ./cmd/tool-schema-report -groups tags,zones
The schema report prints the GTM tool count, serialized tools/list size, token
estimate, and largest definitions. The default GTM tool surface serializes to
78,734 bytes for 64 tools. A regression test enforces an 80,000-byte ceiling so
new parity work does not silently consume unlimited model context. The all
group exposes 94 GTM tools and serializes to 115,748 bytes.
skills/ is the only source: the server embeds these folders and reads its
best-practice resources and prompt guidance from them. A file used by several
skills is edited in one of them, listed in copies in
skills/skills_test.go, then copied to the others:
go test ./skills -update
go test ./skills fails if a copy differs, if skill frontmatter or links are
invalid, if a skill refers to anything outside its folder, or if it names a tool
the server does not register. Rebuild the server to pick up changes.
Pull requests run go test, govulncheck, gosec, Gitleaks, Trivy, staticcheck, and
CodeQL. Request-level GTM tests use local fake Google endpoints. Mutating live
tests must use a disposable container and clean up their entities.
See ARCHITECTURE.md for package boundaries, request flow, authentication internals, token persistence, and security invariants.
For a deep dive into the Google Tag Manager MCP server, read the Deep Wiki.
stape-io/google-tag-manager-mcp-server
is the actively maintained alternative. It covers the same GTM API, has a free
hosted endpoint with Google sign-in, and a local npx mode for your own
credentials. Use it if you do not want to self-host, or if you want new
features.
This server stays available for people who want to self-host a Go binary, to
select the tools the model sees with tool groups, or to require
confirm: true before delete and publish operations.
llms.txt is embedded in the binary and served by every
instance at <BASE_URL>/llms.txt.skills/ contains the Agent Skills.examples/gtm_agent.py demonstrates a programmatic
MCP client.examples/workspace-diff.sh diffs a workspace
against the latest version with gtm-cli, jq and diff.BSD 3-Clause. See LICENSE.
Maintained by Paolo Bietolini.
Loading reviews...
GitHub checked 40h ago - refresh overdue. Recently viewed repositories target hourly refresh.
Find a documented setup for your client. No sign-in, installation, or tool execution.
If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.