1. Conduid
  2. Developer Tools
  3. io.github.mharnett/ga4
MCP server · Developer Tools

io.github.mharnett/ga4

Google Analytics 4 MCP: reports, realtime data, custom dimensions, data streams.

Unclaimed devtools
37Low

Scored 6 months ago · breakdown

About io.github.mharnett/ga4

io.github.mharnett/ga4 is an MCP server published by mharnett in the Developer Tools category: google Analytics 4 MCP: reports, realtime data, custom dimensions, data streams.

Recent commit activity is the strongest signal that reported issues will get attention.

Install

Claude Code
claude mcp add io-github-mharnett-ga4 -- npx -y mcp-ga4
npx
npx -y mcp-ga4

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Tools (9)

ga4_create_custom_dimensionCreate a new custom dimension

Parameters not published.

ga4_get_client_contextReturns the active GA4 property ID and client name

Parameters not published.

ga4_list_custom_dimensionsList all custom dimensions for the property

Parameters not published.

ga4_list_custom_metricsList all custom metrics for the property

Parameters not published.

ga4_list_data_streamsList web/app data streams and their measurement IDs

Parameters not published.

ga4_realtime_reportQuery realtime data (last 30 minutes)

Parameters not published.

ga4_run_reportRun a standard GA4 report with dimensions, metrics, date range, and filters

Parameters not published.

ga4_send_feedbackSubmit feedback on a query result

Parameters not published.

ga4_suggest_improvementSuggest a new query pattern or improvement

Parameters not published.

Ask AI

✦

Ask AI about io.github.mharnett/ga4

Powered by Claude · Grounded in docs

I know everything about io.github.mharnett/ga4. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

  • ✓README presentThe repository ships documentation.

5 checks have not been run yet.

README

mcp-ga4

MCP server for Google Analytics 4 -- run reports, realtime data, custom dimensions, and property management via Claude.

Features

  • 9 tools covering reporting, realtime data, custom dimensions/metrics, data streams, and feedback
  • Two configuration modes: single-property (env vars) and multi-client (config.json)
  • Supports both service account and OAuth credentials
  • Relative date support (today, yesterday, 7daysAgo, 30daysAgo, 90daysAgo)
  • Built on official Google SDKs with resilience patterns

Installation

npm install mcp-ga4

Or clone the repository:

git clone https://github.com/mharnett/mcp-ga4.git
cd mcp-ga4
npm install
npm run build

Configuration

Security: Never share your .mcp.json file or commit it to git -- it may contain API credentials. Add .mcp.json to your .gitignore.

Mode 1: Single Property (env vars)

Set environment variables to connect to a single GA4 property:

GA4_PROPERTY_ID=123456789
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

Mode 2: Multi-Client (config.json)

Create a config.json in the project root to map multiple GA4 properties to project directories. The server auto-detects which property to use based on the caller's working directory.

{
  "credentials_file": "/path/to/oauth-credentials.json",
  "clients": {
    "client-a": {
      "name": "Client A",
      "folder": "/path/to/client-a/project",
      "property_id": "123456789"
    },
    "client-b": {
      "name": "Client B",
      "folder": "/path/to/client-b/project",
      "property_id": "987654321"
    }
  }
}

Usage

Claude Code (.mcp.json)

Single-property mode:

{
  "mcpServers": {
    "ga4": {
      "command": "npx",
      "args": ["mcp-ga4"],
      "env": {
        "GA4_PROPERTY_ID": "123456789",
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/credentials.json"
      }
    }
  }
}

Multi-client mode:

{
  "mcpServers": {
    "ga4": {
      "command": "node",
      "args": ["/path/to/mcp-ga4/dist/index.js"]
    }
  }
}

Claude Desktop: Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows).

Common Query Patterns

Top pages: dimensions=pagePath, metrics=screenPageViews, order_by=screenPageViews

Traffic sources: dimensions=sessionSource,sessionMedium, metrics=sessions,totalUsers

Daily trend: dimensions=date, metrics=sessions,totalUsers

Campaign performance: dimensions=sessionCampaignName, metrics=sessions,conversions

Device breakdown: dimensions=deviceCategory, metrics=sessions,totalUsers

Tools

Tool Description
ga4_get_client_context Returns the active GA4 property ID and client name
ga4_run_report Run a standard GA4 report with dimensions, metrics, date range, and filters
ga4_realtime_report Query realtime data (last 30 minutes)
ga4_list_custom_dimensions List all custom dimensions for the property
ga4_create_custom_dimension Create a new custom dimension
ga4_list_custom_metrics List all custom metrics for the property
ga4_list_data_streams List web/app data streams and their measurement IDs
ga4_send_feedback Submit feedback on a query result
ga4_suggest_improvement Suggest a new query pattern or improvement

Date Formats

Use YYYY-MM-DD for absolute dates, or these relative shortcuts:

  • today
  • yesterday
  • 7daysAgo
  • 30daysAgo
  • 90daysAgo

Common Dimensions and Metrics

Dimensions: date, dateHour, eventName, pagePath, pageTitle, sessionSource, sessionMedium, sessionCampaignName, country, city, deviceCategory, browser, operatingSystem, landingPage, pageReferrer, newVsReturning, firstUserSource, firstUserMedium, firstUserCampaignName

Metrics: sessions, totalUsers, newUsers, activeUsers, screenPageViews, eventCount, conversions, engagedSessions, engagementRate, averageSessionDuration, bounceRate, sessionsPerUser, screenPageViewsPerSession, userEngagementDuration

Data Freshness

  • Standard reports: 24-48 hour delay
  • Realtime reports: last 30 minutes only

Architecture

Built on:

  • @google-analytics/data -- GA4 Data API for reports
  • @google-analytics/admin -- GA4 Admin API for property management
  • cockatiel -- resilience (retry, circuit breaker)
  • pino -- structured logging

License

MIT

Author

Built by Mark Harnett / drak-marketing

README copy captured when this server was indexed; it may lag the repository. The original is authoritative.

Questions

About io.github.mharnett/ga4

How do I install io.github.mharnett/ga4?

Run claude mcp add io-github-mharnett-ga4 -- npx -y mcp-ga4, then add the server to your MCP client's configuration.

Is io.github.mharnett/ga4 safe to use with an AI agent?

Its trust score is 37 out of 100 (low). It passes 1 of the 1 static security checks run so far. It has no ConduID identity yet, so agent calls to it are not receipted.

Is io.github.mharnett/ga4 still maintained?

Yes — the last commit was 23 days ago. The repository has 0 stars and 1 forks.