Dev.to
7/8/2026

Bringing GA4 into an MCP server: what it actually takes to make analytics agent-friendly
Short summary
The author describes building an MCP server that lets AI assistants query GA4 analytics data, covering six tools including one that tracks traffic originating from AI assistants like ChatGPT and Perplexity. Key technical challenges include handling malformed LLM-generated inputs, multi-account OAuth token rotation, and GA4 concurrent-request quota management. Solutions include server-side regex filtering for AI sources, raw-count recomputation to avoid averaging rates, and in-process property-level request serialization.
- •Six GA4 MCP tools including novel LLM-traffic attribution via hand-maintained source lists with server-side regex filtering
- •Technical solutions for LLM-as-API-client: date coercion, token rotation across Google accounts, quota locking
- •Honest limitation: Google AI Overviews traffic is indistinguishable from organic and cannot be attributed separately
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



