How to set up the Model Context Protocol (MCP) server for GA4
Updated Sep 21, 2026
Note:
You can alternatively configure the MCP server for Stape, GTM, 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 example, we’ll use the Claude app. See installation instructions for other services.
How to set up the MCP server for Google Analytics 4
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.

2. Set the name to ga4-mcp-server and the URL to https://mcp-google-analytics.stape.io/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 GA4 account, like “List all my GA4 entities” or “What's the total conversions across all sites this month?”
How to configure the MCP server using mcp-remote
1. Open Claude Desktop and go to File → 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": {
"ga4-mcp-server": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://mcp-google-analytics.stape.io/mcp"
]
}
}
}3. Save the changes by pressing Cmd + S.

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

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.

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

6. Now you can type your request via chat.
In Settings → Developer, you will see the status Running next to ga4-mcp-server. If you face 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 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?
🍽 Table of content:
Comments