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.2.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.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for mcp_google_analytics-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5db2f77347a2504b05f0b88dfd514ccb1da3d637ac4c818c7c104ae802d0cd4e
MD5 5556022ce4c41de417ac31060a499e26
BLAKE2b-256 e2818d6041b0ed8696b86eebb5806d1ed76e02962fb16d5a012196e3ef8e13a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_google_analytics-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b88a48ebf7a929c2ea1efc4218f5c71f0735f59f95b45c84b6c8c769c4ca33b5
MD5 a996833c578930d9ccab244d5bfc2892
BLAKE2b-256 7ab6959ed3d10d4a6a89684161605047c8c775b95ad4988ead83988a75e1fa76

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