/Documentation

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

Updated Jul 27, 2026

i

Note:

You can alternatively configure the MCP server for StapeGTM, 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 Google Analytics 4

1. Open Claude Desktop and go 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.

Edit Config in Claude

2. Replace the file content with the following configuration:

{ "mcpServers": { "ga4-mcp-server": { "command": "npx", "args": [ "-y", "mcp-remote", "https://mcp-google-analytics.stape.io/mcp" ] } } }

3. Save the changes by pressing Cmd + S.

claude_desktop_config file

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

MCP CLI Proxy

4. A browser window will open showing your OAuth login page. 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

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

Successful authorization

6. Now you can type your request via chat.

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.

GA4 MCP server running status

Testing

To check that everything works as intended, simply enter a request in your AI app and see if it’s completed correctly within the GA4 environment.

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 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.

Was this article helpful?

Comments

Can’t find what you are looking for?