Provides tools for querying analytics reports, managing properties, data streams, conversion events, custom dimensions and metrics, and accessing account hierarchies in Google Analytics.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Google Analytics MCP Serverget last week's sessions and pageviews for my website"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Google Analytics MCP Server
GA-MCP (Google Analytics Management Control Panel) is a lightweight Node.js package that provides developers with a structured interface to interact with Google Analytics APIs. It simplifies common GA tasks like querying analytics reports, managing properties, audiences, and more—making it ideal for data analysts, developers, and marketing teams looking to automate reporting and analytics workflows. MCP standard.
Features
Fetch and analyze GA performance data (sessions, users, pageviews, conversions)
Manage properties, data streams, and conversion events
Query custom dimensions and metrics
Access account hierarchies and property configurations
Export data for dashboards or further analysis
OAuth2 authentication with access and refresh tokens
Lightweight, secure, and highly configurable
MCP Tools
get_reports: Get analytics reports data for specified metrics and dimensionslist_accounts: List all Google Analytics accountslist_properties: List properties for a Google Analytics accountlist_data_streams: List data streams for a propertylist_custom_dimensions: List custom dimensions for a propertylist_custom_metrics: List custom metrics for a propertylist_conversion_events: List conversion events for a property
Getting Started
Prerequisites
Node.js v18 or later
Google OAuth2 credentials (Client ID and Client Secret)
Valid Google Analytics access and refresh tokens
Authentication Setup
Create OAuth2 Credentials:
Go to the Google Cloud Console
Create or select a project
Enable the Google Analytics API
Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"
Configure the consent screen and choose the appropriate application type:
Option A: Web Application (Recommended)
Select "Web application"
Add
http://localhost:3000/auth/callbackto "Authorized redirect URIs"
Option B: Desktop Application
Select "Desktop application"
No redirect URI configuration needed (uses out-of-band flow)
Generate Access and Refresh Tokens:
Use the included helper script:
npm run oauth-helperOr use Google OAuth2 Playground with your client credentials
Or implement your own OAuth2 flow
Quick Setup Workflow
Installation
Clone this repository and install dependencies:
Build
Configuration Environment Variables
Option 1: Using .env file (Recommended)
Set up your environment file:
Option 2: Using export commands
Set the following environment variables:
Start
Start the MCP server:
Integrate with Cursor
To use this MCP server with Cursor, add a .cursor/mcp.json file to your project root:
Integrate with VSCode
To use this MCP server with VSCode, add a .vscode/mcp.json file to your project root:
This configuration enables VSCode to recognize and manage the Google Analytics MCP server automatically.
This configuration enables Cursor to recognize and manage the Google Analytics MCP server automatically.
Token Refresh
The MCP server automatically handles token refresh using the provided refresh token. If the access token expires, it will be automatically refreshed during API calls.
Troubleshooting
"The redirect URI... can only be used by a Client ID for native application"
This error occurs when you have a Web application OAuth client but are using the out-of-band redirect URI. Solutions:
Solution 1: Use Web Application (Recommended)
In Google Cloud Console, edit your OAuth client
Add
http://localhost:3000/auth/callbackto "Authorized redirect URIs"Keep
GOOGLE_REDIRECT_URI=http://localhost:3000/auth/callbackin your.envfile
Solution 2: Switch to Desktop Application
Create a new OAuth client and select "Desktop application"
Set
GOOGLE_REDIRECT_URI=urn:ietf:wg:oauth:2.0:oobin your.envfile
About AST Consulting
AST Consulting is a premier digital consulting firm specializing in FinOps, cloud optimization, AI/ML solutions, digital transformation, and performance marketing. With over 100 years of combined leadership experience and a portfolio impacting 50M+ businesses and 500M+ users, AST delivers measurable outcomes by blending strategic vision with deep technical expertise.
We developed ga-mcp as part of our commitment to empower marketers, analysts, and digital teams with tools that drive efficiency, transparency, and actionable insights. Whether optimizing cloud spend or automating analytics intelligence pipelines, AST builds solutions that scale.
👉 Visit us at www.astconsulting.in