GA Multi MCP
The server wraps the Google Analytics Data API (and Admin API for property discovery) to query GA4 metrics and dimensions across one or many properties. It allows listing and fuzzy-searching accessible properties, running report queries with natural-language date ranges, comparing metrics across multiple properties in a single call, fetching per-property metadata (available dimensions, metrics, custom definitions), and querying real-time traffic for the last 30 minutes, all with TTL caching to reduce API calls.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
GA Multi MCP
A Model Context Protocol (MCP) server for querying Google Analytics 4 data across multiple properties. Designed for use with LLM agents and the Programmatic Tool Calling (PTC) framework.
Features
Multi-Property Support: Query analytics across multiple GA4 properties in one call
Fuzzy Name Matching: Reference properties by name or partial match, not just IDs
Natural Language Dates: Use "yesterday", "7daysAgo", "last week" instead of dates
Property Discovery: Auto-discover all accessible GA4 properties
Real-time Data: Query live traffic data (last 30 minutes)
Intelligent Caching: Minimize API calls with configurable TTL caching
LLM-Optimized: Structured outputs designed for AI agent consumption
Related MCP server: Google Analytics MCP Server
Quick Start
New to this? See the step-by-step Getting Started Guide.
Installation
Using uv (Recommended)
uv is the fastest way to install and run:
# Install from GitHub
uv tool install git+https://github.com/heygoodgame/ga-multi-mcp.git
# Run after installing
ga-multi-mcpFrom Source
git clone https://github.com/heygoodgame/ga-multi-mcp.git
cd ga-multi-mcp
# Using uv (recommended)
uv sync
uv run ga-multi-mcp
# Or using pip
pip install -e .Google Cloud Setup
Create a Service Account
Go to Google Cloud Console
Create a new project or select existing
Navigate to "IAM & Admin" > "Service Accounts"
Create a service account with a descriptive name
Enable APIs
Enable "Google Analytics Data API"
Enable "Google Analytics Admin API"
Download Credentials
Create a JSON key for the service account
Save the file securely (e.g.,
~/.config/ga-service-account.json)
Grant Access in GA4
In Google Analytics, go to Admin > Property Access Management
Add the service account email with "Viewer" role
Repeat for each property you want to query
Configuration
Set the following environment variables:
# Required: Path to your service account JSON
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
# Optional: Custom settings
export GA_CACHE_TTL=300 # Cache TTL in seconds (default: 300)
export GA_PROPERTY_CACHE_TTL=3600 # Property list cache TTL (default: 3600)
export GA_FUZZY_THRESHOLD=0.6 # Fuzzy match threshold 0.0-1.0 (default: 0.6)
export GA_DEFAULT_LIMIT=1000 # Default query row limit (default: 1000)
export GA_PROPERTY_ALIASES='{"myblog": ["blog", "personal site"]}' # Custom aliases (JSON)Usage
Running the Server
# Direct execution
python -m ga_multi_mcp
# Or using the CLI
ga-multi-mcpMCP Client Configuration
Add to your MCP client configuration (e.g., Claude Desktop, Cursor):
{
"mcpServers": {
"ga-multi": {
"command": "ga-multi-mcp",
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
}
}
}
}Note: This assumes you've installed with
uv tool install. If running from source, use"command": "uv"with"args": ["run", "ga-multi-mcp"]and set the working directory.
PTC Framework Configuration
For use with open-ptc-agent:
# config.yaml
mcp_servers:
- name: ga-multi
enabled: true
description: Google Analytics 4 multi-property querying
instruction: |
Use list_properties first to discover available properties.
Supports fuzzy matching on property names.
transport: stdio
command: python
args: ["-m", "ga_multi_mcp"]
env:
GOOGLE_APPLICATION_CREDENTIALS: ${GA_SERVICE_ACCOUNT_PATH}Available Tools
list_properties
List all accessible GA4 properties.
# Example output
{
"properties": [
{"id": "123456789", "name": "myblog", "display_name": "My Blog"},
{"id": "987654321", "name": "myapp", "display_name": "My App"}
],
"count": 2
}search_properties
Search for properties by name with fuzzy matching.
# Input
search_properties(query="blog")
# Output
{
"matches": [
{"property_id": "123456789", "display_name": "My Blog", "confidence": 0.85}
],
"best_match": {...}
}query_analytics
Query GA4 analytics for a single property.
# Input
query_analytics(
property="my blog", # Fuzzy matched
metrics=["activeUsers", "sessions"],
start_date="7daysAgo",
end_date="today",
dimensions=["date", "country"]
)
# Output
{
"property_id": "123456789",
"property_name": "My Blog",
"date_range": {"start_date": "2024-01-08", "end_date": "2024-01-15"},
"rows": [
{"date": "20240115", "country": "United States", "activeUsers": 150, "sessions": 200},
...
],
"row_count": 42
}query_multiple_properties
Query metrics across multiple properties for comparison.
# Input
query_multiple_properties(
properties=["blog", "app", "store"],
metrics=["activeUsers", "sessions"],
start_date="last week",
end_date="today"
)
# Output
{
"results": [
{"property_name": "My Blog", "data": [...]},
{"property_name": "My App", "data": [...]},
{"property_name": "My Store", "data": [...]}
],
"summary": {
"totals": {"activeUsers": 5000, "sessions": 8000}
}
}get_property_metadata
Get available dimensions and metrics for a property.
# Input
get_property_metadata(property="my blog")
# Output
{
"dimensions": [
{"api_name": "date", "ui_name": "Date"},
{"api_name": "country", "ui_name": "Country"},
...
],
"metrics": [
{"api_name": "activeUsers", "ui_name": "Active users"},
...
],
"custom_dimensions": [...],
"custom_metrics": [...]
}query_realtime
Query real-time data (last 30 minutes).
# Input
query_realtime(
property="my blog",
metrics=["activeUsers"],
dimensions=["country"]
)
# Output
{
"property_name": "My Blog",
"lookback_minutes": 30,
"rows": [
{"country": "United States", "activeUsers": 25},
{"country": "United Kingdom", "activeUsers": 10}
]
}get_cache_status / clear_cache
Manage the internal cache.
Common Metrics & Dimensions
Popular Metrics
activeUsers- Users active in the periodsessions- Total sessionsscreenPageViews- Page/screen viewseventCount- Total eventsbounceRate- Bounce rateaverageSessionDuration- Avg session lengthnewUsers- New users
Popular Dimensions
date- Date (YYYYMMDD)country- Country namecity- City namedeviceCategory- desktop/mobile/tabletbrowser- Browser nameoperatingSystem- OS namepagePath- Page URL pathsessionSource- Traffic source
Date Formats
Supported date formats:
ISO:
2024-01-15US:
01/15/2024Relative:
today,yesterdayDays ago:
7daysAgo,30daysagoWeeks ago:
1weekAgo,2weeksagoMonths ago:
1monthAgo,3monthsagoNamed:
last week,last month,this week,this month,ytd
Troubleshooting
"Property not found"
Use
list_propertiesto see available propertiesCheck service account has viewer access in GA4
Try
search_propertieswith partial name
"Failed to initialize GA client"
Verify
GOOGLE_APPLICATION_CREDENTIALSpath is correctCheck service account JSON file exists and is valid
Ensure APIs are enabled in Google Cloud Console
Rate Limiting
GA4 API has quotas (default: 100 requests/100 seconds)
Use caching (enabled by default)
Batch queries with
query_multiple_properties
License
MIT License - see LICENSE file.
Contributing
Contributions welcome! Please open an issue or PR on GitHub.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect Google Analytics to ChatGPT. Query GA4 data in plain English and get instant insights.
Ask GA4 about sessions, conversions and revenue by channel from your AI client.
Query your Betterlytics web analytics from AI agents: traffic, funnels, journeys, errors, uptime.
Read-only Google Search Console and Google Analytics for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables LLMs to interact with Google Analytics 4 data through the Google Analytics Data API, supporting standard reports, real-time data, and metadata retrieval.19MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to query Google Analytics 4 data, including listing accounts and properties, running historical and real-time reports with customizable metrics and dimensions.MIT
- AlicenseAqualityDmaintenanceEnables 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.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables natural language querying of Google Analytics 4, including reports, realtime data, custom dimensions, and property management.149 npm1MIT