home / mcp / gtm mcp server

GTM MCP Server

Provides MCP access to Google Tag Manager for listing, creating, updating, and publishing GTM resources.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "paolobtl-gtm-mcp": {
      "command": "gtm-mcp",
      "args": [],
      "env": {
        "GTM_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
        "GTM_PROJECT_ID": "your-project-id",
        "GTM_CLIENT_SECRET": "GOCSPX-your-client-secret"
      }
    }
  }
}

You deploy and use a Model Context Protocol (MCP) server that lets Claude interact with Google Tag Manager. It provides commands to list accounts and containers, manage tags, triggers, variables, and publish container versions, all through your MCP client. This guide shows you how to install, configure credentials, and start using the GTM MCP Server with your MCP client.

How to use

Once you have the GTM MCP Server configured and running, your MCP client can access GTM functionality through the following actions: list GTM accounts and containers, list and inspect tags, triggers, and variables, create and update items, and publish container versions. Use the provided tool endpoints to perform common workflows, such as creating a new tag in a workspace or publishing a container version after making changes.

How to install

# Prerequisites
python3.10+  # Ensure you have Python 3.10 or higher installed
pip install gtm-mcp

# Optional: initial setup and self-check
gtm-mcp-setup
```

Note: The setup wizard will guide you through creating Google Cloud OAuth credentials and configuring Claude Desktop automatically. If you prefer manual configuration, proceed with the Complete Setup Guide below.

Configuration and usage details

This MCP server uses OAuth 2.0 to securely access Google Tag Manager. You create OAuth credentials in your own Google Cloud project and configure them in Claude Desktop. The first authorization opens a browser window to grant the requested permissions, and your tokens are saved locally for future use.

Environment variables you configure for the MCP server are used to connect to GTM. You provide the Client ID, Client Secret, and your Google Cloud Project ID during setup and keep these credentials private.

How to install (step-by-step)

Follow these steps to set up the GTM MCP Server from scratch.

Additional steps for vendor and security notes

- Start Claude Desktop after you have configured the MCP server so it can authenticate and access GTM resources. - Your OAuth credentials are user-specific and private. Treat the Client Secret like a password. - You can revoke access anytime from your Google account settings and delete local tokens if you need to re-authorize.

Troubleshooting

If you encounter issues, restart Claude Desktop, verify your MCP server command is accessible, and ensure environment variables are set correctly. Review Claude Desktop logs for MCP server errors and verify that the OAuth flow completes on first authorization.

Upgrade

Upgrade the MCP server package with:

```bash
pip install --upgrade gtm-mcp
```
This will install the latest version and keep your configuration intact.

Security notes

Your OAuth credentials and access tokens are stored locally and should be protected. Do not share your Client Secret. You can regenerate credentials in Google Cloud Console and revoke access from your Google account settings at any time.

Development

To run tests during development, install the test dependencies and run the test suite.

Tools and capabilities

The GTM MCP Server exposes a set of tools to manage GTM resources through MCP calls, including listing accounts, containers, tags, triggers, and variables, creating and updating resources, and publishing container versions.

Available tools

gtm_list_accounts

List all GTM accounts accessible by your OAuth credentials.

gtm_list_containers

List containers within a selected GTM account.

gtm_list_tags

List tags within a specific workspace.

gtm_get_tag

Retrieve detailed configuration for a specific tag.

gtm_create_tag

Create a new tag in a workspace.

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.