gtm-mcp-server
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-server list tags in my website container"
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
A Model Context Protocol (MCP) server for Google Tag Manager using service account authentication - no OAuth dance required.
Features
No OAuth required - Uses Google Service Account for authentication
Covers the core GTM workflow - Accounts, Containers, Workspaces, Tags, Triggers, Variables, Built-In Variables, and Versions (29 tools)
Local & private - Runs entirely on your machine
Works with Claude Desktop, Cursor, and other MCP clients
Related MCP server: unboundai-gtm-mcp-server
Quick Start
1. Create a Google Cloud Service Account
Go to Google Cloud Console
Select or create a project
Enable the Tag Manager API:
Go to APIs & Services → Library
Search for "Tag Manager API"
Click Enable
Create a service account:
Go to IAM & Admin → Service Accounts
Click "Create Service Account"
Give it a name (e.g., "gtm-mcp-server")
Click Create and Continue (skip optional permissions)
Click Done
Create a key:
Click on your new service account
Go to Keys tab
Add Key → Create new key → JSON
Save the downloaded JSON file somewhere safe (e.g.,
~/.config/gtm-service-account.json)
2. Grant GTM Access to the Service Account
Go to Google Tag Manager
Click Admin (gear icon)
Under Account, click "User Management"
Click the + button to add a user
Enter the service account email (looks like
name@project-id.iam.gserviceaccount.com)Set appropriate permissions:
Read - for listing/viewing only
Edit - for creating/modifying tags, triggers, variables
Publish - for publishing versions
Admin - for full access including user management
3. Configure Your MCP Client
Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on Mac, %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"gtm": {
"command": "npx",
"args": ["-y", "gtm-mcp-server"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account.json"
}
}
}
}Cursor
Add to your Cursor MCP settings:
{
"mcpServers": {
"gtm": {
"command": "npx",
"args": ["-y", "gtm-mcp-server"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account.json"
}
}
}
}4. Restart Your Client
After saving the config, restart your MCP client. You should see the GTM tools available.
Available Tools
Account Management
gtm_list_accounts- List all accessible GTM accounts
Container Management
gtm_list_containers- List containers in an accountgtm_get_container- Get container details
Workspace Management
gtm_list_workspaces- List workspaces in a containergtm_create_workspace- Create a new workspacegtm_get_workspace_status- Show pending changes and merge conflicts in a workspacegtm_sync_workspace- Sync a workspace to the latest container version
Tag Management
gtm_list_tags- List all tags in a workspacegtm_get_tag- Get full tag details with parametersgtm_create_tag- Create a new taggtm_update_tag- Update an existing taggtm_delete_tag- Delete a tag
Trigger Management
gtm_list_triggers- List all triggers in a workspacegtm_get_trigger- Get full trigger detailsgtm_create_trigger- Create a new triggergtm_update_trigger- Update an existing triggergtm_delete_trigger- Delete a trigger
Variable Management
gtm_list_variables- List all variables in a workspacegtm_get_variable- Get full variable detailsgtm_create_variable- Create a new variablegtm_update_variable- Update an existing variablegtm_delete_variable- Delete a variable
Built-In Variable Management
gtm_list_built_in_variables- List enabled built-in variablesgtm_enable_built_in_variables- Enable built-in variables (e.g. Page URL, Click Classes)gtm_disable_built_in_variables- Disable built-in variables
Version Management
gtm_list_versions- List container versionsgtm_get_live_version- Get the currently live (published) versiongtm_create_version- Create a version from a workspacegtm_publish_version- Publish a version to make it live
All list tools return results one page at a time; when more results exist, the response includes a page_token to pass to the next call.
Usage Examples
Once configured, you can ask Claude things like:
"List my GTM accounts"
"Show me all containers in account 123456"
"What tags are in my website container?"
"Create a new pageview trigger called 'All Pages'"
"Create a custom HTML tag that fires on all pages"
"Create a version and publish it"
Troubleshooting
"GOOGLE_APPLICATION_CREDENTIALS not set"
Make sure the environment variable is set in your MCP client config and points to a valid JSON key file.
"Permission denied" errors
Verify the service account email has been added to your GTM account
Check that the permission level is sufficient for the operation
"API not enabled" errors
Make sure the Tag Manager API is enabled in your Google Cloud project.
Server not appearing in Claude Desktop
Check that the paths in your config are correct
Look at Claude Desktop's MCP logs for errors
Try running
npx gtm-mcp-serverdirectly to see any error messages
Development
# Clone the repository
git clone https://github.com/alexstansfield/gtm-mcp-server.git
cd gtm-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Watch mode for development
npm run dev
# Test with MCP Inspector
npx @modelcontextprotocol/inspector node dist/index.jsLicense
MIT
Available Tools
29 toolsgtm_create_tagCreate GTM TagB
Create a new tag in a workspace.
Example parameters for GA4 event parameters (eventSettingsTable): {"key": "eventSettingsTable", "type": "list", "list": [{"type": "map", "map": [{"key": "parameter", "type": "template", "value": "method"}, {"key": "parameterValue", "type": "template", "value": "{{dlv - method}}"}]}]}
Inputs: name (required), type (required), account_id (required), container_id (required), +4 more.
gtm_create_triggerCreate GTM TriggerB
Create a new trigger in a workspace.
Common trigger types:
PAGEVIEW: Fires on page view
CLICK: Fires on click events
LINK_CLICK: Fires on link clicks
FORM_SUBMISSION: Fires on form submit
CUSTOM_EVENT: Fires on custom dataLayer events
DOM_READY: Fires when DOM is ready
WINDOW_LOADED: Fires when window loads
ELEMENT_VISIBILITY: Fires when element becomes visible
Inputs: name (required), type (required), account_id (required), container_id (required), +3 more.
gtm_create_variableCreate GTM VariableB
Create a new variable in a workspace.
Common variable types:
c: Constant
v: Data Layer Variable
k: First Party Cookie
jsm: Custom JavaScript
j: JavaScript Variable
u: URL
r: HTTP Referrer
aev: Auto-Event Variable
Inputs: name (required), type (required), account_id (required), container_id (required), +2 more.
gtm_create_versionCreate GTM VersionA
Create a new container version from a workspace's changes. The workspace must contain changes and be free of merge conflicts.
Inputs: name (required), account_id (required), container_id (required), workspace_id (required), +1 more.
gtm_create_workspaceCreate GTM WorkspaceA
Create a new workspace in a container.
Inputs: name (required), account_id (required), container_id (required), description.
gtm_delete_tagDelete GTM TagBDestructiveIdempotent
Delete a tag from a workspace.
Inputs: tag_id (required), account_id (required), container_id (required), workspace_id (required).
gtm_delete_triggerDelete GTM TriggerADestructiveIdempotent
Delete a trigger from a workspace.
Inputs: account_id (required), trigger_id (required), container_id (required), workspace_id (required).
gtm_delete_variableDelete GTM VariableADestructiveIdempotent
Delete a variable from a workspace.
Inputs: account_id (required), variable_id (required), container_id (required), workspace_id (required).
gtm_disable_built_in_variablesDisable Built-In VariablesADestructiveIdempotent
Disable one or more built-in variables in a workspace. Tags or triggers still referencing them will break.
Inputs: types (required), account_id (required), container_id (required), workspace_id (required).
gtm_enable_built_in_variablesEnable Built-In VariablesAIdempotent
Enable one or more built-in variables in a workspace so tags and triggers can reference them (e.g. {{Page URL}}, {{Click Classes}}).
Inputs: types (required), account_id (required), container_id (required), workspace_id (required).
gtm_get_containerGet GTM ContainerARead-onlyIdempotent
Get details of a specific container, including name, public ID, domains, and usage context.
Inputs: account_id (required), container_id (required).
gtm_get_live_versionGet Live GTM VersionARead-onlyIdempotent
Get the container version that is currently live (published) for a container.
Inputs: account_id (required), container_id (required).
gtm_get_tagGet GTM TagARead-onlyIdempotent
Get full details of a specific tag, including all its parameters, triggers, and configuration.
Inputs: tag_id (required), account_id (required), container_id (required), workspace_id (required).
gtm_get_triggerGet GTM TriggerARead-onlyIdempotent
Get full details of a specific trigger, including its type, filters, and conditions.
Inputs: account_id (required), trigger_id (required), container_id (required), workspace_id (required).
gtm_get_variableGet GTM VariableARead-onlyIdempotent
Get full details of a specific variable, including its type and parameters.
Inputs: account_id (required), variable_id (required), container_id (required), workspace_id (required).
gtm_get_workspace_statusGet GTM Workspace StatusARead-onlyIdempotent
Show all pending changes in a workspace (entities added, updated, or deleted since the last container version) and any merge conflicts.
Inputs: account_id (required), container_id (required), workspace_id (required).
gtm_list_accountsList GTM AccountsARead-onlyIdempotent
List all Google Tag Manager accounts accessible by the service account, with their IDs, names, and paths.
Inputs: page_token.
gtm_list_built_in_variablesList Enabled Built-In VariablesARead-onlyIdempotent
List the built-in variables currently enabled in a workspace (e.g. Page URL, Click Classes). Tags and triggers can only reference built-in variables that are enabled.
Inputs: account_id (required), container_id (required), workspace_id (required), page_token.
gtm_list_containersList GTM ContainersARead-onlyIdempotent
List all containers in a GTM account, with their IDs, names, public IDs, and domains.
Inputs: account_id (required), page_token.
gtm_list_tagsList GTM TagsARead-onlyIdempotent
List all tags in a workspace, with their IDs, names, types, and trigger associations.
Inputs: account_id (required), container_id (required), workspace_id (required), page_token.
gtm_list_triggersList GTM TriggersARead-onlyIdempotent
List all triggers in a workspace, with their IDs, names, types, and filter conditions.
Inputs: account_id (required), container_id (required), workspace_id (required), page_token.
gtm_list_variablesList GTM VariablesARead-onlyIdempotent
List all variables in a workspace, with their IDs, names, and types.
Inputs: account_id (required), container_id (required), workspace_id (required), page_token.
gtm_list_versionsList GTM VersionsARead-onlyIdempotent
List all container versions, with their IDs, names, and entity counts.
Inputs: account_id (required), container_id (required), page_token.
gtm_list_workspacesList GTM WorkspacesARead-onlyIdempotent
List all workspaces in a container, with their IDs, names, and descriptions.
Inputs: account_id (required), container_id (required), page_token.
gtm_publish_versionPublish GTM VersionADestructiveIdempotent
Publish a container version, making it the LIVE version served to all visitors. This replaces the currently live container configuration.
Inputs: account_id (required), version_id (required), container_id (required).
gtm_sync_workspaceSync GTM WorkspaceAIdempotent
Sync a workspace to the latest container version, pulling in changes published since the workspace was created. Reports any merge conflicts.
Inputs: account_id (required), container_id (required), workspace_id (required).
gtm_update_tagUpdate GTM TagADestructiveIdempotent
Update an existing tag in a workspace. Only the provided fields are changed; provided array fields (parameters, trigger IDs) replace the existing arrays wholesale.
Inputs: tag_id (required), account_id (required), container_id (required), workspace_id (required), +5 more.
gtm_update_triggerUpdate GTM TriggerADestructiveIdempotent
Update an existing trigger in a workspace. Only the provided fields are changed; provided filter arrays replace the existing ones wholesale.
Inputs: account_id (required), trigger_id (required), container_id (required), workspace_id (required), +3 more.
gtm_update_variableUpdate GTM VariableADestructiveIdempotent
Update an existing variable in a workspace. Only the provided fields are changed; a provided parameters array replaces the existing parameters wholesale.
Inputs: account_id (required), variable_id (required), container_id (required), workspace_id (required), +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 29 tools
The tools are grouped by entity type (tags, triggers, variables, workspaces, versions) with clear CRUD operations per entity. Some potential confusion between list/get for versions vs live version and the sync workspace tool, but descriptions clarify the distinct purposes.
All tools follow the consistent pattern of 'gtm_' prefix followed by a verb (list, get, create, update, delete, sync, publish, enable, disable) and then the entity name (workspace, tag, trigger, variable, version, etc.). This is highly consistent and predictable.
With 29 tools, the count is slightly high but appropriate for the comprehensive Google Tag Manager API surface. The tools cover multiple entity types (workspaces, tags, triggers, variables, versions, built-in variables) with full CRUD for each, justifying the count. It edges toward the heavy end but remains well-scoped.
The tool set provides full lifecycle management for workspaces, tags, triggers, variables, and versions, including listing, retrieving, creating, updating, deleting, syncing, creating versions, publishing, and managing built-in variables. It also includes account and container listing for navigation. There are no obvious gaps for typical GTM operations.
Related MCP Connectors
Hosted Google Tag Manager MCP server, with each action switched on or off per account.
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Hosted Google Search Console MCP server, with each action switched on or off per account.
Hosted Google Analytics 4 MCP server, with each action switched on or off per account.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP Server that provides a conversational interface to Google Tag Manager API, allowing users to manage tags, triggers, variables, and containers through natural language.-
- AlicenseAqualityDmaintenanceMCP server for Google Tag Manager API, enabling users to manage containers, tags, and triggers through natural language using Google Application Default Credentials.1894 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceMCP server for Google Tag Manager API v2, enabling programmatic management of accounts, containers, workspaces, tags, triggers, variables, and version workflows.46 npm15MIT
- FlicenseNot gradedqualityBmaintenanceA remote MCP server for Google Tag Manager that enables AI assistants to manage GTM accounts, containers, tags, triggers, variables, and more via OAuth or service account authentication.1-