gtm
An MCP server for Google Tag Manager. Connect it to your LLM, authenticate once, and start managing GTM through natural language.
claude mcp add --transport stdio paolobietolini-gtm-mcp-server docker compose up -d \ --env BASE_URL="http://localhost:8080" \ --env JWT_SECRET="your-random-secret" \ --env GOOGLE_CLIENT_ID="your-client-id.apps.googleusercontent.com" \ --env GOOGLE_CLIENT_SECRET="your-client-secret"
How to use
The GTM MCP Server lets you manage Google Tag Manager containers through natural language interactions with AI assistants like Claude, ChatGPT, or Gemini. It exposes a conversational interface that can create and modify GTM tags, manage triggers and containers, audit configurations, generate tracking plans, and publish changes directly to your GTM accounts. The server also supports server-side GTM containers and a workflow of auditing, templating, and publishing changes with safeguards such as confirmations before destructive actions. To get started, run the provided server (via Docker Compose as shown in the install steps) and connect your AI assistant to the MCP endpoint. Once connected, you can ask the AI to list containers, create GA4 tags, set up ecommerce tracking, or publish a version of your workspace after reviewing changes.
Key capabilities include:
- Tag management (GA4 config/events, ecommerce tracking, custom HTML, and custom image tags)
- Trigger management (page views, dataLayer events, clicks, form submissions, timers, and groups)
- Container operations (browse, create versions, publish, organize folders, manage variables)
- Server-side container support (clients and transformations)
- AI-powered workflows (container audits, tracking plan generation, GA4 setup recommendations)
- Template gallery imports from the Community Gallery and automated imports via AI
To use the tools, ensure your MCP server is running and that your AI assistant is configured to reach the server URL (as documented in Quick Start). When you issue commands, the AI will translate them into GTM API actions through the MCP server, handling authentication via OAuth and providing confirmation prompts before actions that could affect live configurations.
How to install
Prerequisites:
- Docker and Docker Compose installed on your machine or host
- Git installed
- Access to Google Cloud project credentials for OAuth (client ID/secret) or a Google account with GTM permissions
Install and run:
-
Clone the repository: git clone https://github.com/paolobietolini/gtm-mcp-server.git cd gtm-mcp-server
-
Prepare environment variables (.env or via docker-compose env): GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=your-client-secret JWT_SECRET=$(openssl rand -base64 32) BASE_URL=http://localhost:8080
-
Start the MCP server using Docker Compose (recommended for this project): docker compose up -d
-
Connect AI assistants:
- Claude: add MCP with the URL http://localhost:8080
- ChatGPT: configure MCP integration with the same URL in your apps platform
- Gemini: add MCP with transport http and URL http://localhost:8080 gtm
Notes:
- The Quick Start section in the README provides CLI snippets for connecting Claude, ChatGPT, and Gemini to the MCP endpoint.
- If you are running inside separate containers, consider setting ALLOWED_HOSTS in your .env for internal Docker networking.
Optional steps (production):
- Use a reverse proxy and TLS termination (e.g., nginx + certbot) and set BASE_URL to your public URL.
- Configure additional security settings and OAuth credentials in Google Cloud Console.
Additional notes
Tips and common considerations:
- The server uses OAuth 2.1 for Google authentication; credentials are not stored by the MCP server.
- When operating on live GTM containers, the server requires explicit confirmation for deletions and publishing actions.
- For local Docker setups, you can enable internal container communication by setting ALLOWED_HOSTS (e.g., ALLOWED_HOSTS=gtm-mcp:8080).
- If you encounter connectivity issues with Google, ensure the GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are correct and that the OAuth consent screen is configured for your domains.
- The repository emphasizes server-side GTM containers support (Clients and Transformations). Ensure you have appropriate permissions for server-side containers in your GTM account.
- The MCP server exposes a URL (BASE_URL) that downstream AI platforms will contact; keep this URL stable in production and consider a domain name with TLS.
Related MCP Servers
Remote
A type-safe solution to remote MCP communication, enabling effortless integration for centralized management of Model Context.
openapi
OpenAPI definitions, converters and LLM function calling schema composer.
workflowy
Powerful CLI and MCP server for WorkFlowy: reports, search/replace, backup support, and AI integration (Claude, LLMs)
unity
A Unity MCP server that allows MCP clients like Claude Desktop or Cursor to perform Unity Editor actions.
metabase-ai-assistant
🚀 The most powerful MCP Server for Metabase - 111+ tools for AI SQL generation, dashboard automation & enterprise BI. Works with Claude, Cursor, ChatGPT.
the-academy
A Socratic dialogue engine for AI agents.