MCP server for Google Tag Manager
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
GTM MCP Server
A Model Context Protocol (MCP) server that enables Claude to interact with Google Tag Manager.
Table of Contents
- Features
- Quick Start
- Complete Setup Guide
- Available Tools
- How Authentication Works
- Upgrade
- 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
Installation
pip install gtm-mcp
gtm-mcp-setup
The setup wizard will guide you through:
- Creating Google Cloud OAuth credentials (5 minutes)
- Configuring Claude Desktop automatically
See PyPi
Prefer manual setup? See the Complete Setup Guide below.
📋 Complete Setup Guide
Part 1: Install the Package
pip install gtm-mcp
Part 2: Create Google Cloud OAuth Credentials
Step 1: Create a Google Cloud Project
- Go to Google Cloud Console
- Click on the project dropdown (top left)
- Click "New Project"
- Enter a project name (e.g., "My GTM MCP Server")
- Click "Create"
- Wait for the project to be created and select it
Step 2: Enable Tag Manager API
- In your project, go to "APIs & Services" → "Library"
- Search for "Tag Manager API"
- Click on it and click "Enable"
- Wait for it to enable (may take a minute)
Step 3: Configure OAuth Consent Screen
- Go to "APIs & Services" → "OAuth consent screen"
- Select "External" (unless you have a Google Workspace)
- Click "Create"
- Fill in required fields:
- App name: My GTM MCP (or whatever you like)
- User support email: Your email
- Developer contact email: Your email
- Click "Save and Continue"
- Click "Update" then "Save and Continue"
- Add your email as a test user
- Click "Save and Continue"
Step 4: Create OAuth Credentials
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- Select "Desktop app" as the application type
- Enter a name: "GTM MCP Desktop Client"
- Click "Create"
- IMPORTANT: A dialog appears with your credentials - DO NOT CLOSE IT YET
Step 5: Save Your Credentials
From the dialog that appeared:
- Copy the Client ID (looks like:
123456789-abc123.apps.googleusercontent.com) - Copy the Client secret (looks like:
GOCSPX-...) - Note your Project ID from the Google Cloud Console (top bar, next to project name)
- Save these somewhere safe - you'll need them in the next step
You can also download the JSON file, but you only need the three values above.
Part 3: Configure Claude Desktop
⬆ top 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 - Claude Code
~/.claude.json
Add your credentials:
{
"mcpServers": {
"gtm-mcp": {
"command": "gtm-mcp",
"env": {
"GTM_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
"GTM_CLIENT_SECRET": "GOCSPX-your-client-secret",
"GTM_PROJECT_ID": "your-project-id"
}
}
}
}
Replace the values with your actual credentials from Part 2, Step 5.
Note: If you have other MCP servers configured, just add the
"gtm-mcp"entry to the existing"mcpServers"object.
Part 4: Restart and Authorize
-
Restart Claude Desktop completely (close and reopen)
-
Ask Claude to use a GTM tool (e.g., "List my GTM accounts")
-
First-time authorization - a browser window will open automatically:
- Sign in with your Google account
- You'll see "Google hasn't verified this app" warning
- Click "Advanced" → "Go to [Your App Name] (unsafe)"
- This is safe because you created the app yourself
- Grant the requested permissions
- You'll see "The authentication flow has completed"
- Return to Claude Desktop
-
Your authorization is saved locally - you won't need to do this again!
🛠️ Available Tools
⬆ top
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_create_variable |
Create a new variable (constant, data layer, cookie, URL, etc.) |
gtm_publish_container |
Create and publish a new container version |
🔐 How Authentication Works
⬆ top
This MCP server uses OAuth 2.0 to securely access Google Tag Manager:
- You create OAuth credentials in your own Google Cloud project
- You configure those credentials in Claude Desktop
- First use: Browser opens to authorize access to your GTM account
- Your tokens are saved locally on your machine (
~/.gtm-mcp-token.json) for future use
Why Do I Need My Own OAuth Credentials?
For security and privacy:
- ✅ You maintain full control over the OAuth app
- ✅ No shared credentials between users
- ✅ You can revoke access anytime
- ✅ Your credentials stay private
- ✅ Compliant with Google's OAuth policies
Upgrade
Run pip install --upgrade gtm-mcp
❓ Troubleshooting
"Missing required OAuth credentials" Error
Problem: The MCP server can't find your credentials.
Solution: Make sure you:
- Set the environment variables correctly in
claude_desktop_config.json(or~/.claude.json) - Restarted Claude Desktop after editing the config
- Used the correct format (no extra quotes in JSON)
- The config file is valid JSON (use a JSON validator if unsure)
"Google hasn't verified this app" Warning
Problem: Google shows a security warning during first authorization.
Solution: This is completely normal for personal OAuth apps. Since you created the OAuth app yourself, Google shows this warning.
To proceed: Click "Advanced" → "Go to [App Name] (unsafe)"
This is safe because you control the app.
Can't Access GTM Accounts
Possible causes:
- Your Google account doesn't have access to any GTM accounts
- You didn't grant all requested permissions during authorization
- Tag Manager API isn't enabled in your Google Cloud project
Solution:
- Verify your Google account has GTM access
- Re-authorize by deleting
~/.gtm-mcp-token.jsonand trying again - Check that Tag Manager API is enabled in Google Cloud Console
Connection Issues
Debugging steps:
- Verify Claude Desktop is completely restarted
- Check Claude Desktop logs for MCP server errors
- Verify
gtm-mcpcommand works: rungtm-mcpin terminal - Check your config file is valid JSON
- Ensure all three environment variables are set correctly
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
Revoking Access
To revoke access to your GTM account:
- Go to Google Account Permissions
- Find your app name in the list
- Click "Remove access"
- Delete the local token file:
rm ~/.gtm-mcp-token.json
You can re-authorize anytime by using any GTM tool in Claude again.
🔒 Security Notes
- Your OAuth credentials are yours alone - keep them private
- Never share your Client Secret - treat it like a password
- Your access tokens are stored locally:
~/.gtm-mcp-token.json - You can regenerate credentials anytime in Google Cloud Console
- You can revoke access anytime from your Google account settings
- This server only accesses GTM - no other Google services
💻 Development
Running Tests
pip install -e ".[dev]"
pytest
📝 License
⬆ top see LICENSE file for details
🤝 Contributing
⬆ top 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
⬆ top 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gtm_mcp-0.1.2.tar.gz.
File metadata
- Download URL: gtm_mcp-0.1.2.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7196fe4e1c07c59dbd5f0faa4b7f9c62ae0fd09f140e4fe46203ce0468b08c5
|
|
| MD5 |
a7feb15b2a5191e9e456a3f226a27c32
|
|
| BLAKE2b-256 |
ee0991a8e102703e81506749740e1d7adc5076d1e979104cacf1cd2bb19d001b
|
Provenance
The following attestation bundles were made for gtm_mcp-0.1.2.tar.gz:
Publisher:
python-publish.yml on paolobtl/gtm-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtm_mcp-0.1.2.tar.gz -
Subject digest:
b7196fe4e1c07c59dbd5f0faa4b7f9c62ae0fd09f140e4fe46203ce0468b08c5 - Sigstore transparency entry: 717998329
- Sigstore integration time:
-
Permalink:
paolobtl/gtm-mcp@920d22816f876641bb805f9a14b1a8c854f9a38c -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/paolobtl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@920d22816f876641bb805f9a14b1a8c854f9a38c -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtm_mcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: gtm_mcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fb0c003bd577ccaa53575d5e9248627f54a06bc0160b885d9d6b7b227cab005
|
|
| MD5 |
fbf72dafcd50d365c3e45332f93c1434
|
|
| BLAKE2b-256 |
8669487436c4ae456572dd78e7d0b0e4ccf9e9bb05d13ba58079aa51fca3c7ba
|
Provenance
The following attestation bundles were made for gtm_mcp-0.1.2-py3-none-any.whl:
Publisher:
python-publish.yml on paolobtl/gtm-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtm_mcp-0.1.2-py3-none-any.whl -
Subject digest:
5fb0c003bd577ccaa53575d5e9248627f54a06bc0160b885d9d6b7b227cab005 - Sigstore transparency entry: 717998354
- Sigstore integration time:
-
Permalink:
paolobtl/gtm-mcp@920d22816f876641bb805f9a14b1a8c854f9a38c -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/paolobtl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@920d22816f876641bb805f9a14b1a8c854f9a38c -
Trigger Event:
push
-
Statement type: