Google Tag Manager MCP Server
Enables natural language management of Google Tag Manager resources including accounts, containers, tags, triggers, and variables via the Model Context Protocol.
README
Google Tag Manager MCP Server
Local Model Context Protocol (MCP) server for Google Tag Manager, allowing Claude to interact with your GTM accounts, containers, tags, triggers, and variables.
š Quick Start
1. Clone and Install
git clone <repository-url>
cd gtm-mcp-server
npm install
2. Setup Google Cloud Project and API
- š Go to Google Cloud Console
- š Create a new project (important: create a new project specifically for this)
- š§ Enable Google Tag Manager API:
- Inside your project, go to "APIs & Services" > "Library"
- Search for "Tag Manager API"
- Click on it and press "Enable"
3. Create OAuth 2.0 Credentials
- š On the Tag Manager API page, click "Create Credentials" button
- ā In "What data will you be accessing?" select "User data"
- š± In "OAuth Client ID" section:
- Application type: select "Desktop app"
- Give it any name you want
- š„ Download the JSON file and save it as
credentials.jsonin the project root
4. Configure Test Users
- š¤ Go to "APIs & Services" > "Credentials" (left sidebar)
- š Find your newly created "OAuth 2.0 Client ID" and click on it
- š„ Go to "Audience" tab, scroll down to "Test Users" section
- ā Add your email address as a test user
5. Run Authorization
# Build the project first
npm run build
# Run authorization
npm run auth
This will:
- Open a browser window for Google authorization
- Redirect you to sign in with the email you added as a test user
- After successful authorization, show a success page at
http://localhost:3000/callback - Create a
gtm-config.jsonfile with access tokens in your project
6. Configure Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"google-tag-manager": {
"command": "node",
"args": ["/FULL/PATH/TO/YOUR/gtm-mcp-server/dist/index.js"],
"env": {
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
}
}
}
ā ļø Important: Replace /FULL/PATH/TO/YOUR/gtm-mcp-server/ with the actual absolute path to your project folder.
For example:
- macOS:
"/Users/wiefix/WORK/gtm-mcp-server/dist/index.js" - Windows:
"C:\\Users\\YourName\\Documents\\gtm-mcp-server\\dist\\index.js"
PATH explanation: The PATH environment variable specifies directories where system executables (like node) are located. On macOS/Linux, these standard paths ensure the MCP server can find Node.js.
7. Restart Claude Desktop
After saving the configuration file, restart Claude Desktop to connect the MCP server.
š ļø Available Tools
š gtm_account
GTM account management
get- get account detailslist- list all accountsupdate- update account settings
š¦ gtm_container
GTM container management
get- get container detailslist- list containers in accountcreate- create new containerupdate- update containerdelete- delete container
š gtm_workspace
GTM workspace management
get- get workspace detailslist- list workspaces in containercreate- create new workspaceupdate- update workspacedelete- delete workspace
š gtm_folder
Folder management for organizing elements
get- get folder detailslist- list folders in workspacecreate- create new folderupdate- update folderdelete- delete folder
š·ļø gtm_tag
GTM tag management
get- get tag detailslist- list tags in workspacecreate- create new tagupdate- update tagdelete- delete tag
ā” gtm_trigger
GTM trigger management
get- get trigger detailslist- list triggers in workspacecreate- create new triggerupdate- update triggerdelete- delete trigger
š¢ gtm_variable
GTM variable management
get- get variable detailslist- list variables in workspacecreate- create new variableupdate- update variabledelete- delete variable
š§ gtm_builtin_variable
GTM built-in variable management
list- list built-in variablescreate- enable built-in variable (pageUrl, pageTitle, etc.)delete- disable built-in variable
š¬ Usage Examples
After setup, you can ask Claude:
Basic navigation:
- "Show all my GTM accounts"
- "List containers in account 123456"
- "Show workspaces in container 456789"
Organization:
- "Create folder 'Analytics Tags' for organizing tags"
- "List all folders in workspace"
Working with tags:
- "Create Google Analytics tag with Measurement ID GA_MEASUREMENT_ID"
- "Show all tags in workspace 7"
- "Update tag with ID 15 with new settings"
- "Delete unused tag"
Triggers:
- "Create trigger for all page views"
- "Create click trigger for button with class 'download-btn'"
- "List all triggers"
Variables:
- "Enable built-in variable Page URL"
- "Create custom variable for GA Measurement ID"
- "Show all variables in workspace"
š§ Troubleshooting
Authorization Errors
- Make sure
credentials.jsonis in the project root - Verify that Google Tag Manager API is enabled in your Google Cloud project
- Check that your email is added as a test user in OAuth consent screen
- Try running
npm run authagain
API Errors
- Ensure your Google account has access to GTM accounts
- Check access permissions in GTM interface
- Verify that the API is enabled and credentials are correct
Connection Errors
- Restart Claude Desktop after making configuration changes
- Verify correct absolute paths in
claude_desktop_config.json - Check that the
dist/index.jsfile exists (runnpm run buildif missing)
š File Structure
gtm-mcp-server/
āāā credentials.json # Your Google OAuth credentials (downloaded from Google Cloud)
āāā gtm-config.json # Access tokens (auto-created after successful authorization)
āāā src/ # TypeScript source code
āāā dist/ # Compiled JavaScript (created by npm run build)
āāā package.json # Project dependencies and scripts
āāā README.md # This instruction file
ā ļø Security
- Files
credentials.jsonandgtm-config.jsoncontain sensitive authentication data - These files are automatically added to
.gitignoreto prevent accidental commits - Never publish these files in public repositories or share them
- Keep your Google Cloud project credentials secure
š Development
# Development mode with auto-reload
npm run dev
# Build project for production
npm run build
# Code linting and formatting
npm run lint
# Re-run authorization if needed
npm run auth
š Support
If you encounter problems:
- Double-check all setup steps - make sure you followed the exact sequence
- Verify Node.js version - ensure you're using Node.js v20.19.5 or higher
- Check Google Cloud setup:
- Project created and Tag Manager API enabled
- OAuth credentials created as Desktop app
- Your email added as test user
- Verify file paths in Claude Desktop config are absolute and correct
- Check logs in Claude Desktop terminal for error messages
- Rebuild the project with
npm run buildif needed
šÆ Quick Verification
To verify everything works:
- Complete all setup steps above
- Restart Claude Desktop
- Open a new chat in Claude
- Ask: "List my GTM accounts"
- You should see your Google Tag Manager accounts listed
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.