What if you could ask an AI "why did my traffic drop last week?" and get an actual answer, pulled from your real Google Analytics and Search Console data, cross-referenced, in plain English?
That's what this guide sets up. It's a one-time configuration that gives Claude Code live access to your GA4 and Search Console properties. Once it's done, you can ask questions about your traffic, search performance, and SEO metrics without ever opening a dashboard.
If you're not familiar with MCP (Model Context Protocol) or why this matters, start with our plain-English explainer on what MCP is and why business owners should care. This guide is the hands-on follow-up: every step, every command, every troubleshooting tip.
Works on macOS, Windows, and Linux.
What you'll need
Before you start, make sure you have:
- A Claude Code subscription (Pro, Max, or API key)
- A Google account with access to your GA4 and Search Console properties
- Python 3.10 or higher installed on your machine
- Node.js 18+ and npm installed (download here)
- The gcloud CLI installed (Google Cloud SDK)
- Basic comfort running terminal commands (copy/paste is fine)
What you'll set up
There are two separate MCP servers. They share a single Google Cloud service account, so you only go through the Google Cloud setup once. Both servers support multiple properties, so just grant the service account access to each property you want to analyze.
| Component | What It Does | Install Method |
|---|---|---|
| GA4 MCP Server | Queries GA4 traffic, events, conversions, user data | pipx (Python) |
| GSC MCP Server | Queries search queries, impressions, CTR, indexing status | npx (Node.js) |
Part 1: Google Cloud setup
Both MCP servers authenticate using the same Google Cloud service account. You only need to do this once.
Create or select a Google Cloud project
- Go to console.cloud.google.com
- Click the project dropdown at the top of the page
- Either select an existing project or click New Project
- If creating new: name it something like "MCP Analytics" and click Create
- Make sure your new/selected project is active (shown in the top bar)
Enable the required APIs
You need to enable three APIs in your project. Navigate to APIs & Services > Library in the left sidebar, then search for and enable each one:
- Google Analytics Data API: pulls your GA4 report data
- Google Analytics Admin API: reads property configuration
- Google Search Console API: pulls search performance data
For each one: search the name, click on the API, then click the Enable button.
Create a service account
- In your Google Cloud project, go to APIs & Services > Credentials
- Click Create Credentials > Service Account
- Give it a name (e.g., "mcp-analytics-server")
- Click Create and Continue
- Skip the optional role assignment and click Done
Download the service account key
- On the Credentials page, click your new service account email
- Go to the Keys tab
- Click Add Key > Create new key
- Choose JSON format and click Create
- A .json file will download. Save it somewhere safe on your machine
Keep this file secure. This JSON key grants access to your analytics data. Don't commit it to Git, don't share it in Slack, and don't put it in a public folder. A good location is a dedicated folder like ~/.config/gcloud/ or ~/keys/.
For the rest of this guide, we'll refer to this file path as /path/to/your/service-account-key.json. Replace that with your actual file path whenever you see it.
Grant the service account access to your properties
Google Analytics 4:
- Go to analytics.google.com
- Open Admin (gear icon, bottom left)
- For each GA4 property you want to analyze, go to Admin > Property Access Management
- Click the + button and add your service account email
- Set the role to Viewer (read-only is all you need)
Your service account email looks like: mcp-analytics-server@your-project.iam.gserviceaccount.com
Google Search Console:
- Go to search.google.com/search-console
- For each Search Console property, select that property
- Go to Settings > Users and permissions
- Click Add User
- Enter your service account email and set permission to Full (read access)
Repeat for every property you want to access. The same service account works for all of them.
Checkpoint: You now have a Google Cloud project with three APIs enabled, a service account with a downloaded JSON key, and that service account has Viewer access to your GA4 and Search Console properties. The Google Cloud part is done.
Part 2: Install the GA4 MCP server
Google's official GA4 MCP server is a Python package. We'll install it with pipx, which keeps it isolated from your system Python.
Install pipx (if you don't have it)
macOS:
brew install pipx
pipx ensurepathWindows:
pip install pipx
pipx ensurepathLinux:
sudo apt install pipx # or: pip install pipx
pipx ensurepathClose and reopen your terminal after running ensurepath.
Install the server
pipx install git+https://github.com/googleanalytics/google-analytics-mcp.gitVerify it installed:
which google-analytics-mcpThis should return a path like ~/.local/pipx/venvs/google-analytics-mcp/bin/google-analytics-mcp. Copy this path. You'll need it next.
Add to Claude Code at user scope
This single command makes GA4 available across all your Claude Code projects. The server automatically discovers every GA4 property your service account can access, so there's no need to hard-code a property ID:
claude mcp add-json --scope user google-analytics-mcp \
'{
"command": "/path/from/which/output",
"args": [],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json"
}
}'Replace the two placeholders:
/path/from/which/output: the path returned by thewhichcommand above/path/to/your/service-account-key.json: your downloaded JSON key from Part 1
The GA4 MCP server is now installed and configured. It will be available in every Claude Code session.
Part 3: Install the Search Console MCP server
The Search Console MCP server takes a different approach. It's a Node.js package that runs via npx, which means there's no separate install step. npx downloads and runs the package automatically the first time Claude Code starts the server.
Confirm Node.js and npx are available
node --version # Should show v18.x or higher
npx --version # Should return a version numberIf Node.js isn't installed, download it from nodejs.org. npx comes bundled with Node.js automatically.
Add the GSC server to Claude Code at user scope
claude mcp add-json --scope user gsc-mcp \
'{
"command": "npx",
"args": ["-y", "mcp-server-gsc"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json"
}
}'Replace /path/to/your/service-account-key.json with the same JSON key path from Part 1.
Verify both servers
Restart Claude Code (close and reopen it), then run:
/mcpYou should see both servers listed and connected:
• google-analytics-mcp: connected
• gsc-mcp: connectedYou can also check from your terminal:
claude mcp listBoth MCP servers are now installed at user scope, ready to use across all your Claude Code projects. No per-project configuration needed.
Important: Both servers have read-only access. They can query and analyze your data but cannot change any settings, modify your GA4 configuration, or submit URLs for indexing. Your data is safe.
Part 4: Start asking questions
With both servers connected, you can ask Claude Code questions about your analytics data in plain English. Here are some examples to try right away.
Google Analytics questions:
- How many users visited my site in the last 30 days?
- What are my top 10 landing pages by sessions this month?
- Show me traffic by source/medium for the last 7 days
- What's the conversion rate for my contact form this quarter?
- Compare this month's traffic to last month. What changed?
- Which device category has the highest engagement rate?
Search Console questions:
- What are my top 20 search queries by clicks in the last 28 days?
- Which pages have the highest impressions but lowest CTR?
- Show me queries where I rank between positions 5-15 (quick win opportunities)
- How has my search performance trended over the last 90 days?
- Compare mobile vs. desktop search performance
The real power: combining both.
This is where it gets interesting. You can ask Claude to cross-reference both data sources in a single question:
- "My organic traffic dropped last week. Can you check both GA4 and Search Console to figure out what happened?"
- "Find pages where search impressions are growing but site engagement is low. Those might need content improvements."
- "What are my best-performing queries, and how much traffic are those pages actually getting once people land on them?"
Troubleshooting
Server shows "disconnected": Double-check that the JSON key file path in your config is correct and the file exists. Make sure the service account email has been added to both GA4 and Search Console. Restart Claude Code completely and run claude mcp list to confirm the config was saved.
"Permission denied" errors: Verify the service account has Viewer access in GA4 (Admin > Property Access Management) and Full permission in Search Console (Settings > Users and permissions). Confirm all three APIs are enabled in your Google Cloud project.
"Property not found" for GA4: Make sure you're using the Property ID (a plain number like 123456789), not the Measurement ID (which starts with G-). Verify the service account has Viewer access to the specific property you're querying.
pipx or npx not found: Run pipx ensurepath and restart your terminal. Make sure Node.js 18+ is installed with node --version. On Windows, you may need to open a new terminal window after installing.
Editing your config directly: If you need to update paths or fix a typo, your user-scoped config is stored in ~/.claude.json. Open it in any text editor and look for the mcpServers section. You can also remove a server with claude mcp remove google-analytics-mcp -s user.
Quick reference
| Action | Command |
|---|---|
| Check server status | /mcp (inside Claude Code) |
| List all MCP servers | claude mcp list |
| Remove a server | claude mcp remove <name> -s user |
| Edit config directly | Open ~/.claude.json in a text editor |
| Update GA4 MCP server | pipx upgrade google-analytics-mcp |
Key links:
- GA4 MCP Server (Official)
- GSC MCP Server
- Google's Official MCP Guide
- Claude Code MCP Docs
- Google Cloud Console
- Google Analytics
- Google Search Console
- Node.js Download
What's next?
This setup gives you an AI-powered analytics assistant that's available every time you open Claude Code. But Google Analytics and Search Console are just the beginning. MCP servers exist for dozens of tools, and the ecosystem is growing fast.
If you want to understand the bigger picture of what MCP is and where it's headed, read our plain-English explainer on MCP. And if you're interested in connecting AI to other parts of your business (your CRM, project management, internal databases), that's exactly what we help with.