/Documentation

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

Updated Sep 25, 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:

How to set up the MCP server for GTM

We’ll cover two ways to configure an MCP server:

  1. Using HTTP connection - generally a better option, as long as your MCP client supports it. It prevents a lot of bugs and is way easier to install.
  2. Using mcp-remote - more complicated and error-prone, but can be the only option for some MCP clients (or if you specifically wish to use it for your setup).

How to configure the MCP server using HTTP connection

1. Open Claude Desktop and go to File → Settings → Connectors → click Add to create a custom connector.

Add a custom connector

2. Set the name to gtm-mcp-server and the URL to https://gtm-mcp.stape.ai/mcp, then click Continue.

Set name and URL

3. For Authentication, select Sign in now → for OAuth client, select Register automatically → click Add. 

Authentication and OAuth client

4. On the new screen, click Connect (or click the new connector in the Connectors list). 

Click Connect

5. A new browser page will open - click Continue connecting and go through the Google OAuth flow.

Continue connecting

6. After the access is granted, the tool will be available for your use.

MCP authorized

7. Now you can type your request via chat. To verify that it’s working, just type any query related to your GTM account, like “List all my GTM entities” or “What's the total number of events across all sites this month?”

How to configure the MCP server using mcp-remote

1. Open Claude Desktop and navigate to Settings → Developer → Edit 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?