Skip to main content
Glama
msaeedsakib

ga4-mcp

by msaeedsakib

ga4-mcp

A Google Analytics 4 MCP server with a one-command setup. It is a TypeScript rewrite of Google's google-analytics-mcp. You don't need gcloud, Python, OAuth clients or env vars: give it a service account key and pick your agents.

npx @saeedsakib/ga4-mcp setup

Setup does four things:

  1. Asks for the path to your service account JSON key and stores a copy in ~/.config/ga4-mcp/ (owner-only permissions).

  2. Checks access live. If an API isn't enabled or the service account can't see any property, it tells you exactly what to fix and waits while you do.

  3. Adds the MCP server to Claude Code, Cursor and/or Codex, and installs the bundled ga4-mcp skill so the agent knows how to query GA4 well.

  4. Prints a config snippet for any other MCP client or custom harness.

Restart your agent and ask something like "How did organic traffic change over the last 28 days?"

Before you start: get a service account key

  1. In Google Cloud Console, pick or create a project and enable the Google Analytics Admin API and the Google Analytics Data API.

  2. Go to IAM & Admin → Service Accounts → Create service account. It needs no Cloud roles.

  3. Open the service account, go to Keys → Add key → Create new key → JSON, and download it.

  4. In Google Analytics, go to Admin → Property access management → + → Add users. Paste the service account email (…@….iam.gserviceaccount.com), choose Viewer and save. Repeat for each property you want the agent to see.

Setup checks each of these steps and tells you which one is missing.

Related MCP server: GA4 MCP Server

Commands

Command

What it does

npx @saeedsakib/ga4-mcp setup

Store a key, verify access, configure agents

npx @saeedsakib/ga4-mcp status

Show the stored key and configured agents, then re-check access

npx @saeedsakib/ga4-mcp remove

Remove the server and skill from agents, and optionally delete the key

npx @saeedsakib/ga4-mcp

Start the stdio MCP server (this is what agents run)

Custom harnesses

Any MCP client that can spawn a stdio server works. Run setup once to store the key, then point your client at:

{
  "mcpServers": {
    "ga4": { "command": "npx", "args": ["-y", "@saeedsakib/ga4-mcp"] }
  }
}

Give your agent skills/ga4-mcp/SKILL.md as instructions if it supports skills or system prompts.

Tools

All tools are read-only and match upstream's tool names and arguments.

Tool

Description

get_account_summaries

Accounts and properties the service account can see

get_property_details

Property settings (time zone, currency, …)

list_google_ads_links

Google Ads accounts linked to a property

list_property_annotations

Notes left on dates (releases, campaigns)

get_custom_dimensions_and_metrics

A property's custom definitions

run_report

Core Data API report

run_realtime_report

Last 30 minutes of activity

run_funnel_report

Funnel steps with drop-off, breakdowns and next actions

run_conversions_report

Ad cost, ROAS and attributed conversions

Where things are written

Path

Key

$XDG_CONFIG_HOME/ga4-mcp/service-account.json (default ~/.config/…, or %APPDATA%\ga4-mcp\ on Windows)

Claude Code

~/.claude.json → mcpServers.ga4, skill in ~/.claude/skills/ga4-mcp/ (respects CLAUDE_CONFIG_DIR)

Cursor

~/.cursor/mcp.json → mcpServers.ga4, skill in ~/.cursor/skills/ga4-mcp/

Codex

~/.codex/config.toml → [mcp_servers.ga4], skill in ~/.agents/skills/ga4-mcp/ (respects CODEX_HOME)

Setup only changes its own ga4 entry and leaves the rest of each config file as it was.

Development

bun install
bun test
bun run typecheck
bun run build

The published package runs on Node 20.11 or later.

License

Apache-2.0. See NOTICE for attribution to the original Google project.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables LLM applications to query Google Analytics 4 data through standard MCP interfaces, supporting real-time data, custom reports, and metadata discovery.
    5
    63 npm
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Connects MCP clients like Claude Desktop to Google Analytics 4 Data API, enabling natural language queries for reports, top pages, traffic sources, conversions, realtime users, and period comparisons.
    7
    31 PyPI
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables querying Google Analytics 4 data using natural language through MCP clients like Claude and Cursor, supporting 200+ dimensions and metrics for traffic, user behavior, and e-commerce analysis.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables querying Google Analytics 4 properties using natural language through MCP clients. Supports customizable reports with any dimensions and metrics, listing properties, and real-time data.
    4
    MIT