Stape
Search
Contact salesTry for free

How to configure the MCP Server for Google Analytics 4

Uliana Lesiv

Uliana Lesiv

Author
Published
Dec 17, 2025
i

Key takeaways:

  • The GA4 MCP server lets your AI app send requests directly to GA4 - returning reports, running commands, or querying dimensions and metrics.
  • You only need Node.js (v18+) and an MCP-compatible AI client to configure it.
  • Setup is done by adding the GA4 MCP server entry in the client's config file. 
  • You can also connect GTM and/or Stape MCP servers along with the GA4 MCP server; we show how to do it.
  • After restarting the AI app, you authenticate with your Google account to grant access.
  • A Running status confirms successful setup.

How the GA4 MCP server works

After you set up the MCP Server (MCP Server for Google Analytics 4), you can enter any request directly into your AI app (such as the Claude app). That request is then passed to the MCP Server through the MCP Protocol, the standard communication protocol for AI tools. Once the server receives the requests, it processes them, executing actions, running commands, or returning the requested data.

Once the server receives the requests, it processes them, executing actions, running commands, or returning the requested data. Available tools include querying dimensions and metrics, allowing users to analyze user behavior and traffic sources.

How MCP Server works
How MCP Server works

Use cases of Google Analytics MCP Server

The requests can cover nearly all GA4 reporting and administrative operations, including (but not limited to):

  • Run GA4 reports. Retrieve historical and segmented data (dimensions, metrics, filtering, ordering), including analysis of conversion rates, average session duration, and traffic source performance.
  • Get real-time reports. View current, up-to-date user activity on your site or app and analyze events in real time to identify trends or issues quickly.
  • Generate GA4 account summary. Receive a complete list and overview of all properties you have access to.
  • List Google Ads accounts connected to GA4. Returns a list of the Google Ads accounts linked to a specified GA4 property.
  • Fetch property annotations. Retrieves the annotations (notes for specific dates/periods) created on a specified GA4 property.

Pre-requires

To configure the GA4 MCP server, you will need an AI app or agent (in our case, it is the Claude app).

How to configure Google Analytics 4 MCP Server?

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
!

Please note: if you are already using or would like to install MCP servers for other platforms, such as Google Tag Manager and/or Stape, you will need to update the configuration code by adding other MCP's code.

Here is the example if you need to add GTM MCPStape MCP, and GA4 MCP servers:

3. Restart Claude Desktop.

4. Once restarted, a browser window will be open. Select the Google account that has access to the Google Analytics property you want to modify with the MCP server. Complete the authentication flow to grant Claude access to your MCP server.

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

Once 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. In case of problems with the setup, 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 (such as Cursor AI) have 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), some tools can be hidden or filtered out.

To prevent this: use shorter MCP server names in your configuration (e.g., ga4-mcp-server).

The MCP cache

mcp-remote stores credential data in ~/.mcp-auth (or in the directory defined by your MCP_REMOTE_CONFIG_DIR). If you encounter persistent issues, try clearing the cached state and tokens.

To clear the cache, run the following command:

rm -rf ~/.mcp-auth

Afterward, restart your MCP client.

Want to start on the server side?Register now!

author

Uliana Lesiv

Author

Uliana is a Content Manager at Stape, specializing in analytics and integration setups. She breaks down complex tracking concepts into clear insights, helping businesses optimize data collection.

Comments

Try Stape for all things server-side