npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@toolsdk.ai/google-analytics-mcp

v1.0.5

Published

MCP server for Google Analytics Data API

Readme

Google Analytics MCP Server

A Model Context Protocol (MCP) server that provides seamless access to Google Analytics 4 data through standard MCP interfaces. This tool allows LLM applications to easily query and analyze Google Analytics data without directly dealing with the complexities of the Google Analytics Data API.

Features

  • Real-time Data Access: Get real-time analytics data for current active users and activity
  • Custom Reports: Create comprehensive reports with custom dimensions and metrics
  • Quick Insights: Predefined analytics insights for common use cases
  • Metadata Discovery: Get available dimensions and metrics for your Google Analytics property
  • Smart Error Handling: Detailed error messages with actionable solutions for permission issues
  • Standard MCP Interface: Works with any MCP-compatible client

Installation

npm install @toolsdk.ai/google-analytics-mcp

Prerequisites

  • Node.js >= 18.0.0
  • Google Analytics 4 property
  • Google Cloud service account with appropriate permissions

Setup

1. Google Cloud Service Account Setup

  1. Create a Google Cloud service account with the "Viewer" role for your Google Analytics property
  2. Download the service account key as JSON
  3. Add the service account to your Google Analytics property with Viewer access:
    • Go to Google Analytics (analytics.google.com)
    • Navigate to Admin > Property Access Management
    • Add your service account email with Viewer access

2. Environment Configuration

Create a .env file in your project root with the following content:

GOOGLE_CREDENTIALS='{"type":"service_account","project_id":"your-project-id","private_key_id":"your-private-key-id","private_key":"-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n","client_email":"[email protected]","client_id":"your-client-id","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/your-service-account%40your-project.iam.gserviceaccount.com"}'

Note: Make sure to properly format the private key with \n for newlines.

Usage

Use ToolSDK.ai

import { ToolSDKApiClient } from 'toolsdk/api';
const toolSDK = new ToolSDKApiClient();
// Get Tools
const GoogleAnalyticsMCP = await toolSDK.package('@toolsdk.ai/google-analytics-mcp', {
  GOOGLE_CREDENTIALS: process.env.GOOGLE_CREDENTIALS,
});

Use Claude

{
  "mcpServers": {
    "google-analytics-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@toolsdk.ai/google-analytics-mcp"
      ],
      "env": {
        "GOOGLE_CREDENTIALS": "Your Google Credentials JSON String"
      }
    }
  }
}

Available Tools

analytics_report

Get comprehensive Google Analytics data with custom dimensions and metrics. Can create any type of report.

Parameters:

  • propertyId (string, required): Google Analytics property ID
  • startDate (string, required): Start date (YYYY-MM-DD)
  • endDate (string, required): End date (YYYY-MM-DD)
  • dimensions (array, optional): Dimensions to query
  • metrics (array, required): Metrics to query
  • dimensionFilter (object, optional): Filter by dimension values
  • metricFilter (object, optional): Filter by metric values
  • orderBy (object, optional): Sort results by dimension or metric
  • limit (number, optional): Limit number of results (default: 100)

realtime_data

Get real-time analytics data for current active users and activity.

Parameters:

  • propertyId (string, required): Google Analytics property ID
  • dimensions (array, optional): Dimensions for real-time data
  • metrics (array, optional): Real-time metrics (default: ['activeUsers'])
  • limit (number, optional): Limit number of results (default: 50)

quick_insights

Get predefined analytics insights for common use cases.

Parameters:

  • propertyId (string, required): Google Analytics property ID
  • startDate (string, required): Start date (YYYY-MM-DD)
  • endDate (string, required): End date (YYYY-MM-DD)
  • reportType (string, required): Type of quick insight report (overview, top_pages, traffic_sources, etc.)
  • limit (number, optional): Limit number of results (default: 20)

get_metadata

Get available dimensions and metrics for Google Analytics property.

Parameters:

  • propertyId (string, required): Google Analytics property ID
  • type (string, optional): Type of metadata to retrieve (dimensions, metrics, both)

search_metadata

Search for specific dimensions or metrics by name or category.

Parameters:

  • propertyId (string, required): Google Analytics property ID
  • query (string, required): Search term to find dimensions/metrics
  • type (string, optional): Type of metadata to search (dimensions, metrics, both)
  • category (string, optional): Filter by category

Error Handling

The server provides detailed error messages with actionable solutions:

  • Permission Errors: Clear instructions on how to grant access to your service account
  • Configuration Errors: Guidance on setting up environment variables correctly
  • API Errors: Detailed information about what went wrong with the Google Analytics API

License

MIT