google-analytics-mcp
Provides tools to find and manage Google Ads links linked to Google Analytics properties.
Provides tools for Google Analytics 4 (GA4) reporting, admin management, and discovery, enabling data analysis and property configuration.
Provides tools for Google Search Console (GSC) search analytics, sitemaps, and site management, allowing query and page performance analysis.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@google-analytics-mcpshow my top pages for last week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Google Analytics MCP Server
A powerful Model Context Protocol (MCP) server that provides comprehensive Google Analytics 4 (GA4), Google Search Console (GSC), and Google Merchant Center (GMC) integration for Claude Desktop and other MCP clients.
Key Features
49 Specialized Tools Across Google Platforms
GA4: 20+ tools for reporting, admin, and discovery
GSC: 10+ tools for search analytics and site management
GMC: 11+ tools for merchant center and product management
Resolver: 4 tools for human-friendly ID resolution
Whoami: 1 unified summary tool
Smart Resolver Layer
Human-friendly queries: Use domains like "gatedepot.com" instead of cryptic IDs
Auto-resolution: Automatically finds the right property/site/account
Fuzzy matching: Handles typos and variations intelligently
Multi-platform: Works across GA4, GSC, and GMC
Performance Optimizations
TTL Caching: 10-minute cache for discovery calls (instant repeat lookups)
Auto-retry: Handles Google API rate limits with exponential backoff
Configurable: Environment variables for cache and retry settings
Enterprise Security
OAuth Integration: User-based authentication via Application Default Credentials
Secret Management: Credentials stored securely in Google Secret Manager
Read-only Access: Limited scopes for data protection
Related MCP server: Google Analytics MCP Server
Available Tools
GA4 Tools (20 tools)
Core Reporting:
run_report- Custom GA4 reports with dimensions, metrics, filtersrun_realtime_report- Real-time analytics dataget_custom_dimensions_and_metrics- Property metadata
Admin Management:
get_account_summaries- List all GA4 accounts and propertiesget_property_details- Detailed property informationlist_conversion_events- Conversion event managementlist_data_streams- Data stream configurationlist_custom_dimensions- Custom dimension managementlist_custom_metrics- Custom metric managementlist_google_ads_links- Google Ads integration
Enhanced Discovery:
properties_list_accounts- Flattened account/property listproperties_find- Search properties by name/URLdatastreams_find- Find streams by URL/measurement IDreport_top_pages- Top pages preset reportreport_revenue_by_channel- Revenue analysis presetreport_events_over_time- Event tracking over timereport_landing_pages_vs_conversions- Landing page analysis
GSC Tools (10 tools)
Basic Operations:
gsc_sites_list- List Search Console sitesgsc_sitemaps_list- Manage sitemapsgsc_search_analytics_query- Search performance data
Enhanced Analytics:
sites_find- Find sites by domain/URLpermissions_get- Site permission detailstop_queries- Top search queries presettop_pages- Top performing pages presetqueries_for_page- Queries driving specific pagescountry_device_matrix- Geographic and device analysissa_build_filters- Advanced filter builder
GMC Tools (11 tools)
Account Management:
gmc_accounts_list- List Merchant Center accountsgmc_accounts_get- Account detailsgmc_accounts_issues_list- Account issuesaccounts_list- Enhanced account listingaccount_status- Account status and summary
Product Management:
gmc_products_list- List productsgmc_products_get- Product detailsproducts_find- Search products by queryproduct_status- Individual product statusproduct_status_aggregate- Bulk product status
Reporting:
report_issues_last_30d- Recent issues report
Resolver Tools (4 tools)
find_ga4_property- Resolve domain/URL to GA4 propertyfind_gsc_site- Resolve domain/URL to GSC sitefind_gmc_account- Resolve domain/brand to GMC accountfind_google_ads_link- Find Google Ads links for properties
Whoami Tool (1 tool)
summary- Unified overview of all accessible accounts and resources
🛠️ Quick Start
1. Clone and Setup
git clone https://github.com/pkidwell22/google-analytics-mcp.git
cd google-analytics-mcp
pip install -e .2. Authentication Setup
# Run the OAuth setup script
./setup-oauth.shThis will:
Enable required Google APIs (GA4, GSC, GMC, Cloud Run, Secret Manager)
Set up Application Default Credentials
Configure OAuth scopes for all platforms
3. Local Testing
# Build and run with Docker
./test-local.sh
# Or run directly
python3 -m analytics_mcp.server --transport http --port 80804. Cloud Run Deployment
# Deploy to Google Cloud Run
./deploy.sh🔧 Configuration
Claude Desktop Integration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"ga4-mcp": {
"transport": {
"type": "http",
"url": "https://ga4-mcp-syiiroz2la-uc.a.run.app"
},
"env": {
"GOOGLE_PROJECT_ID": "your-project-id"
}
}
}
}Environment Variables
GOOGLE_PROJECT_ID: Your Google Cloud Project IDMCP_CACHE_TTL_SEC: Cache TTL in seconds (default: 600)MCP_CACHE_MAXSIZE: Maximum cache entries (default: 2048)MCP_GOOGLE_RETRIES: API retry attempts (default: 5)
Example Usage
With Claude Desktop
Natural Language Queries:
"Show me revenue by channel for gatedepot.com"
"What are the top pages for my site?"
"Find conversion issues in my Merchant Center"
"List all my Google properties and accounts"
"Show me search performance for my landing pages"
Advanced Analytics:
"Get top queries driving traffic to /products page"
"Show me country and device breakdown for last month"
"Find products with issues in my Merchant Center"
"Analyze events over time for purchase events"
Direct API Usage
# Health check
curl https://ga4-mcp-syiiroz2la-uc.a.run.app/health
# Test cache functionality
bash scripts/smoke_cache.shArchitecture
analytics_mcp/
├── coordinator.py # MCP server configuration
├── server.py # Entry point and transport handling
├── tools/
│ ├── utils.py # Common utilities and auth
│ ├── reporting/ # GA4 Data API tools
│ ├── admin/ # GA4 Admin API tools
│ ├── gsc.py # Google Search Console tools
│ ├── gsc_enhanced.py # Enhanced GSC tools
│ ├── gmc.py # Google Merchant Center tools
│ ├── gmc_enhanced.py # Enhanced GMC tools
│ ├── ga4_enhanced.py # Enhanced GA4 tools
│ ├── resolver.py # Human-friendly ID resolution
│ └── whoami.py # Unified account summary
├── utils/
│ ├── cache.py # TTL caching system
│ └── google_retry.py # API retry logic
└── scripts/
└── smoke_cache.sh # Cache validation scriptSecurity
OAuth Integration: User-based authentication via Application Default Credentials
Secret Management: Credentials stored securely in Google Secret Manager
Read-only Access: Limited scopes for data protection
No Hardcoded Keys: All sensitive data externalized
Environment-based Config: Secure configuration via environment variables
Performance Features
Smart Caching
TTL-based: Configurable cache expiration (default: 10 minutes)
Memory efficient: LRU eviction with configurable max size
Transparent: Cache status visible in
meta.cachedfieldSelective: Only caches discovery/resolver calls, not real-time data
Resilient API Calls
Auto-retry: Handles 429/5xx errors automatically
Exponential backoff: Prevents API hammering
Random jitter: Avoids thundering herd problems
Configurable: Adjustable retry attempts and timing
Testing
Local Testing
# Run server locally
python3 -m analytics_mcp.server --transport http --port 8080
# Test specific tools
python3 -c "
import asyncio
from analytics_mcp.tools.resolver import find_ga4_property
# Test your tool here
"Cache Testing
# Test cache functionality
bash scripts/smoke_cache.sh
# Test with custom URL
URL=https://your-service-url.run.app bash scripts/smoke_cache.shReal-World Impact
Before MCP:
Copy/paste property IDs like
properties/341922028Switch between multiple Google tools
Remember different interfaces and APIs
Manual ID lookups and context switching
After MCP:
Natural language: "Show me revenue for gatedepot.com"
Unified interface through Claude
Instant cached lookups
Automatic error handling and retries
Deployment Scripts
setup-oauth.sh- Initial OAuth setup and API enablementtest-local.sh- Local Docker testingdeploy.sh- Cloud Run deployment with environment variablestest-mcp.sh- MCP server testingscripts/smoke_cache.sh- Cache validation testing
Prerequisites
Python 3.10+
Google Cloud Project with billing enabled
Google Analytics 4 property
Google Search Console access (optional)
Google Merchant Center access (optional)
Docker (for local testing)
gcloudCLI configured
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests
Submit a pull request
License
Apache 2.0 - See LICENSE file for details
Support
Issues: GitHub Issues
Documentation: See
README_mcp_claude.mdfor Claude Desktop setupDeployment: See
DEPLOYMENT_STEPS.mdfor detailed deployment guide
Roadmap
Resolver Layer - Human-friendly ID resolution
TTL Caching - Performance optimization
Auto-retry - Resilient API calls
GMC Integration - Merchant Center tools
Enhanced Tools - Discovery and preset reports
URL Inspection API - GSC URL inspection
Batch Operations - Bulk data operations
Custom Dashboards - Visualization tools
Export Functionality - Data export capabilities
Advanced Filtering - More sophisticated query options
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/pkidwell22/Google-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server