Google Analytics MCP Server

by ast-consulting

Not rated
GitHub

About

A structured interface for interacting with Google Analytics APIs, simplifying tasks like querying reports and managing properties.

Details

Author
ast-consulting
Categories
Cloud Service, Other, API
Tags
#google-analytics, #analytics

Setup

Install Google Analytics MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/ast-consulting/gsc-mcp

Follow the installation instructions in the repository README, then restart your MCP client.

A structured interface for interacting with Google Analytics APIs, simplifying tasks like querying reports and managing properties.

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.

- 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

- get_reports: Get analytics reports data for specified metrics and dimensions
- list_accounts: List all Google Analytics accounts
- list_properties: List properties for a Google Analytics account
- list_data_streams: List data streams for a property
- list_custom_dimensions: List custom dimensions for a property
- list_custom_metrics: List custom metrics for a property
- list_conversion_events: List conversion events for a property

- Node.js v18 or later
- Google OAuth2 credentials (Client ID and Client Secret)
- Valid Google Analytics access and refresh tokens

Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"

Configure the consent screen and choose the appropriate application type:

- Select "Web application"
- Addhttp://localhost:3000/auth/callbackto "Authorized redirect URIs"

- Select "Desktop application"
- No redirect URI configuration needed (uses out-of-band flow)

- Use the included helper script:npm run oauth-helper
- Or use
Google OAuth2 Playgroundwith your client credentials
- Or implement your own OAuth2 flow

# 1. Set up environment file npm run setup-env # 2. Edit .env with your OAuth2 Client ID and Secret (from step 1 above) # 3. Generate tokens npm run oauth-helper # 4. Copy the generated tokens to your .env file # 5. Build and start npm run build node dist/index.js

Clone this repository and install dependencies:

npm run setup-env # This creates .env from the template # Edit .env file with your actual credentials

Set the following environment variables:

export GOOGLE_CLIENT_ID=your_oauth2_client_id export GOOGLE_CLIENT_SECRET=your_oauth2_client_secret export GOOGLE_ACCESS_TOKEN=your_access_token export GOOGLE_REFRESH_TOKEN=your_refresh_token

To use this MCP server withCursor, add a.cursor/mcp.jsonfile to your project root:

{ "mcpServers": { "ga-mcp": { "command": "npx", "args": ["-y", "ga-mcp"], "env": { "GOOGLE_CLIENT_ID": "your_oauth2_client_id", "GOOGLE_CLIENT_SECRET": "your_oauth2_client_secret", "GOOGLE_ACCESS_TOKEN": "your_access_token", "GOOGLE_REFRESH_TOKEN": "your_refresh_token" } } } }

To use this MCP server with VSCode, add a.vscode/mcp.jsonfile to your project root:

{ "servers": { "ga-mcp": { "command": "npx", "args": ["-y", "ga-mcp"], "env": { "GOOGLE_CLIENT_ID": "your_oauth2_client_id", "GOOGLE_CLIENT_SECRET": "your_oauth2_client_secret", "GOOGLE_ACCESS_TOKEN": "your_access_token", "GOOGLE_REFRESH_TOKEN": "your_refresh_token" } } } }

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.

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.

"The redirect URI... can only be used by a Client ID for native application"

This error occurs when you have aWeb applicationOAuth 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
- Addhttp://localhost:3000/auth/callbackto "Authorized redirect URIs"
- KeepGOOGLE_REDIRECT_URI=http://localhost:3000/auth/callbackin your.envfile

Solution 2: Switch to Desktop Application
- Create a new OAuth client and select "Desktop application"
- SetGOOGLE_REDIRECT_URI=urn:ietf:wg:oauth:2.0:oobin your.envfile

AST Consultingis 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 developedga-mcpas 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.

Interact with the App Store Connect API to manage apps, sales, and reports.

Access eBay Analytics data via the CData JDBC Driver.

A read-only MCP server for querying live Google Ad Manager data, powered by CData.

Access Google Analytics 4 (GA4) data using the Model Context Protocol.

Access the Google Analytics Data API to retrieve and analyze website traffic data.

An MCP server for interacting with the Kayzen Analytics API, requiring credentials configured via environment variables.

Interact with Kong Konnect APIs to query and analyze Kong Gateway configurations, traffic, and analytics.

Connect AI assistants to live Meta Ads, GA4, and Search Console data. 100% local, machine-locked encryption, no cloud relay.

Interact with the Meta Ads API to access, analyze, and manage advertising campaigns.

Interact with Facebook and Instagram advertising data using the Meta Marketing API.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.