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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。