gtm-mcp
Enables full Google Tag Manager management via the GTM API v2, including tags, triggers, variables, and version publishing, with workspace-based change tracking.
README
gtm-mcp
MCP server for full Google Tag Manager management via the GTM API v2: tags, triggers, variables and versions.
Tools (22)
Hierarchy: Account → Container → Workspace → (Tags / Triggers / Variables)
| Tool | What it does |
|---|---|
get_accounts |
List accessible GTM accounts — entry point |
get_containers |
Containers in an account |
get_workspaces |
Workspaces in a container (usually "Default Workspace") |
get_workspace_status |
Pending changes vs. the published version |
get_tags / get_tag |
List or detail tags |
create_tag / update_tag / delete_tag / revert_tag |
Tag CRUD |
get_triggers / get_trigger |
List or detail triggers |
create_trigger / update_trigger / delete_trigger |
Trigger CRUD |
get_variables |
List variables |
create_variable / update_variable / delete_variable |
Variable CRUD |
get_versions |
History of published versions |
create_version |
Snapshot the current workspace (restore point) |
publish_version |
Publish a version to production |
Typical flow
1. get_accounts() → account_id
2. get_containers(account_id) → container_id
3. get_workspaces(account_id, container_id) → workspace_id
4. get_workspace_status(...) → review pending changes
5. [create/edit tags, triggers, variables]
6. create_version(account_id, container_id, workspace_id, name="v1")
7. publish_version(account_id, container_id, version_id)
Setup
- Create a Google Cloud project (or reuse one) and enable the Tag Manager API.
- Create an OAuth 2.0 Client ID of type "Desktop app" and download it as
client_secret.json. - If the app is in "Testing" mode, add your Google account as a test user.
- Install dependencies:
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt - Run the OAuth flow once:
This opens a browser — log in and grant access. Credentials are saved toCLIENT_SECRET_PATH=~/.config/gtm-mcp/client_secret.json python3 setup_auth.py~/.config/gtm-mcp/credentials.json.
⚠️ Only enable this MCP when you're actually working on GTM — leaving it always-on in a client that doesn't cache the OAuth session can trigger the auth flow on every startup.
MCP client configuration
{
"mcpServers": {
"gtm": {
"command": "/path/to/.venv/bin/python3",
"args": ["/path/to/gtm-mcp/server.py"]
}
}
}
| Env var | Default | Purpose |
|---|---|---|
GOOGLE_GTM_CREDENTIALS |
~/.config/gtm-mcp/credentials.json |
Path to the credentials file generated by setup_auth.py |
Notes
- All changes (create/edit/delete) stay in the workspace until published
with
create_version+publish_version. update_tag/update_trigger/update_variabledo a GET before the PUT to preserve unspecified fields — you won't lose parameters by omission.- Common
tag_typevalues:googtag(GA4/Google Tag),html(custom HTML),gclidw(Ads conversion),ua(legacy Universal Analytics). - Common
trigger_typevalues:pageview,customEvent,linkClick,formSubmission,domReady. - Common
variable_typevalues:v(Data Layer),k(Cookie),u(URL),jsm(Custom JS). parametersis a list of{type, key, value}wheretypeis one oftemplate,boolean,integer,listormap.
License
MIT — see LICENSE.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.