gtm-mcp
Enables natural language management of Google Tag Manager accounts, containers, tags, triggers, variables, and versions, including creation, update, and publishing.
README
GTM MCP Server
A Model Context Protocol (MCP) server that enables Claude to interact with Google Tag Manager.
Table of Contents
- Features
- Quick Start
- Setup Instructions
- Available Tools
- Troubleshooting
- Security Notes
- Development
- License
- Contributing
- Getting Help
Features
- List GTM accounts and containers
- Manage tags, triggers, and variables
- Create and publish container versions
- Full workspace management
🚀 Quick Start
Prerequisites
- Python 3.10 or higher
- Claude Desktop (or any MCP-compatible client like Cursor)
- A Google account with access to Google Tag Manager
🔧 Setup Instructions
Configure Python
Install the package using pip or pipx:
pip install gtm-mcp
See PyPi
Enable Tag Manager API
- Go to Google Cloud Console
- Create a new project or select an existing one
- Go to "APIs & Services" → "Library"
- Search for "Tag Manager API"
- Click on it and click "Enable"
Configure Credentials
This server uses Application Default Credentials (ADC) for authentication. You need to set up credentials that have access to your Google Tag Manager accounts.
Step 1: Create a Service Account
- Go to Google Cloud Console
- Navigate to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "Service Account"
- Fill in the service account details:
- Service account name: gtm-mcp-service
- Description: Service account for GTM MCP Server
- Click "Create and Continue"
- Skip optional steps and click "Done"
Step 2: Create and Download Service Account Key
- Click on the service account you just created
- Go to the "Keys" tab
- Click "Add Key" → "Create New Key"
- Select "JSON" format
- Click "Create"
- The JSON file will download automatically
- Save this file securely - you'll need its path later
- Copy the service account email (looks like:
gtm-mcp-service@your-project.iam.gserviceaccount.com)
Step 3: Grant Service Account Access to GTM
- Go to Google Tag Manager
- Select your GTM account
- Click "Admin" in the top navigation
- Under "Account", click "User Management"
- Click the "+" button to add a user
- Enter the service account email from Step 2
- Select appropriate permissions:
- Read: For read-only access
- Edit: For creating/modifying tags, triggers, variables
- Approve: For publishing container versions
- Publish: For full publishing rights
- Click "Invite"
Configure Claude Desktop
Edit your Claude Desktop config file:
- Linux:
~/.config/Claude/claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add your configuration:
{
"mcpServers": {
"gtm-mcp": {
"command": "gtm-mcp",
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json",
"GOOGLE_PROJECT_ID": "your-project-id"
}
}
}
}
Important: Replace the values with your actual paths and project ID.
Example paths:
- Linux/macOS:
/home/username/gtm-service-account.json - Windows:
C:\\Users\\YourName\\gtm-service-account.json
To find your Project ID:
- Look in the Google Cloud Console top bar, next to your project name
- Or find it in your service account JSON file under the
"project_id"field
Try It Out
- Restart Claude Desktop completely (close and reopen)
- Ask Claude: "List my GTM accounts"
- Authentication will happen automatically using the service account credentials!
🛠️ Available Tools
Once configured, Claude will have access to these GTM tools:
| Tool | Description |
|---|---|
gtm_list_accounts |
List all your GTM accounts |
gtm_list_containers |
List containers in an account |
gtm_list_tags |
List tags in a workspace |
gtm_get_tag |
Get detailed configuration of a specific tag |
gtm_create_tag |
Create a new tag |
gtm_update_tag |
Update an existing tag |
gtm_list_triggers |
List triggers in a workspace |
gtm_create_trigger |
Create a new trigger |
gtm_list_variables |
List variables in a workspace |
gtm_get_variable |
Get detailed configuration of a specific variable |
gtm_create_variable |
Create a new variable (constant, data layer, cookie, URL, etc.) |
gtm_publish_container |
Create and publish a new container version |
gtm_list_versions |
List all versions of a container |
gtm_get_version |
Get detailed information about a specific version |
gtm_get_live_version |
Get the currently published (live) version |
gtm_get_latest_version |
Get the latest version (may not be published) |
gtm_delete_version |
Delete (archive) a container version |
gtm_undelete_version |
Restore a deleted version |
gtm_update_version |
Update version metadata (name, description, notes) |
gtm_set_latest_version |
Mark a version as the latest |
❓ Troubleshooting
"Missing required environment variable" Error
Problem: The MCP server can't find the required environment variables.
Solution:
- Ensure both
GOOGLE_APPLICATION_CREDENTIALSandGOOGLE_PROJECT_IDare set in your Claude Desktop config - Verify the path to your service account JSON file is correct and absolute
- On Windows, use double backslashes:
C:\\Users\\... - Restart Claude Desktop after editing the config
"Failed to load Application Default Credentials" Error
Problem: The credentials file cannot be loaded or is invalid.
Solution:
- Verify the service account JSON file exists at the specified path
- Check that the JSON file is valid and not corrupted
- Ensure the file has proper read permissions
- Try downloading a new key from Google Cloud Console
"Service account has no access" Error
Problem: The service account doesn't have permission to access your GTM account.
Solution:
- Go to GTM → Admin → User Management
- Verify the service account email is listed with appropriate permissions
- Grant at least "Read" permission (or higher based on your needs)
Can't Access GTM Accounts
Possible causes:
- Service account doesn't have GTM permissions
- Tag Manager API isn't enabled in your Google Cloud project
- Wrong service account email was added to GTM
Solution:
- Verify Tag Manager API is enabled in Google Cloud Console
- Check that the service account email is added to your GTM account
- Ensure proper permissions are granted in GTM User Management
Package Not Found After Install
Problem: gtm-mcp command not found after installation.
Solution:
# Ensure pip install location is in PATH
pip install --user gtm-mcp
# Or use pipx for isolated installation
pipx install gtm-mcp
🔒 Security Notes
- Keep your JSON key file secure - it provides full access to whatever permissions you've granted
- Never commit the JSON file to version control - add it to
.gitignore - Use restrictive file permissions -
chmod 600 service-account.jsonon Unix/Linux - Store the file in a secure location with limited access
- You can create new keys and delete old ones in Google Cloud Console
- Regularly rotate service account keys for better security
- This server only accesses GTM - no other Google services
- Credentials are only used for Google Tag Manager API authentication
- No credentials are sent to any third-party services
💻 Development
Running Tests
pip install -e ".[dev]"
pytest
📝 License
See LICENSE file for details
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
For bugs and feature requests, please open an issue.
🆘 Getting Help
If you encounter issues:
- Check the Troubleshooting section above
- Review Claude Desktop logs for error messages
- Verify your Google Cloud project has Tag Manager API enabled
- Ensure environment variables are set correctly in the config
- Open an issue on GitHub with:
- Your operating system
- Python version (
python --version) - Error messages from Claude Desktop logs
- Steps to reproduce the issue
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。