gtm-mcp-server
Provides tools for managing Google Tag Manager workspaces, including creating, updating, deleting, and listing tags, triggers, and variables at the draft level.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gtm-mcp-serverCreate a GA4 event tag named 'page_view' in container GTM-ABC123 and fire it on all pages."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gtm-mcp-server
An MCP (Model Context Protocol) server for creating and managing tags, triggers, and variables in Google Tag Manager directly from Claude, Codex, or any MCP client.
The server only operates at the workspace (draft) level — it never auto-publishes a container to production. You still need to review and publish the version yourself in the GTM UI (or via a future extension of this tool).
Features
gtm_list_accounts,gtm_list_containers,gtm_list_workspacesgtm_list_tags,gtm_create_tag,gtm_update_tag,gtm_delete_taggtm_list_triggers,gtm_create_triggergtm_list_variables,gtm_create_variable
Every tool accepts account / container / workspace as either a name or an ID
(e.g. container: "GTM-ABC123" or container: "My Website").
Related MCP server: GTM MCP Server
1. Create an OAuth client on Google Cloud
Go to Google Cloud Console and create (or select) a project.
Go to APIs & Services → Library and enable the Tag Manager API.
Go to APIs & Services → Credentials → Create Credentials → OAuth client ID.
Application type: Desktop app.
Download the resulting JSON file and rename it to
credentials.json.Place it at
~/.gtm-mcp/credentials.json(default location), or set theGTM_MCP_CREDENTIALS_PATHenvironment variable to point somewhere else.
The Google account you sign in with needs access to the relevant GTM account/container (add it under GTM → Admin → User Management if needed).
2. Install
git clone https://github.com/YOUR_USERNAME/gtm-mcp-server.git
cd gtm-mcp-server
npm install
npm run build3. Sign in to Google (one-time)
npm run authThis prints a URL — open it in your browser, sign in, and grant access. The token is
saved to ~/.gtm-mcp/token.json and refreshes automatically afterwards (no need to
sign in again).
4. Connect to Claude Code / Claude Desktop
With Claude Code:
claude mcp add gtm -- node "/path/to/gtm-mcp-server/dist/index.js"With Claude Desktop, add this to claude_desktop_config.json:
{
"mcpServers": {
"gtm": {
"command": "node",
"args": ["/path/to/gtm-mcp-server/dist/index.js"]
}
}
}Once connected, you can ask directly, for example:
"Create a GA4 event tag named 'purchase_tracking' in container GTM-ABC123, default workspace, fired by the 'Purchase Event' trigger."
Environment variables
Variable | Default | Meaning |
|
| Directory holding credentials/token |
|
| Path to the OAuth client secret file |
|
| Path to the cached token |
Security notes
Never commit
credentials.jsonortoken.jsonto git (already covered by.gitignore).The token is stored in plaintext on your local machine — only run this server on a machine you trust.
All changes are made at the workspace draft level; publishing still requires a manual step in the GTM UI.
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Let AI manage your Google Tag Manager containers — tags, triggers, variables, and more.
Manage SRG+ hubs, channels, content, assets, users, and workspaces from any MCP-aware AI agent.
Create, update, and revoke Apple Wallet and Google Wallet passes from any MCP client.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables comprehensive management of Google Tag Manager accounts, containers, workspaces, tags, triggers, and variables through OAuth2 authentication, allowing users to create, update, and publish GTM configurations via natural language.2621 npmMIT
- AlicenseNot gradedqualityBmaintenanceMCP server for Google Tag Manager API v2, enabling programmatic management of accounts, containers, workspaces, tags, triggers, variables, and version workflows.21 npm14MIT
- AlicenseNot gradedqualityCmaintenanceEnables full Google Tag Manager management via the GTM API v2, including tags, triggers, variables, and version publishing, with workspace-based change tracking.MIT
- AlicenseAqualityAmaintenanceMCP server for the Google Tag Manager API v2, enabling natural-language management of containers, workspaces, tags, triggers, variables, and publishing. It handles OAuth authentication and built-in rate limiting for the strict GTM API quota.19120 npm1MIT