Stape/Documentation

How to set up the Model Context Protocol (MCP) server for GA4

Updated Dec 17, 2025

The following guide demonstrates configuring an MCP server for GA4. You can alternatively configure the MCP server for Stape or for GTM.

Requirements for setting up MCP for GA4

To set up the GA4 MCP server, you will need:

An AI app or agent (in our case, it is the Claude app).

Set up Google Analytics 4 MCP Server step-by-step

1. Open Claude Desktop and go to SettingsDeveloperEdit Config.

Edit Config in Claude
Edit Config in Claude

2. Open the configuration file that controls what MCP servers Claude can access and add the following configuration:

{ "mcpServers": { "ga4-mcp-server": { "command": "npx", "args": [ "-y", "mcp-remote@0.1.30", "https://mcp-ga.stape.ai/mcp" ] } } }

Save the changes (Command + S).

claude_desktop_config file
claude_desktop_config file

3. Restart Claude Desktop.

4. After restarting, a browser window will open.

Choose the Google account that has access to the Google Analytics property you want to modify using the MCP server by Stape. Complete the authentication process to grant Claude access to your MCP server.

Grant the access to Google Account
Grant the access to Google Account

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

Successful authorization
Successful authorization

In SettingsDeveloper, you will see the status Running next to ga4-mcp-server. If you face any problems with configuration, refer to the troubleshooting section below in this guide.

GA4 MCP server running status
GA4 MCP server running status

Troubleshooting GA4 MCP server configuration

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 (e.g., 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 (e.g., ga4-mcp-server).

The MCP cache

mcp-remote stores credential data in ~/.mcp-auth (or the location defined by the $MCP_REMOTE_CONFIG_DIR$ environment variable). If you run into persistent issues, you should try clearing this cached state and tokens.

Use this command to clear the cache:

rm -rf ~/.mcp-auth

Afterward, restart your MCP client.

Comments

Can’t find what you are looking for?