Is your GA4 data actually right? Get a fixed-price GA4 & GTM audit. Request an audit
noxtag
AI + analytics

Google Tag Manager MCP server: let Claude or Cursor manage your GTM 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.

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
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, 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
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:

{
  "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:

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.

Is your GA4 & GTM setup collecting the right data?

Get a senior review of your tags, triggers, data layer and consent setup, with a prioritized fix list your developers can act on.

Fixed price · Read-only access · Reply within 1 business day

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
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
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
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.

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 combines automated container analysis with a senior review of tags, triggers, data layer and consent, and ends with a prioritised fix list.

noxtag is a small, senior tracking-implementation practice. We write these guides from real GA4 and GTM audits. More about us.