October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
API integration

How to Connect Google Analytics to an MCP Server

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Google’s official, experimental Google Analytics MCP server to let a compatible AI client read data from a GA4 property. The documented local setup requires a Google Cloud project with the Analytics Admin API and Analytics Data API enabled, Application Default Credentials (ADC) for an identity that can access the property, and an MCP client configuration such as Gemini CLI or Claude Code. The server is read-only: it can retrieve Analytics information, but it cannot change Analytics settings.

What the Google Analytics MCP connection does

Google describes its Google Analytics Model Context Protocol (MCP) server as a way to connect Analytics data to an LLM, such as Gemini. In practice, an MCP-compatible client launches or connects to the server, then uses its available tools to request information from Analytics. You can ask questions in natural language—for example, how many users arrived yesterday—or request reports and property details.

The official project is documented as experimental and uses the Google Analytics Admin API and Google Analytics Data API. Its documented read tools cover account summaries, property details, Google Ads links, standard reports, funnel reports, custom dimensions and metrics, and realtime reports. Google states that the server accepts read requests only; it cannot edit Analytics configuration or settings. That makes it a reporting interface, not a way to administer GA4.

Google documents a local server setup for Gemini and Claude Code. A local setup runs the server on your machine through the MCP client. This is distinct from connecting to a Google-hosted remote MCP server, which has separate authentication and IAM considerations.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before you start

  • A Google Cloud project: You need a project where you can enable APIs and manage credentials. You can use an existing project or create one.
  • Access to the GA account or property: The identity used for authentication must already have appropriate access to the Analytics resource you want to query.
  • Both Analytics APIs enabled: Enable the Google Analytics Admin API and Google Analytics Data API in the project you will identify with GOOGLE_PROJECT_ID.
  • Python package runner: Install pipx, which the documented local configuration uses to run analytics-mcp.
  • A compatible client: The documented configuration paths include Gemini CLI or Gemini Code Assist and Claude Code. Do not assume every application that supports MCP has the same setup or authentication flow.

The official repository specifies the read-only OAuth scope https://www.googleapis.com/auth/analytics.readonly. Use an identity with only the Analytics permissions needed for the data you intend to retrieve.

Set up the local server with Gemini

  1. Enable the APIs. In the Google Cloud project you plan to use, enable both Google Analytics Admin API and Google Analytics Data API. Record the project ID; you will put it in GOOGLE_PROJECT_ID.
  2. Set up ADC. Authenticate the Google user who has access to the target Analytics account or property using Application Default Credentials. The documented flow uses gcloud auth application-default login; use the read-only Analytics scope above and note the path to the resulting credentials file. The MCP process needs to be able to read that file.
  3. Install pipx. Install pipx using the method appropriate for your operating system, then check that the pipx executable is available in the environment from which Gemini runs.
  4. Edit Gemini’s settings. Add this server entry to ~/.gemini/settings.json, replacing the example values with your actual credentials-file path and Google Cloud project ID:
{
  "mcpServers": {
    "analytics-mcp": {
      "command": "pipx",
      "args": ["run", "analytics-mcp"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/adc-credentials.json",
        "GOOGLE_PROJECT_ID": "your-google-cloud-project-id"
      }
    }
  }
}
  1. Restart or reopen Gemini. Start Gemini CLI or Gemini Code Assist in the environment where the settings file is available. Type /mcp and verify that analytics-mcp appears in the server list.
  2. Ask a read-only test question. Start with a property-details question, or try: What are the most popular events in my Google Analytics property in the last 180 days? Check that the client is querying the intended property and date range before relying on the result.

The file path in GOOGLE_APPLICATION_CREDENTIALS must be an absolute path that the launched process can access. If Gemini cannot find pipx or the credentials file, a correct project ID alone will not establish the connection.

Configure Claude Code instead

If you use Claude Code, the official repository documents adding the local process with the claude mcp add command. Run it in a shell where claude and pipx are available. Replace the sample file path and project ID:

Rank #2
Sale
The Google Workspace Bible: [14 in 1] The Ultimate All-in-One Guide from Beginner to Advanced | Including Gmail, Drive, Docs, Sheets, and Every Other App from the Suite
  • The Google Workspace Bible: [14 in 1] The Ultimate All in One Guide from Beginner to Advanced Including Gmail, Drive, Docs, Sheets, and Every Other App from the Suite
  • ABIS BOOK
claude mcp add analytics-mcp --scope user 
  -e GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/adc-credentials.json 
  -e GOOGLE_PROJECT_ID=your-google-cloud-project-id 
  -- pipx run analytics-mcp

The --scope user option registers the server for your user configuration. After adding it, restart or reopen Claude Code and inspect its MCP servers to confirm the connection. Then test with a specific property-details or report question. If your Claude Code version or environment presents different registration options, follow its current MCP configuration interface rather than copying a Gemini JSON entry into it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a Google Analytics MCP connector; it does not authenticate to GA4 or retrieve Analytics reports. It can be useful separately when your task is to capture a webpage. One GET request returns an image or PDF:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for the request options. Before a capture, it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture.

The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. If that separate screenshot workflow is useful, sign up for ScreenshotNeo free.

Authentication: local ADC is not the same as remote MCP

For the documented local setup, ADC supplies the Google identity used by the server. The identity must have access to the target Analytics account or property, and the read-only scope limits the requested OAuth access. The Cloud project named by GOOGLE_PROJECT_ID is where the required APIs are enabled; it does not grant Analytics access by itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Google’s guidance for its remote Google MCP servers describes separate authentication choices: ADC, an OAuth 2.0 client ID and secret, or an Authorization header containing an OAuth bearer token. An API key is an option only for services that do not require a principal. The supported method depends on the AI application. Google also says remote Google MCP servers do not support Dynamic Client Registration or OAuth Client ID Metadata Documents.

Where Google Cloud IAM applies to remote MCP calls, the predefined MCP Tool User role (roles/mcp.toolUser) includes the mcp.tools.call permission. That permission concerns making MCP calls; it does not replace the permissions required on the underlying Analytics account or property. For hosted or multi-user deployments, choose an identity model deliberately—such as per-user OAuth or an appropriately scoped service identity—and avoid sharing broad credentials across users.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting connection and access problems

  • The client does not list analytics-mcp. Check that the JSON entry is nested under mcpServers, the command is pipx, and the arguments are run and analytics-mcp. Save the file, restart the MCP client, and inspect /mcp in Gemini.
  • The server starts, but requests fail. Confirm that both the Admin API and Data API are enabled in the Cloud project named by GOOGLE_PROJECT_ID. Enabling APIs in a different project will not fix the project configured for this process.
  • Authentication errors appear. Verify that GOOGLE_APPLICATION_CREDENTIALS points to the ADC JSON file created by gcloud auth application-default login, that the file exists and is readable by the MCP process, and that the credentials were created with https://www.googleapis.com/auth/analytics.readonly. Reauthenticate if the required scope was not granted.
  • The connection works but cannot see the property. Check that the authenticated user has access to the exact Analytics account or property. The Cloud project and its API settings do not automatically grant access to GA4 data.
  • Gemini works but another client does not. Check that client’s own MCP configuration and supported authentication methods. The Gemini local JSON settings are not a universal MCP configuration format.
  • A remote endpoint rejects the setup. Do not assume a local pipx configuration or ADC file applies to a Google-hosted remote server. Use the remote server’s documented authentication method, and account for Google’s stated lack of Dynamic Client Registration and OAuth Client ID Metadata Documents.

Use the server carefully

Natural-language requests are convenient, but a report answer still depends on choosing the correct property, date range, dimensions, and metrics. Make the property and time window explicit for important questions, and verify the returned report in Analytics when a business decision depends on it. For repeated or consequential reporting, use precise prompts and retain enough context to understand which property and period were queried.

The local server is documented as experimental, so treat it as a development integration rather than assuming production guarantees or a particular maintenance commitment. The reviewed documentation does not establish a fixed query latency, service-level commitment, or cost for a particular deployment. Check applicable Google Cloud usage and billing information for your environment, and test the integration with non-critical reporting before making it part of an automated workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can I use the connection to change Analytics settings?

No. Google describes the official server as read-only; it cannot edit Analytics configuration or settings.

Does the Cloud project ID identify my GA4 property?

No. GOOGLE_PROJECT_ID identifies the Cloud project used for the server and API enablement. The authenticated identity must separately have Analytics access to the property you want to query.

Can I use this local setup with any MCP client?

Not automatically. Gemini and Claude Code have documented configuration paths, but other clients may require different server registration or authentication settings.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.