# Google Tag Manager MCP server: let Claude or Cursor manage your GTM container

> How to connect Google Tag Manager to Claude, Cursor or Gemini with an MCP server: the main options, setup steps, useful prompts, and the safety rules to follow before letting AI edit a live container.

**In short:**
- Google doesn't publish an official GTM MCP server; third-party servers (Stape's hosted one, open-source self-hosted ones) wrap the Tag Manager API v2.
- The fastest setup is npx mcp-remote https://gtm-mcp.stape.ai/mcp with Google OAuth.
- Use AI read-only first, in a separate workspace, and never give it publish rights.

- URL: https://noxtag.com/google-tag-manager-mcp/
- Category: AI + analytics
- Last updated: 2026-12-03
- Publisher: noxtag (https://noxtag.com)

A **Google Tag Manager MCP server** lets an AI assistant like Claude, Cursor or Gemini read and edit your GTM containers through the Tag Manager API. Instead of clicking through dozens of tags, you ask: *"List every tag that fires on All Pages"* or *"Create a GA4 event tag for `generate_lead` with form_id and lead_type."*

It's genuinely useful for audits and repetitive setup. It's also a direct line from a language model to your live tracking, so the safety rules at the end of this guide matter.

![How a GTM MCP server connects your AI client to Tag Manager](https://noxtag.com/img/gtm-mcp-how-it-works.svg)
*Figure: How a GTM MCP server works. How a GTM MCP server connects your AI client to Tag Manager.*

## Is there an official Google Tag Manager MCP server?

Not from Google, at the time of writing. Google publishes an official [Google Analytics MCP server](https://noxtag.com/google-analytics-mcp-setup/), but the GTM servers are built by third parties. They all wrap the same **Tag Manager API v2**, and they differ in hosting, authentication and how much they let the AI change.

The most widely used options:

| Server | How it runs | Auth | Good for |
|---|---|---|---|
| **Stape's GTM MCP server** | Hosted remote endpoint (`gtm-mcp.stape.ai`), connected via `mcp-remote` | Google OAuth in the browser | Quickest start, no credentials to manage |
| **GTM Editor MCP** (open source) | Hosted (`mcp.gtmeditor.com`) or self-hosted binary/Docker | Google OAuth | Teams that want to self-host |
| **npm packages** (several) | Local `npx` process | Service account or OAuth | Developers who want everything local |

![Hosted vs self-hosted: what you trade off](https://noxtag.com/img/gtm-mcp-options.svg)
*Figure: Hosted vs. self-hosted GTM MCP. Hosted vs self-hosted: what you trade off.*

## Setup: the hosted route (fastest)

Stape's server is free to use and runs remotely, so there's nothing to install except a small bridge.

**Claude Desktop:** open Settings → Developer → Edit Config, and add:

```json
{
  "mcpServers": {
    "gtm-mcp-server": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://gtm-mcp.stape.ai/mcp"]
    }
  }
}
```

Restart Claude Desktop. The first time a GTM tool is called, a browser window opens for Google sign-in. Approve access with an account that has the GTM permissions you want the AI to have.

**Claude Code:**

```bash
claude mcp add gtm-mcp-server -- npx -y mcp-remote https://gtm-mcp.stape.ai/mcp
```

**Cursor:** Settings → MCP → Add new MCP server, with the same command and arguments.

You'll need **Node.js 18 or newer** for `npx`.

> **Keep the server name short.** Some clients, such as Cursor, cap the combined length of the server name and tool name at 60 characters, and silently drop tools beyond it. `gtm-mcp-server` or just `gtm` is safe.

If authentication gets stuck, clear the cached tokens with `rm -rf ~/.mcp-auth` and restart the client.

## Setup: the self-hosted route

If your company won't allow a third-party server to hold OAuth tokens for your GTM accounts, run an open-source server yourself:

1. Create a Google Cloud project and enable the **Tag Manager API**.
2. Create OAuth credentials (desktop app), or a service account added as a user in GTM.
3. Run the server locally (`npx`, binary or Docker) following its README, and point your MCP client at it.

Self-hosting means the tokens and API calls never leave infrastructure you control.

## Prompts that are actually useful

![Audit questions an AI can answer in seconds with GTM access](https://noxtag.com/img/gtm-mcp-prompts.svg)
*Figure: Audit prompts that work with GTM MCP. Audit questions an AI can answer in seconds with GTM access.*

**Auditing (read-only, safe):**
- *"In container GTM-XXXX, list all tags with their triggers. Flag any tag that fires on All Pages but isn't a configuration tag."*
- *"Which tags are paused, and which triggers aren't used by any tag?"*
- *"Find every Custom HTML tag and summarise what each script does."* Custom HTML is where security and performance problems hide.
- *"Compare the live version with the current workspace and list what changed."*

**Building (writes to a workspace):**
- *"Create a Data Layer Variable for `form_id` and `lead_type`, a Custom Event trigger for `generate_lead`, and a GA4 event tag that sends both parameters."*
- *"Rename all tags to the pattern `Platform - Type - Detail` and move them into folders by platform."*

**Documentation:**
- *"Generate a tracking plan table from this container: event name, trigger, parameters and destination."*

## Safety rules before you let AI touch GTM

![Six rules for using AI on a live GTM container](https://noxtag.com/img/gtm-mcp-safety.svg)
*Figure: 6 rules before AI touches your GTM. Six rules for using AI on a live GTM container.*

GTM changes go live for every visitor the moment a version is published. Treat AI access like giving a junior team member edit rights:

1. **Start read-only.** Use the AI for audits first. Give it an account with **Read** access to the container.
2. **Work in a separate workspace.** Ask the AI to create its own workspace (for example "ai-changes"), never the Default Workspace that people are editing.
3. **Never let it publish.** Give the account **Edit**, not **Publish**. A human reviews the workspace and publishes.
4. **Always preview.** Test every AI-made change in GTM Preview and GA4 DebugView before publishing.
5. **Review Custom HTML carefully.** Don't publish scripts the AI wrote without reading every line.
6. **Use version notes.** Ask the AI to write a version description listing every change. That's your audit trail.

![A safe workflow: AI drafts, humans review and publish](https://noxtag.com/img/gtm-mcp-workflow.svg)
*Figure: A safe AI + GTM workflow. A safe workflow: AI drafts, humans review and publish.*

## GTM MCP vs doing it by hand

MCP shines at **breadth**: auditing 200 tags, renaming everything to a convention, or documenting a container nobody understands. It's weaker at **judgement**: whether a tag should exist, whether a trigger matches the business logic, or whether consent is handled correctly. That still needs someone who knows how the site and the business work.

> **Further reading:** [Google Tag Manager triggers explained: every type, with examples](https://noxtag.com/google-tag-manager-triggers/)

## Frequently asked questions

### Is there an official Google Tag Manager MCP server?

Google doesn't publish an official Tag Manager MCP server at the time of writing. Google does publish an official Google Analytics MCP server. GTM MCP servers come from third parties such as Stape and open-source projects, and they all use the Tag Manager API v2.

### How do I connect Claude to Google Tag Manager?

Add an MCP server to Claude. For Stape's hosted server, add a server that runs npx -y mcp-remote https://gtm-mcp.stape.ai/mcp, restart Claude, and complete the Google sign-in when prompted. Claude can then read and edit the containers your Google account can access.

### Is it safe to let AI edit a GTM container?

It's safe with guardrails: start with read-only access, have the AI work in a separate workspace, never give it publish rights, preview every change in GTM Preview and GA4 DebugView, and read any Custom HTML it writes before a human publishes.

### What can a GTM MCP server do?

A GTM MCP server lets an AI assistant list and audit tags, triggers and variables, find unused or paused items, compare versions, create or edit tags in a workspace, rename items to a convention, and document a container as a tracking plan.

## Want a container audit done properly?

An AI can list what's in your container. Knowing what's wrong with it takes experience. Our [GA4 & GTM audit](https://noxtag.com/contact/) combines automated container analysis with a senior review of tags, triggers, data layer and consent, and ends with a prioritised fix list.

---
Source: https://noxtag.com/google-tag-manager-mcp/ · Need help with GA4 or GTM? https://noxtag.com/contact/
