Skip to main content

MCP server for Google Analytics integration

Project description

Google Analytics MCP Server

A Model Context Protocol (MCP) server for Google Analytics integration. This server provides tools for interacting with Google Analytics, including running reports, querying accounts and properties, and accessing metadata.

Features

  • Run Reports: Get analytics data with specified metrics and dimensions
  • Account Management: List accounts and properties
  • Metadata Access: Get information about available metrics and dimensions
  • Resources: Access Google Analytics accounts, properties, and metadata
  • Prompts: Templates for common Google Analytics workflows

Installation

pip install mcp-google-analytics

Configuration

Set the following environment variables:

export GOOGLE_ANALYTICS_CLIENT_ID="your_client_id"
export GOOGLE_ANALYTICS_CLIENT_SECRET="your_client_secret"
export GOOGLE_ANALYTICS_REFRESH_TOKEN="your_refresh_token"
export GOOGLE_ANALYTICS_PROPERTY_ID="your_property_id"

OAuth Setup

To get the required OAuth credentials:

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Google Analytics Data API and Google Analytics Admin API
  4. Create OAuth 2.0 credentials
  5. Use the OAuth 2.0 Playground to get a refresh token:
    • Go to https://developers.google.com/oauthplayground/
    • Configure the OAuth 2.0 Playground to use your client ID and secret
    • Select the required Google Analytics scopes
    • Click "Authorize APIs"
    • Exchange the authorization code for tokens
    • Save the refresh token

Usage

Starting the server directly

mcp-google-analytics

Using with Claude Desktop

Add the following to your claude_desktop_config.json file:

"mcp-google-analytics": {
  "command": "uvx",
  "args": [
    "mcp-google-analytics"
  ],
  "env": {
    "GOOGLE_ANALYTICS_CLIENT_ID": "your_client_id",
    "GOOGLE_ANALYTICS_CLIENT_SECRET": "your_client_secret",
    "GOOGLE_ANALYTICS_REFRESH_TOKEN": "your_refresh_token",
    "GOOGLE_ANALYTICS_PROPERTY_ID": "your_property_id"
  }
}

Replace the environment variables with your actual Google Analytics credentials.

Available Tools

  • run_report: Run a basic report with specified metrics and dimensions
  • get_accounts: List all Google Analytics accounts
  • get_properties: List all properties within an account
  • get_metadata: Get metadata about available metrics and dimensions

Available Resources

  • google_analytics://accounts: List of all accounts
  • google_analytics://properties/{account_id}: List properties for a specific account
  • google_analytics://metadata: Metadata about available metrics and dimensions

Available Prompts

  • create_basic_report: Template for creating a basic report
  • analyze_traffic_sources: Template for analyzing traffic sources
  • track_conversions: Template for tracking conversions

Version

0.0.1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_google_analytics-0.0.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_google_analytics-0.0.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file mcp_google_analytics-0.0.3.tar.gz.

File metadata

File hashes

Hashes for mcp_google_analytics-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8e9ded88c579ca17c4811cbfb68273f41350470c18a86e1bd63be2374d7edefa
MD5 036640e766bc3b66779eb555e4e2d0cb
BLAKE2b-256 ead57027d657b01c638fe7997534502e99b67e9462f3be13b93335058afc89de

See more details on using hashes here.

File details

Details for the file mcp_google_analytics-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_google_analytics-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44a2b0bfd4f352154004791d029e29c61fcd2e1a204686f1282f0d513c263344
MD5 ca60971684eb65cfae2fed7531eff5f3
BLAKE2b-256 c43f60fb7a089aa281c82820096d24f9b0963020a7a9c0709b13bd6782582205

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page