Stape
Search
Try for free

How to configure the MCP Server for Google Tag Manager

Uliana Lesiv

Uliana Lesiv

Author
Published
May 2, 2025

Model Context Protocol (MCP) Server provides interoperability and coordination between AI models and tools. It is especially helpful in systems where many AI agents are working together. For the end user, it means smooth command performance and convenient data retrieval without the need to write API requests themselves.

We, at Stape, have developed the MCP Server for Google Tag Manager so you can manage and perform required actions more easily within a tool. In this article, we will explain what the MCP Server is and how it works. We have also prepared a detailed MCP Server implementation guide.

Model Context Protocol Server definition

The Model Context Protocol (MCP) is an open standard that enables AI models to interact with APIs, databases, and various external services.

The MCP Server acts as a central intermediary. It provides a standardized interface for accessing tools, systems, and data sources. The MCP Server ensures that resources and tools are accessible to any AI app compatible with the protocol.

How does the MCP Server work?

After configuring the MCP Server (in our case, for Google Tag Manager), you can type any request in your AI app (e.g., the Claude app). Your request is sent to the MCP Server via the MCP Protocol (standard protocol for AI communication). Once the request is received, the MCP Server handles it (performs actions/commands or returns some data you requested).

The request can refer to most commands connected with GTM functionality and its entities. It includes, but is not limited to:

  • Creating, getting, updating, removing accounts, workspaces, containers, and environments.
  • Creating, getting, reverting, updating, removing clients, tags, triggers, variables, folders, and templates.
  • Listing, getting, and managing the latest GTM container and header versions.
  • Managing users’ permissions.
How MCP Server works
How MCP Server works

Before starting

To configure the MCP Server for GTM, you will need:

  • Node.js (v16 or higher)
  • Google Cloud Platform account
  • Service account credentials for Google Tag Manager API

How to set up an MCP server for GTM

1. Create a new project on the Google Cloud Platform.

To do it, go to the navigation menu → IAM & Admin → Create a Project. Add the name for a project (let’s say “gtm-mcp”). In the Location field, click Browse, select the required location. Click Create. 

2. Create a service account.

Go to the Create service account page → select a GC project → add service account name → Done.

Create a service account on Google Cloud
Create a service account on Google Cloud

3. Generate a JSON key.

Next to the service account, click Keys → Add key → Create new key → select JSON → click Create.

Service account key
Service account key

4. Enable GTM API in a project.

In the needed project, navigate to APIs & Services (click "APIs & Services" on the left-hand menu) → click Library → search for Google Tag Manager API and click Enable.

Enable GTM API
Enable GTM API

5. Download the MCP Server for Google Tag Manager from GitHub and unzip the folder.

Download MCP server from GitHub
Download MCP server from GitHub

6. Open the folder you downloaded from GitHub in Terminal.

7. Run the commands: npm install && npm build to install dependencies and build the library.

npm install && npm build
npm install && npm build
Run npm install && npm build commands
Run npm install && npm build commands

8. Put the JSON service account key you’ve created in the folder “Keys”.

9. Add the config to the AI app or agent. In our case, it is the Claude app.

Open Claude desktop → Settings → Developer tab → Edit Config → open desktop JSON file called “claude_desktop_config” → paste the code below.

If you need to set up only the MCP Server for GTM, paste this code:

{ "mcpServers": { "google-tag-manager-mcp-server": { "command": "node", "args": ["/your_path_to_file/mcp-google-tag-manager/dist/index.js"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "mcp-google-tag-manager/keys/gtm-mcp.json" } } } }

If you are a Stape user and would like to install Stape MCP Server, follow the instructions from our Stape MCP Server configuration guide and paste this code:

{ "mcpServers": { "google-tag-manager-mcp-server": { "command": "node", "args": ["/your_path_to_file/mcp-google-tag-manager/dist/index.js"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "mcp-google-tag-manager/keys/gtm-mcp.json" } }, "stape-mcp-server": { "command": "node", "args": ["/your_path_to_file/stape-mcp-server/dist/index.js"], "env": { "STAPE_AUTH_KEY": "skey" } } } }

Once done, save the file → close the Claude app → reopen it.

After adding the code to the file, you should see the list of MCP Servers in the Developer tab of the Claude app.

Developer tab in Claude app
Developer tab in Claude app

That’s it. Now you can start typing your request in the Claude app.

Conclusion

Setting up an MCP Server for Google Tag Manager significantly simplifies interacting with GTM resources. For a user, there is no need for manual API requests. With our implementation, you can integrate this functionality into your workflow. Whether you're managing tags, containers, or user permissions, the MCP Server acts as a reliable bridge between your AI tools and GTM. We hope this guide helps you get started quickly!

author

Uliana Lesiv

Author

Uliana is a Content Manager at Stape, specializing in analytics and integration setups. She breaks down complex tracking concepts into clear insights, helping businesses optimize data collection.

author

Comments

Try Stape for all things server-sideright now!