Get the FREE Ultimate OpenClaw Setup Guide →

gtm

MCP server for Google Tag Manager: read tags/triggers/variables, publish containers, and audit changes via Claude/Gemini.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio pouyanafisi-gtm-mcp node /absolute/path/to/gtm-mcp/dist/index.js \
  --env GTM_TOKEN_FILE="/absolute/path/to/gtm-mcp/token.json" \
  --env GTM_CREDENTIALS_FILE="/absolute/path/to/gtm-mcp/credentials.json"

How to use

This MCP server provides programmatic access to Google Tag Manager API v2. It exposes a rich set of operations to manage GTM accounts, containers, workspaces, tags, triggers, variables, and version management through a unified MCP interface. You can authenticate with OAuth 2.0 credentials and then perform actions such as listing accounts, creating containers, deploying tags, updating triggers, and publishing container versions. The server is designed to be driven by the MCP framework, allowing you to script complex GTM workflows and integrate GTM management into your automation pipelines. Use the provided operations reference to discover the exact endpoints and payloads supported by the GTM MCP server.

How to install

Prerequisites:

  • Node.js 18.0.0+ installed on your machine (nvm recommended).
  • npm (comes with Node.js) or yarn.
  • Google Cloud Project with Tag Manager API enabled and OAuth 2.0 Desktop credentials downloaded as credentials.json.

Install from npm (recommended for quick start):

# globally install the MCP server so you can run the gtm-mcp binary directly
npm install -g gtm-mcp

# run the MCP server (example using the installed binary)
gtm-mcp

Install from source:

# clone the repository
git clone https://github.com/pouyanafisi/gtm-mcp.git
cd gtm-mcp

# install dependencies
npm install

# build the project (if applicable)
npm run build

# run the server (example using the built dist/index.js via node)
node dist/index.js

Configure credentials by placing credentials.json and token.json in a known location and referencing them via environment variables when starting the server.

Environment setup example (from the MCP config example in README):

export GTM_CREDENTIALS_FILE=/absolute/path/to/credentials.json
export GTM_TOKEN_FILE=/absolute/path/to/token.json
node dist/index.js

Additional notes

  • Ensure you use the correct GTM account/container IDs (numeric IDs) when performing operations.
  • If authentication fails, run the dedicated auth flow (npm run auth or the provided authentication command in your setup) to generate or refresh tokens.
  • For production, consider mounting credentials securely and avoiding hard-coded paths. Use absolute paths in the env vars and keep token.json refreshed.
  • Review OPERATIONS.md and MCP_SETUP.md for platform-specific configuration and a complete list of supported operations.
  • When using the MCP server programmatically, batch requests where possible to respect API rate limits and handle retries with backoff.

Related MCP Servers

Sponsor this space

Reach thousands of developers