This guide walks you through connecting Claude Desktop to your Google Analytics accounts. Once set up, you can ask Claude questions like “show me last month’s traffic for [website]” and get real answers from your GA data.
The setup has many small steps, but none of them are hard if you go in order. Expect to spend about 45–60 minutes the first time.
What You’ll End Up With
- Claude Desktop will have direct, read-only access to your Google Analytics data.
- You’ll be able to ask Claude in plain English to pull reports, list accounts, compare time periods, etc.
- Nothing about this gives Claude permission to modify your GA data — it’s read-only.
What You Need Before Starting
- A Windows PC (this guide is Windows-specific).
- Claude Desktop installed. Download from claude.ai/download if you don’t have it.
- A Google account that has access to at least one Google Analytics property.
- About an hour of focused time. Don’t rush; small mistakes compound.
Everything else (Python, Google Cloud project, OAuth credentials, gcloud CLI, etc.) we’ll install or create together below.
Overview: The Big Picture
Before diving in, here’s roughly what we’re going to do, and why. Skim this so the steps make sense:
- Install some tools on your PC (Python, pipx, Google Cloud CLI) — these are the plumbing that lets your computer talk to Google.
- Create a project inside Google Cloud — a free container where your access credentials will live.
- Tell Google “this project is allowed to read Analytics data” by enabling two APIs.
- Create an OAuth client — basically a “permission slip” that lets your computer ask for access to your data.
- Run a login command that uses that permission slip to save a credential file to your PC.
- Install the MCP server — the small program that bridges Claude Desktop and Google Analytics.
- Edit a Claude Desktop config file to tell it about the new server.
- Restart Claude Desktop and test.
Don’t worry if some of those words don’t mean anything yet. Each step is explained.
Part 1: Install Python
Python is a programming language. The MCP server is written in Python, so we need it installed.
- Go to https://www.python.org/downloads/
- Click the big yellow “Download Python 3.x.x” button.
- Open the downloaded installer.
- Important: On the first installer screen, check the box that says “Add python.exe to PATH” at the bottom. This is critical.
- Click Install Now and wait for it to finish.
Verify it worked:
- Press the Windows key, type
PowerShell, and open it. - Type this and press Enter:
python --version - You should see something like
Python 3.12.5. If you get an error, the PATH checkbox was missed — re-run the installer and check the box.
Part 2: Install pipx
pipx is a tool that installs and runs Python programs without messing with your system.
In the same PowerShell window:
- Run:
python -m pip install --user pipxWait for it to finish (about 15 seconds). - Run:
python -m pipx ensurepath - Close PowerShell completely and reopen it. This is necessary — pipx won’t be findable until you do.
- Verify it worked:
pipx --versionYou should see something like1.10.0.
Part 3: Install Google Cloud CLI (gcloud)
The Google Cloud CLI is a program that lets your PC log in to Google services from the command line.
- Go to https://cloud.google.com/sdk/docs/install#windows
- Download the “Google Cloud CLI installer” (the Windows installer, an
.exefile). - Run the installer.
- During installation:
- Uncheck “Install Bundled Python” — you already have Python from Part 1.
- Check “Run ‘gcloud init’ to configure the SDK” (it might be checked by default).
- When the installer finishes, a Command Prompt window will open running
gcloud init. It will ask you to log in via a browser. - Sign in with the Google account that has access to your Analytics data.
- When asked “Pick cloud project to use”, you can pick any existing project, or choose to create a new one. We’re going to create a fresh dedicated one in the next part, so it doesn’t matter what you pick here. You can also just close the window if it feels overwhelming.
Verify it worked:
Close any open PowerShell windows and open a new one (gcloud needs a fresh terminal to be findable). Then:
gcloud --version
You should see version numbers listed. If you get an error, restart your PC and try again.
Part 4: Create a Google Cloud Project
A Google Cloud project is a free container that holds your API permissions. We’ll create a fresh one just for Claude.
- Open https://console.cloud.google.com in your browser.
- Sign in with the same Google account you used in Part 3.
- At the top of the page, you’ll see a project picker dropdown (might say “Select a project” or show an existing project name). Click it.
- In the popup, click “NEW PROJECT” in the upper right.
- Fill in:
- Project name: Something memorable like
Claude MCP— Google will auto-generate a unique ID likeclaude-mcp-478621from this. Write down the ID that appears below the name field; you’ll need it later. - Organization / Location: Leave defaults.
- Project name: Something memorable like
- Click CREATE and wait ~30 seconds.
- Once created, click the project picker at the top again and select your new project (so subsequent steps happen inside it).
Part 5: Enable the Two Required APIs
For your project to be allowed to read Analytics data, two APIs need to be turned on.
- Make sure your new project is selected at the top of the Google Cloud Console (the project name should be visible in the project picker).
- Open this link: https://console.cloud.google.com/apis/library
- In the search box, type “Google Analytics Data API”.
- Click the result, then click the blue ENABLE button. Wait a few seconds.
- Click your browser’s back button to return to the library, then search for “Google Analytics Admin API”.
- Click the result and click ENABLE.
That’s it — both APIs are now turned on for your project.
Part 6: Configure the OAuth Consent Screen
The “consent screen” is what you’ll see when you log in to grant your PC access to your data. You only need to set this up once per project.
- Go to: https://console.cloud.google.com/auth/overview
- If a setup wizard appears (it usually does for new projects), click GET STARTED.
- Fill in the App Information form:
- App name:
Claude MCP(or anything you like — only you will see it) - User support email: Pick your own email from the dropdown.
- App name:
- Click NEXT.
- Audience: Choose External. (This sounds scary but is correct for personal use. It just means “users outside an organization” — which includes you signing in with your own Gmail.) Click NEXT.
- Contact Information: Enter your email again. Click NEXT.
- Finish: Check the agreement box and click CONTINUE, then CREATE.
Add Yourself as a Test User
After setup, you need to add yourself to a “test users” list. While the app is in “Testing” mode (which it will be — we’re not publishing it), only listed test users can sign in.
- In the left sidebar (under “Google Auth Platform”), click Audience.
- Direct link: https://console.cloud.google.com/auth/audience
- Scroll down to the Test users section.
- Click + ADD USERS.
- Type your Google email address (the one with Analytics access) and click SAVE.
You should see your email listed under “User information” now.
Part 7: Create an OAuth Client ID
This step creates the “permission slip” your PC will use to ask for access.
- Go to: https://console.cloud.google.com/apis/credentials
- Make sure your project is selected at the top.
- Click + CREATE CREDENTIALS near the top, then choose OAuth client ID from the dropdown.
- Application type: Select Desktop app from the dropdown.
- Name: Type something like
Claude Desktop MCP(only you will see it). - Click CREATE.
- A popup will appear showing your Client ID and Client Secret. Click DOWNLOAD JSON to save the credentials file.
- Save the downloaded file somewhere you’ll remember, like
Documents\Claude\. The filename will look likeclient_secret_123456789-abcdefg.apps.googleusercontent.com.json. - Important: Don’t share this file with anyone or commit it to a public Git repository. Treat it like a password.
Part 8: Log In and Save Credentials to Your PC
Now we use the OAuth client you just downloaded to log in and save a credentials file that the MCP server will read.
- Open PowerShell (Windows key → type “PowerShell” → Enter).
- Type the following, replacing
C:\path\to\your\client_secret_xxx.jsonwith the actual path to the file you downloaded in Part 7:gcloud auth application-default login --client-id-file="C:\path\to\your\client_secret_xxx.json" --scopes="https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform"Tip: To find the exact path to your downloaded file, open File Explorer, navigate to the file, right-click it, and choose “Copy as path”. Paste that between the quotes. Tip: This command is long. Copy-paste it into PowerShell rather than typing manually. - Press Enter. Your default web browser should open automatically.
- Sign in with your Google account (the same one you added as a test user in Part 6).
- You’ll see a scary-looking warning: “Google hasn’t verified this app”. This is expected and fine. Click:
- Advanced (small link at the bottom)
- Then Go to Claude MCP (unsafe) (or whatever you named your app)
- Approve the permissions when asked (Analytics read access + Cloud Platform).
- The browser will show “You are now authenticated” and PowerShell will say:
Credentials saved to file: [C:\Users\<you>\AppData\Roaming\gcloud\application_default_credentials.json]
Write down (or copy) that exact path — you’ll paste it into the Claude Desktop config later.
If You Get “This app is blocked”
This means you ran the command without --client-id-file and gcloud tried to use its own default OAuth client, which Google has disabled for Analytics. Re-run the command, making sure --client-id-file="..." is included.
If You Get “Access blocked: [App name] has not completed the Google verification process”
You forgot to add yourself as a test user. Go back to Part 6 and add your email, then re-run the command.
Part 9: Install the MCP Server
The “MCP server” is the small program that translates between Claude Desktop and the Google Analytics API.
In PowerShell, run:
pipx run analytics-mcp --help
The first time this runs, it will take about 60 seconds as it downloads and installs the package. You’ll see output ending with something like:
Starting MCP Stdio Server: Google Analytics MCP Server
That’s it — it works. Press Ctrl+C to stop it (we just needed to confirm and pre-install). Future runs (including from Claude Desktop) will be instant because everything is cached.
Part 10: Edit the Claude Desktop Config File
This is the file where Claude Desktop learns about new MCP servers.
Open the File
- Press Windows key + R to open the Run dialog.
- Paste this and hit Enter:
%APPDATA%\Claude - A File Explorer window will open. Look for a file named
claude_desktop_config.json.- If it exists: Right-click → “Open with” → choose Notepad (or VS Code if you have it).
- If it doesn’t exist: Right-click in the empty space → New → Text Document. Rename it to exactly
claude_desktop_config.json(make sure to remove the.txtextension — you may need to enable “File name extensions” in File Explorer’s View menu to see it).
Back It Up First
Before editing, make a backup. In the same folder, copy claude_desktop_config.json and paste it (it’ll create claude_desktop_config - Copy.json). If anything goes wrong, you can restore.
Edit the Contents
If the file is empty or brand new, paste this:
{
"mcpServers": {
"analytics-mcp": {
"command": "pipx",
"args": ["run", "analytics-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "C:\\Users\\YOUR_USERNAME\\AppData\\Roaming\\gcloud\\application_default_credentials.json",
"GOOGLE_PROJECT_ID": "your-project-id-here"
}
}
}
}
If you already have other MCP servers in the file, add the analytics-mcp block as a new entry alongside them (inside the same mcpServers braces). Don’t forget the comma between entries. Example with two existing servers:
{
"mcpServers": {
"some-existing-server": {
"command": "...",
"args": ["..."]
},
"another-existing-server": {
"command": "...",
"args": ["..."]
},
"analytics-mcp": {
"command": "pipx",
"args": ["run", "analytics-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "C:\\Users\\YOUR_USERNAME\\AppData\\Roaming\\gcloud\\application_default_credentials.json",
"GOOGLE_PROJECT_ID": "your-project-id-here"
}
}
}
}
Fill In Your Values
You need to change two things in the analytics-mcp block:
GOOGLE_APPLICATION_CREDENTIALS: ReplaceYOUR_USERNAMEwith your actual Windows username. To find it, in PowerShell type:echo $env:USERNAMESo if your username isjohn, the path becomes:C:\\Users\\john\\AppData\\Roaming\\gcloud\\application_default_credentials.jsonCritical: Use double backslashes (\\) instead of single backslashes (\). JSON requires this.GOOGLE_PROJECT_ID: Replaceyour-project-id-herewith the project ID you wrote down in Part 4 (it looks likeclaude-mcp-478616). If you forgot it, go to https://console.cloud.google.com and look at the project picker — the ID is shown under the name.
Common JSON Mistakes That Will Break Everything
JSON is strict and unforgiving. The most common ways to break the file:
- Missing comma between entries inside
mcpServers. - Extra comma after the last entry (don’t put a comma after the last item in a list).
- Single backslashes in Windows paths (use
\\not\). - Curly braces or square brackets that don’t match.
- Smart quotes (
") instead of straight quotes (") — this happens if you paste from Word or similar. Use a plain text editor like Notepad or VS Code.
Before saving, paste the file contents into https://jsonlint.com and click “Validate JSON”. If it says “Valid JSON”, you’re good. If not, fix the error it points to.
If Claude Desktop sees broken JSON in this file, it will silently delete all your MCP servers on next launch. This is why we backed up first.
Save the File
Save the file (Ctrl+S in Notepad). Make sure the filename is still claude_desktop_config.json and not claude_desktop_config.json.txt.
Part 11: Restart Claude Desktop
This is the step people miss most often. Just closing the window is not enough — Claude Desktop keeps running in the background.
- Look at the system tray (bottom-right of your screen, near the clock). You may need to click the small
^arrow to see hidden icons. - Find the Claude icon, right-click it, and choose Quit.
- Wait 5 seconds.
- Reopen Claude Desktop from the Start menu.
Part 12: Test It
In Claude Desktop, start a new conversation and ask:
List my Google Analytics accounts.
Claude should respond by calling the MCP server and listing your accounts and their properties. You can then ask follow-up questions like:
Show me last 30 days of sessions for [your-website-property].
Compare this month vs last month for [property] by traffic source.
What were the top 10 pages on [property] last week?
Troubleshooting
“Pipx not found” or the MCP server doesn’t appear in Claude
Claude Desktop sometimes can’t find pipx on its own. Replace "command": "pipx" in the config with the full path. To find the full path, in PowerShell run:
where.exe pipx
Copy the output (something like C:\Users\YOU\AppData\Roaming\Python\Python312\Scripts\pipx.exe) and put it in the config — remember to escape backslashes (\\ not \):
"command": "C:\\Users\\YOU\\AppData\\Roaming\\Python\\Python312\\Scripts\\pipx.exe"
“invalid_grant: Bad Request” when running a query
The credentials file is no longer valid — usually because the refresh token expired (Google expires them after about 6 months of disuse) or got revoked.
Fix: Re-run the login command from Part 8 (the long gcloud auth application-default login --client-id-file=... one). Then fully restart Claude Desktop (right-click tray icon → Quit, then reopen).
Server times out at startup (60-second timeout in logs)
If you look at the log file at %APPDATA%\Claude\logs\mcp-server-analytics-mcp.log and see lines like creating virtual environment... followed by a timeout, your config is probably using --spec git+... style args.
Fix: Open the config and make sure the args line for analytics-mcp is exactly:
"args": ["run", "analytics-mcp"]
Not the longer ["run", "--spec", "git+https://...", "..."] form. The latter forces a fresh install on every Claude Desktop launch, which times out.
All my MCP servers disappeared after restart
Your config file has invalid JSON. Claude Desktop silently resets the file when it can’t parse it.
Fix: Restore from the backup you made. If you didn’t make one (next time, do!), rebuild the config carefully. Use https://jsonlint.com to validate before saving.
“Python was not found” warnings when running gcloud
These are harmless Windows messages from a feature called “App Execution Aliases” interfering with gcloud. You can ignore them. If they really bother you, go to Windows Settings → Apps → Advanced app settings → App execution aliases, and turn off the python.exe and python3.exe entries.
PowerShell complains about commas in –scopes
PowerShell sometimes mis-parses commas. Always wrap the value in double quotes:
--scopes="scope1,scope2"
Not:
--scopes=scope1,scope2
What If I Want to Update the MCP Server Later?
The MCP server is updated by Google occasionally. By default, pipx caches the version you first installed and uses it indefinitely. To force an update:
In PowerShell:
pipx run --no-cache analytics-mcp --help
This forces pipx to check for and install the newest version. After the new version installs, fully restart Claude Desktop.
Glossary
- MCP (Model Context Protocol): An open standard that lets AI assistants like Claude talk to external programs and data sources.
- MCP server: A small program that exposes a specific data source or tool (like Google Analytics) to Claude.
- OAuth: A standard way of granting limited access to your data to a third-party app without giving them your password.
- Application Default Credentials (ADC): A credentials file that Google libraries automatically look for to authenticate.
- pipx: A Python tool for installing and running command-line Python programs in isolated environments.
- PyPI: The Python Package Index — the central repository where most Python programs are published.
- Scopes: The specific permissions an OAuth credential grants (e.g., “read Analytics data” vs “edit Analytics settings”).
- Test user: A Google account allowed to use an OAuth app that hasn’t been formally verified by Google.
Summary of Key “Gotchas”
If you remember nothing else, remember these — they’re the things that broke during setup:
- Always use
--client-id-filewithgcloud auth application-default login. Without it, you’ll get “This app is blocked” because gcloud’s default credentials no longer work for Analytics. - Add yourself as a test user on the OAuth consent screen — otherwise sign-in is blocked.
- Use
pipx run analytics-mcpin the config, notpipx run --spec git+.... The latter times out. - Use double backslashes (
\\) in Windows paths inside the JSON config. - Fully quit Claude Desktop from the system tray before reopening — closing the window is not enough.
- Always back up the config file before editing — a JSON typo will wipe all your MCP servers.
- Validate JSON at https://jsonlint.com before saving the config.