Query GA4 properties using the Google Analytics MCP server via MCPorter. Each workspace supplies its own service account credentials — no shared or global auth.
uvx (from uv) — runs analytics-mcp ephemerally, no install neededmcporter — npm i -g mcporterEach workspace stores its own credentials:
text
{workspace}/
credentials/
ga-service-account.json ← Google service account key file
ga-config.json ← optional: default project/property
ga-config.json shape (optional):
json
{
"projectId": "my-gcp-project",
"defaultProperty": "properties/123456789"
}
If ga-config.json is absent, pass property explicitly in every query.
{workspace}/credentials/ga-service-account.json (fail clearly if missing).{workspace}/credentials/ga-config.json if present; extract projectId and defaultProperty.bash
bash {skill_dir}/scripts/ga.sh <workspace> <tool> [args...]
Or directly:
bash
CREDS="{workspace}/credentials/ga-service-account.json"
PROJECT_ID="$(cat {workspace}/credentials/ga-config.json | python3 -c 'import json,sys; print(json.load(sys.stdin).get("projectId",""))')"
mcporter call \
--stdio uvx \
--stdio-arg analytics-mcp \
--env "GOOGLE_APPLICATION_CREDENTIALS=$CREDS" \
--env "GOOGLE_CLOUD_PROJECT=$PROJECT_ID" \
"analytics-mcp.<tool>" \
[key=value ...]
ToolPurposeget_account_summariesList all GA accounts + properties the SA has access toget_property_detailsDetails for a specific propertyrun_reportStandard GA4 data report (dimensions, metrics, date ranges)run_funnel_reportFunnel analysisrun_realtime_reportRealtime dataget_custom_dimensions_and_metricsCustom dimensions/metrics for a propertylist_google_ads_linksGoogle Ads links for a property
List all accessible properties:
bash
mcporter call --stdio uvx --stdio-arg analytics-mcp \
--env "GOOGLE_APPLICATION_CREDENTIALS=$CREDS" \
analytics-mcp.get_account_summaries
Run a report (sessions last 30 days):
bash
mcporter call --stdio uvx --stdio-arg analytics-mcp \
--env "GOOGLE_APPLICATION_CREDENTIALS=$CREDS" \
--env "GOOGLE_CLOUD_PROJECT=$PROJECT_ID" \
analytics-mcp.run_report \
property=properties/123456789 \
'dimensions=[{"name":"date"}]' \
'metrics=[{"name":"sessions"}]' \
'dateRanges=[{"startDate":"30daysAgo","endDate":"today"}]'
See references/setup.md for full instructions. Short version:
{workspace}/credentials/ga-service-account.jsonbash {skill_dir}/scripts/ga.sh {workspace} get_account_summariesPERMISSION_DENIED — SA email not added to GA property accesscredentials not found — check ga-service-account.json pathAPI not enabled — enable Admin + Data APIs in GCP console