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

@osva-ai/connector-ga4

v0.1.1

Published

OSVA Connector Profile V1 Google Analytics 4 MCP connector (read-only property discovery, metadata, and reporting)

Readme

@osva-ai/connector-ga4

OSVA Connector Profile V1 read-only MCP connector for Google Analytics 4 (GA4).

This package is developed in the osva-connectors monorepo. Recommended npm version 0.1.1 (SDK 1.1.4); see docs/INSTALL-GA4.md.

Capabilities

Seven MCP tools:

| Tool | Purpose | | ------------------------ | ---------------------------------------------------------------------------------- | | ga4.property.list | Discover GA4 properties accessible to the credential (Admin API account summaries) | | ga4.property.get | Property metadata (timezone, currency, display name) | | ga4.metadata.get | Reporting dimensions and metrics (getMetadata) with local search/pagination | | ga4.report.run | Bounded custom core report (runReport) | | ga4.report.realtime | Realtime report (runRealtimeReport, defaults to activeUsers) | | ga4.report.acquisition | Session acquisition report (channel + source/medium) | | ga4.report.ecommerce | Ecommerce overview or product breakdown (separate query shapes) |

Google APIs

| API | Host | Usage | | -------------------------- | ------------------------------- | ---------------------------------------- | | Analytics Admin API v1beta | analyticsadmin.googleapis.com | Property discovery and property metadata | | Analytics Data API v1beta | analyticsdata.googleapis.com | Metadata, core reports, realtime reports |

Universal Analytics Reporting API is not used.

Authentication

Supported credential paths (via google-auth-library):

  1. Application Default Credentials (ADC) — user credentials or metadata service on GCP.
  2. Service account — set GOOGLE_APPLICATION_CREDENTIALS to the service account JSON key path.
  3. User-authorized ADC — when your environment already holds user-refreshed ADC credentials.

Required OAuth scope:

https://www.googleapis.com/auth/analytics.readonly

GA4 property access (important)

Creating a Google Cloud service account and enabling APIs does not grant Analytics property access. A Google Analytics administrator must grant the service account (or user) an appropriate role (for example Viewer) on each GA4 property in Admin → Property access management.

Environment variables

| Variable | Required | Description | | -------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------- | | GOOGLE_APPLICATION_CREDENTIALS | For service accounts | Path to service account JSON (standard Google env var) | | OSVA_CONNECTOR_GA4_PROPERTY_ID | No | Default numeric GA4 property ID for tools that accept optional propertyId | | OSVA_CONNECTOR_GA4_TIMEOUT_MS | No | Total operation deadline in ms for auth, HTTP, body read, and retry backoff (default 30000, min 1000, max 120000) |

Credentials are never accepted through MCP tool inputs. There is no interactive browser OAuth flow in G1.

Enable both Google Analytics Data API and Google Analytics Admin API in your Google Cloud project.

MCP client configuration (stdio)

Local monorepo development:

{
  "mcpServers": {
    "osva-ga4": {
      "command": "node",
      "args": ["packages/ga4/dist/stdio.js"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
        "OSVA_CONNECTOR_GA4_PROPERTY_ID": "123456789"
      }
    }
  }
}

After npm publication:

{
  "command": "npx",
  "args": ["-y", "@osva-ai/[email protected]"],
  "env": {
    "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
  }
}

Property IDs

GA4 property IDs are numeric (for example 123456789). Tools accept either the bare ID or properties/123456789. Admin and Data API resource names use the properties/{id} form internally.

Date ranges

Custom and preset reports accept GA4 date strings:

  • YYYY-MM-DD
  • today, yesterday
  • NdaysAgo (for example 7daysAgo)

Relative expressions follow Google’s documented syntax.

Pagination and output limits

| Concern | Behavior | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Core reports | Google offset + limit (max 1000 rows per tool call); includes rowCount, rowsReturned, and hasMoreRows when derivable. If Google omits rowCount, the connector sets rowCountIsLowerBound: true (page row count only, not the query total) | | Property list | Admin API pageToken pagination | | Metadata | Single provider fetch; local search, limit, and offset (not Google server-side metadata pagination) | | MCP JSON output | Max 256 KiB serialized structured output per tool response | | HTTP body read | Max 2 MiB raw response before parsing |

The connector does not recursively fetch additional report pages within one tool call.

Quotas and retries

Google enforces separate quotas for Core, Realtime, and Admin operations. The connector:

  • Maps HTTP 429 and RESOURCE_EXHAUSTED to RATE_LIMITED
  • Retries at most once for safe transient failures (429/5xx) within the configured deadline
  • Honors Retry-After when present and within the deadline
  • Does not retry authentication, permission, or validation failures

When Google includes propertyQuota, fields use nested consumed / remaining QuotaStatus objects (Analytics Data API shape). Flat numeric quota fields are not synthesized. Quota is not guaranteed on every call; the connector does not set returnPropertyQuota on requests.

Security and privacy

  • Provider dimensions, metrics, and cell values are treated as untrusted data (prompt-injection safe handling is the MCP host’s responsibility; this connector does not execute provider strings).
  • No user-level export, no configuration mutations, no arbitrary Google API method execution.
  • Errors and logs are sanitized (no access tokens, refresh tokens, or private keys).
  • Ecommerce and acquisition reports avoid user-level identifiers by design; business-sensitive aggregates may still appear.

Known limitations

  • Read-only; no Admin write operations.
  • No interactive OAuth onboarding in the connector binary.
  • Realtime reports support only realtime-compatible dimensions/metrics.
  • Ecommerce overview and product breakdown use fixed metric/dimension sets; incompatible combinations surface as provider errors.
  • totalRevenue on acquisition preset is omitted when incompatible with the fixed dimension set (preset uses keyEvents instead of revenue on session-scoped dimensions).