How to set up the Model Context Protocol (MCP) server for Google Tag Manager
Updated Sep 25, 2026
Note:
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 example, we’ll use the Claude app. See installation instructions for other services.
How to set up the MCP server for GTM
We’ll cover two ways to configure an MCP server:
- 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.
- 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.

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

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

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

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

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

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.

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.

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

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.

5. After you grant access, 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.

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