Google Analytics 4 · mindstone — Claude Code MCP server: setup
This MCP server lets an AI agent inspect GA4 properties and schemas, then run reports. Use it to explore analytics data from your coding environment.
claude mcp add --env GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> --env GA4_PROPERTY_ID=<GA4_PROPERTY_ID> --transport stdio google-analytics -- npx -y @mindstone/mcp-server-google-analyticsWhat Google Analytics 4 does
The server can list GA4 accounts and properties, inspect available dimensions and metrics, check whether they work together, and run reports. Large exports can run as asynchronous tasks, with results retrieved in pages. Standard reports include safeguards for high row volumes.
You need Node.js 20+, npm, and Google credentials with the analytics.readonly scope, or a service-account JSON file that has access to the GA4 property. Set GOOGLE_APPLICATION_CREDENTIALS to an absolute file path; Node.js will not expand ~ or %APPDATA%. That path requirement matters: an unresolved shortcut prevents the server from reading the credentials. GA4_PROPERTY_ID can provide a default property.
What it helps with
- list available GA4 accounts and properties
- inspect a property's dimensions and metrics
- check dimension and metric compatibility before reporting
- run a report against GA4 data
- retrieve a large report through an asynchronous export
Example prompts for the agent
- List the GA4 accounts and properties I can access.
- Check whether these dimensions and metrics can be used together in a report.
- Run a report for this GA4 property and retrieve the large export in pages.
How to install Google Analytics 4
Platform CLI
claude mcp add --env GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> --env GA4_PROPERTY_ID=<GA4_PROPERTY_ID> --transport stdio google-analytics -- npx -y @mindstone/mcp-server-google-analyticsReplace <…> with your own values
Platform CLI
codex mcp add google-analytics --env GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> --env GA4_PROPERTY_ID=<GA4_PROPERTY_ID> -- npx -y @mindstone/mcp-server-google-analyticsReplace <…> with your own values
Config file
{
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": [
"-y",
"@mindstone/mcp-server-google-analytics"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "<GOOGLE_APPLICATION_CREDENTIALS>",
"GA4_PROPERTY_ID": "<GA4_PROPERTY_ID>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"google-analytics": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@mindstone/mcp-server-google-analytics"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "<GOOGLE_APPLICATION_CREDENTIALS>",
"GA4_PROPERTY_ID": "<GA4_PROPERTY_ID>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> -e GA4_PROPERTY_ID=<GA4_PROPERTY_ID> google-analytics npx -y @mindstone/mcp-server-google-analyticsReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Google Analytics 4
How do I install Google Analytics 4 in Claude Code?
Run `claude mcp add mcp-server-google-analytics -e GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> -- npx -y @mindstone/mcp-server-google-analytics`. Set the credential variable to an absolute path.
What does the Google Analytics 4 MCP server do?
It lets an agent inspect GA4 accounts, properties, schemas, and reporting data. Large exports can be handled as background tasks and read in pages.
What credentials does the server require?
Use Google ADC with the analytics.readonly scope, or a service-account JSON file that can access the GA4 property. Set its absolute path in GOOGLE_APPLICATION_CREDENTIALS.
Similar MCP servers
All MCP servers for Data and databases →Google Analytics 4 by other authors comes first.