Analytics MCP
Integrates with AWS Secrets Manager to securely store and retrieve Google service account credentials.
Automates Google Analytics 4 property creation, data streams, and optional BigQuery export for tracking.
Automates Google Tag Manager container setup, including GA4 config tags, event tags, publishing, and snippets.
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., "@Analytics MCPShow health status for example.com prod"
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.
Analytics MCP
One-click GA4 + GTM analytics automation for developers, agencies, and AI agents.
Automate Google Analytics 4 and Google Tag Manager setup, apply opinionated tracking blueprints, monitor health, and manage everything via CLI, REST API, MCP tools, or Web UI.
Features • Quickstart • Screenshots • CLI • MCP • API
Features
Feature | Description |
GA4 Automation | Create properties, web data streams, optional BigQuery export |
GTM Automation | Containers, GA4 config tags, event tags, publish & snippets |
Tracking Blueprints | SaaS, ecommerce, and content presets with dataLayer specs |
Consent Presets | none, basic, and advanced consent-gated triggers |
Multi-Environment | Separate dev/stage/prod configurations |
Governance | Audit log, GTM diff, rollback |
Health Monitoring | Scheduled checks, webhook/email alerts, time-series charts |
MCP Integration | 5 tools for Claude, Gemini, and other MCP clients |
Web Dashboard | Create, monitor, and manage sites visually with charts |
Security | KMS/Secrets Manager support (AWS, GCP, Azure) |
Reliability | Automatic retry with exponential backoff for API calls |
Related MCP server: MCP Google Analytics 4 Server
Quickstart
Prerequisites
Docker & Docker Compose
Python 3.11+ (for local dev)
Google Cloud service account with GA4 Admin, GTM, and (optional) BigQuery permissions
1. Clone and configure
git clone https://github.com/abhishekshankar/MCP-Metrics.git
cd MCP-Metrics
cp config/env.example .env
# Edit .env with your GTM account ID and credentials path2. Start services
docker compose up -dAPI available at http://localhost:8000 — health check:
curl http://localhost:8000/health3. Create your first site
pip install -e ".[dev]"
analytics-mcp create \
--domain example.com \
--name "Example Site" \
--env prod \
--blueprint saas \
--pretty4. Web UI
cd web-ui && npm install && npm run devScreenshots
Dashboard
List all your analytics setups with health status at a glance.
┌─────────────────────────────────────────────────────────────┐
│ Sites Dashboard │
├──────────────┬──────────┬─────┬──────────┬────────┬────────┤
│ Domain │ Name │ Env │ Blueprint│ GTM │ Status │
├──────────────┼──────────┼─────┼──────────┼────────┼────────┤
│ example.com │ Example │ prod│ saas │ GTM-ABC│ active │
│ shop.com │ Shop │ prod│ ecommerce│ GTM-DEF│ active │
│ blog.com │ Blog │ prod│ content │ GTM-GHI│ active │
└──────────────┴──────────┴─────┴──────────┴────────┴────────┘Site Detail with Health Charts
View detailed health metrics with time-series charts showing events, sessions, and conversions over time.
┌─────────────────────────────────────────────────────────────┐
│ example.com · prod │
├─────────────────────────────────────────────────────────────┤
│ G-XXXXXXXX │ GTM-XXXX │ saas │ healthy │
├─────────────────────────────────────────────────────────────┤
│ Health Metrics (24h) │
│ ┌─────────────────────────────────────────────────────────┐│
│ │ Events: 1,500 │ Sessions: 800 │ Conversions: 45 ││
│ └─────────────────────────────────────────────────────────┘│
│ │
│ Health Trends (30 Days) │
│ ═══════════════════════════════════════════════════════ │
│ ║ Chart: Events & Sessions over time ║ │
│ ║ Chart: Conversions bar chart ║ │
│ ═══════════════════════════════════════════════════════ │
│ │
│ GTM Configuration Diff │
│ ├─ Tags: +3 added, -1 removed │
│ ├─ Triggers: +2 added │
│ └─ Variables: no changes │
└─────────────────────────────────────────────────────────────┘Blueprint Editor
View, edit, and create custom tracking blueprints with live validation.
┌─────────────────────────────────────────────────────────────┐
│ Blueprint Editor │
│ [saas] [ecommerce] [content] [+ New Blueprint] │
├─────────────────────────────────────────────────────────────┤
│ name: saas │
│ description: SaaS product site tracking │
│ events: │
│ - signup_started │
│ - signup_completed │
│ - trial_started │
│ - pricing_view │
│ │
│ [Apply to Site] [Save Changes] │
└─────────────────────────────────────────────────────────────┘CLI Commands
Command | Description |
| Full GA4 + GTM + blueprint setup |
| Get site status |
| List all sites |
| Apply/update blueprint |
| Run health check |
| Rollback GTM version |
| Human-readable setup summary |
MCP Client Setup
Claude Desktop
Copy config/mcp-claude.example.json into your Claude Desktop MCP config:
{
"mcpServers": {
"analytics": {
"command": "python",
"args": ["/path/to/analytics_mcp_mcp_server.py"],
"env": {
"DATABASE_URL": "postgresql://..."
}
}
}
}Available MCP Tools
Tool | Description |
| Create GA4 + GTM setup for a new site |
| Get current status of a site's analytics |
| Apply a tracking blueprint to a site |
| Get human-readable description of setup |
| Get health status with metrics |
REST API
Core Endpoints
Method | Endpoint | Description |
GET |
| Service health |
POST |
| Create site |
GET |
| List sites |
GET |
| Site status |
POST |
| Apply blueprint |
GET |
| Health check |
GET |
| Health history (charts data) |
GET |
| Blueprint version history |
GET |
| GTM config diff |
POST |
| Rollback |
GET |
| Audit log |
POST |
| Save custom blueprint |
OpenAPI docs: http://localhost:8000/docs
Authentication
Pass X-API-Key header with admin or readonly key (configured in .env):
curl -H "X-API-Key: admin-key-change-me" http://localhost:8000/sitesArchitecture
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ CLI │ │ Web UI │ │ MCP Client │
│ (Typer) │ │ (React) │ │ (FastMCP) │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└────────────────┼────────────────┘
│
┌─────────▼──────────┐
│ FastAPI REST │
│ + MCP Server │
└─────────┬──────────┘
│
┌───────────────┼───────────────┐
│ │ │
┌───────▼───────┐ ┌─────▼─────┐ ┌──────▼──────┐
│ GA4Service │ │ GTMService│ │HealthService│
│ (w/ retry) │ │ (w/ retry)│ │(w/ scheduler)│
└───────┬───────┘ └─────┬─────┘ └──────┬──────┘
│ │ │
└───────────────┼──────────────┘
│
┌───────────────▼───────────────┐
│ Google APIs (GA4, GTM, BQ) │
└───────────────────────────────┘
│
┌────────▼────────┐
│ PostgreSQL │
│ (Sites, Audit) │
└─────────────────┘Security Features
KMS/Secrets Manager Support
Store Google service account credentials securely:
# AWS Secrets Manager
KMS_PROVIDER=aws
AWS_SECRET_NAME=analytics-mcp/google-credentials
# GCP Secret Manager
KMS_PROVIDER=gcp
GOOGLE_CLOUD_PROJECT=your-project
# Azure Key Vault
KMS_PROVIDER=azure
AZURE_KEY_VAULT_URL=https://your-vault.vault.azure.net/
AZURE_SECRET_NAME=google-credentialsAPI Authentication
Admin and read-only API keys
Role-based access control
Audit logging of all operations
Development
# Install dependencies
pip install -e ".[dev]"
# Run tests
MOCK_GOOGLE_APIS=true pytest backend/tests -v
# Run API locally
DATABASE_URL=postgresql://analytics:analytics@localhost:5432/analytics_mcp \
MOCK_GOOGLE_APIS=true \
PYTHONPATH=backend/src uvicorn main:app --reload
# Run migrations
alembic -c backend/alembic.ini upgrade head
# Web UI development
cd web-ui && npm install && npm run devConfiguration
Environment Variables
Variable | Description | Default |
| Use mock Google APIs (no real credentials needed) |
|
| Path to service account JSON | - |
| GTM account ID |
|
| Secrets manager (aws/gcp/azure) | - |
| Number of retry attempts for API calls |
|
| Health check scheduler interval |
|
See config/env.example for full configuration options.
Mock Mode
Set MOCK_GOOGLE_APIS=true (default in docker-compose) to run without real Google credentials. All GA4/GTM operations use in-memory mocks — ideal for development and CI.
Contributing
Contributions welcome! Please read our contributing guidelines (coming soon).
License
MIT — see LICENSE
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
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/abhishekshankar/MCP-Metrics'
If you have feedback or need assistance with the MCP directory API, please join our Discord server