Query Analytics

Query Analytics

Builds valid Google Analytics 4 API requests from plain parameters with automatic date range resolution, metric formatting, and filter expression parsing. Eliminates manual GA4 API syntax construction and raw data formatting for analytics queries.

Category
Visit Server

README

Stop wrestling with analytics API syntax.

MCPize License: MIT

Query Analytics is an MCP server that turns plain parameters into valid GA4 API requests, resolves human-readable date ranges, formats raw metric values, parses filter expressions, and aggregates response rows. No more digging through the GA4 reference docs mid-session.

Quick Start

Add this to your Claude Desktop or MCP client config:

{
  "mcpServers": {
    "query-analytics": {
      "url": "https://query-analytics-YOUR_HASH-uc.a.run.app/mcp"
    }
  }
}

Replace YOUR_HASH with the Cloud Run service URL from your deployment.

Before / After

Before: Hand-building a GA4 request body at 2am.

// What you used to write by hand:
{
  "dimensions": [{"name": "date"}, {"name": "country"}],
  "metrics": [{"name": "sessions"}, {"name": "bounceRate"}],
  "dateRanges": [{"startDate": "2026-03-06", "endDate": "2026-04-02"}],
  "limit": 1000,
  "orderBys": [{"metric": {"metricName": "sessions"}, "desc": true}]
}

After: One tool call.

build_ga4_query(
  metrics: ["sessions", "bounceRate"],
  dimensions: ["date", "country"],
  date_range: "last_28_days",
  order_by_metric: "sessions"
)

Output:

{
  "query": {
    "dimensions": [{"name": "date"}, {"name": "country"}],
    "metrics": [{"name": "sessions"}, {"name": "bounceRate"}],
    "dateRanges": [{"startDate": "2026-03-06", "endDate": "2026-04-02"}],
    "limit": 1000,
    "orderBys": [{"metric": {"metricName": "sessions"}, "desc": true}]
  },
  "resolvedDateRange": {
    "startDate": "2026-03-06",
    "endDate": "2026-04-02",
    "daysCount": 28
  }
}

Tools

Tool What it does
build_ga4_query Build a valid GA4 Data API runReport request body from plain parameters
get_date_range Convert named periods (last_28_days, this_month, etc.) to start/end date strings
format_analytics_metric Format raw numbers into human-readable strings (62.34%, 2m 14s, $1,234.00)
parse_filter_expression Convert plain-text filter strings into GA4 filterExpression JSON
aggregate_rows Roll up GA4 response rows by a dimension with metric summation and top-N

Who is this for?

  • Analytics engineers who are tired of re-reading the GA4 API docs to remember the exact filterExpression schema.
  • Product developers building dashboards who need clean, formatted metric values without writing formatting helpers from scratch.
  • AI agents and automations that need to construct valid GA4 queries programmatically without hallucinating API structure.

Health Check

Both endpoints return the same JSON:

GET /
GET /health
{
  "status": "ok",
  "server": "query-analytics",
  "version": "1.0.0",
  "tools": 5
}

Use /health for Cloud Run liveness probes.

MCP Endpoint

POST /mcp

Handles all MCP protocol requests (tools/list, tools/call) via StreamableHTTP transport.


Built by Mastermind HQ

MIT License

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured