Google Analytics MCP: How AI now communicates with analytics without API crutches

24.07.20254 min read
Meshcheryakov Dmitry
Lead Technical DirectorMeshcheryakov Dmitry

In July 2025, Google quietly released a tool on GitHub that would forever change the way web analytics was done. Official Google Analytics MCP server is a bridge that allows large language models (LLMs) to directly, securely, and structuredly query data from GA4.

You no longer need to write complex Python scripts to work with the Data API or build multi-story dashboards in Looker Studio. Now you can open Cursor, Gemini CLI or Claude Desktop and simply ask: “Which 5 products brought in the most organic search revenue last week?”

And AI will give an accurate answer, independently generating the necessary request to the metrics.


What is MCP (Model Context Protocol)?

MCP Specification, originally proposed by Anthropic in late 2024, has become the industry standard for connecting AI to external data sources. This is a conceptual answer to the problem of "AI hallucinations" due to lack of fresh context.

MCP is not a replacement for the HTTP API, it is a surface above it. It uses standard JSON-RPC 2.0 (on top of HTTP or WebSocket) but makes the request structure understandable to AI models.

Why wasn't a regular REST API suitable for AI?

Classic API problem How MCP solves it
Blindness LLM: the model does not know what endpoints exist. She needs to feed Swagger/OpenAPI documentation. Property Discoverability: The MCP server itself gives the circuit when connected (schema.json) all available methods and tools. What does this give us? We are in NBM-IT We are actively testing this combination to automate SEO audits. Instead of manually downloading CSV from Analytics, building graphs in Excel and writing conclusions, we feed the entire data set to the AI ​​server via MCP.
Hallucinations in parameters: LLM often confuses data types (sends a string instead of a number). Strong typing JSON Schema: MCP strictly validates the request before sending it to the Google backend.
Insulation: each service (GA4, CRM, Slack) requires writing a unique connector in Python. Versatility: once written MCP client works with any MCP server in the world without changing the client code.

How the official GA4 MCP Server works

The Google server is written in Python and is available in the official repository. Installation is simple (via pipx или Docker), но под капотом он требует стандартной настройки Google Cloud (Service Account, ключи авторизации и доступ к Google Analytics Admin & Data API).

The server exposes (exposes) 8 basic tools for AI:

  1. Getting a list of accounts.
  2. Getting a list of resources (Properties).
  3. Checking the status of connections with Google Ads.
  4. Generating reports on metrics and parameters (the most powerful method).
  5. Working with filters and segments.

Transaction example: person → MCP → GA4

  1. Man in Gemini CLI: “Show me the conversion from cart to purchase in the last 7 days”
  2. Gemini: understands the intent, analyzes the available MCP tools and decides to use the GA4 server method get_report.
  3. Gemini → MCP: sends a valid JSON-RPC request with parameters start_date, end_date, metrics: ['ecommercePurchases'], dimensions: ['date'].
  4. MCP → GA Data API: translates JSON-RPC into a native Google Analytics call.
  5. GA4 → MCP → Gemini: the data is returned to the LLM.
  6. Gemini → Man: “Over the last 7 days, the conversion rate was 3.2%, here is the breakdown by day...”

Who can connect to this server?

The MCP architecture is charming in its openness (client-server). If you have installed a GA4 MCP server on your machine (or in the company’s circuit), the following can connect to it:

  • Gemini CLI / Advanced
  • Claude Desktop (via Anthropic's Code Interpreter)
  • ChatGPT Code Interpreter
  • Development environments: Cursor, VS Code (via Cline plugin), Replit.

Killer feature for developers: Right in the Cursor editor (AI assistant) you can ask: “Write a React component that displays a session graph, take real monthly data from our GA4”. Cursor, through the local MCP, itself goes to your analytics, picks up JSON and, based on it, generates a working and data-accurate mockup UI!


Security risks: what enthusiasts are silent about

Transferring access to the “analytics button” to AI agents is a serious step towards automation, but also a huge security hole. Recent Cornell University research (arXiv:2505.11154) identified protocol vulnerabilities:

  1. Prompt Injection: If the MCP server has access not only to read GA4, but also to other databases on the server, attackers can inject a malicious prompt through web forms, forcing the AI to leak data to competitors.
  2. Tool Poisoning: Hacking open MCP servers for the purpose of data substitution. For example, a competitor could skew your CPL data to force your algorithms to reset your ad campaign bids.

Best Practice: Run the MCP server in an isolated Docker container. Issue a Service Account in Google Cloud exclusively read rights (Viewer). No ability to create segments or change settings.


Business Impact: Will Analysts Be Unemployed?

No. Regular builders of monotonous reports in Looker are possible. But systems analysts will move to a new level of abstraction.

The appearance of such servers marks the beginning of an era Actionable AI Agents. The next logical step, which is already being implemented through MCP + dbt bundles (announcement from dbt Labs):

The agent itself monitors the drop in traffic → The agent itself makes an MCP request in GA4 to find a sagging page → The agent itself makes an MCP request in Google Search Console → The agent itself generates the terms of reference to fix the SEO problem and sets the task in Jira (via Jira MCP).

If your company is looking to automate marketing and end-to-end analytics, getting rid of routine, NBM-IT web development team ready to design a secure data architecture with LLM integration. Fill out the application to evaluate your project.

Free project cost estimate

Answer 4 questions and we will send you a range of prices to suit your needs.

1. What type of corporate website do you need?

Leave your contacts - we will call you back, sort out the problem and offer the best way. We have more than 350 projects behind us, each of which we launched with an individual approach. We guarantee expert advice during business hours.