/Documentation

How to set up the Model Context Protocol (MCP) server for Google Tag Manager

Updated Jul 27, 2026

i

Note:

You can alternatively GA4, or Google Ads.

Before you begin

For the MCP to connect and operate correctly, please make sure that:

  • Your node.js version is up to date (v18 or higher).
  • You have an AI app or agent (in our case, it is the Claude app).

How to set up the MCP server for GTM

1. Open Claude Desktop and navigate to SettingsDeveloperEdit Config → open desktop JSON file called claude_desktop_config

This opens Claude's JSON configuration file, which is where Claude stores information about the MCP servers it can connect to. Every MCP server that you want Claude to use must be defined in this configuration file.

Claude's JSON configuration file

2. Replace the file content with the following configuration.

{ "mcpServers": { "google-tag-manager-mcp-server": { "command": "npx", "args": [ "-y", "mcp-remote", "https://gtm-mcp.stape.ai/mcp" ] } } }

3. Save the changes by pressing Cmd + S.

configuration

3. Restart Claude. When Claude starts again, it will attempt to connect to the added MCP server.

OAuth login page

4. Authenticate with OAuth.

A browser window will open showing your OAuth login page. Complete the authentication flow to grant Claude access to your MCP server.

grant Claude access to your MCP server

5. After you grant access, the tools will become available for you to use.

the tools will become available for you to use

5. Now you can type your request via chat.

In Settings → Developer, you will see the status Running next to google-tag-manager-mcp-server. If you encounter any problems with configuration, refer to the troubleshooting section below.

if it works, the status must be "running"


Testing

To check that everything works as intended, simply enter a request in your AI app and see if it’s completed correctly within Google Tag Manager’s containers.

Troubleshooting

MCP Server name length limit

Some MCP clients, like Cursor AI, enforce a 60-character limit on the combined length of the MCP server name and the tool name. If your configuration uses a long server name (for example, ga4-mcp-server-your-additional-long-name), this may cause specific tools to be hidden or filtered out by the client.

Action: to ensure all tools are visible, configure your MCP server with a shorter name (for example, ga4-mcp-server).

The MCP cache

mcp-remote stores all the credential information inside ~/.mcp-auth (or wherever your MCP_REMOTE_CONFIG_DIR points to). If you're having persistent issues, try running:

rm -rf ~/.mcp-auth

It will clear any locally stored state and tokens. Then restart your MCP client.

Was this article helpful?

Comments

Can’t find what you are looking for?