Google Analytics MCP Server
Provides tools for interacting with Google Analytics 4 (GA4) data, including listing accounts and properties, running historical reports with custom metrics and dimensions, and fetching real-time user activity.
Click on "Deploy 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 MCP ServerHow many users did my site have yesterday?"
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
🚀 MCP Server para Google Analytics 4 (GA4) - Permite a agentes de IA consultar datos de Analytics en tiempo real.
✨ Características
📊 Listar cuentas de Google Analytics
🌐 Listar propiedades (sitios web) por cuenta
📈 Reportes históricos con métricas y dimensiones personalizables
⚡ Reportes en tiempo real - usuarios activos ahora mismo
Related MCP server: Google Analytics MCP Server
📋 Requisitos Previos
Node.js v18 o superior
Proyecto en Google Cloud con las siguientes APIs habilitadas:
Google Analytics Admin API
Google Analytics Data API
Credenciales OAuth 2.0 (Client ID y Client Secret)
🔧 Instalación
1. Clonar el repositorio
git clone https://github.com/TU_USUARIO/google-analytics-mcp.git
cd google-analytics-mcp
npm install2. Configurar Google Cloud
Ve a Google Cloud Console
Crea un proyecto o selecciona uno existente
Habilita las APIs:
Ve a APIs & Services > Credentials
Crea credenciales OAuth 2.0 Client ID (tipo: Desktop App)
Descarga el archivo JSON
3. Obtener Refresh Token
Edita get-refresh-token.js con tu Client ID y Client Secret, luego:
```bash
node get-refresh-token.jsNota: El script solicitará permisos de edición (
analytics.edit) para permitir la creación de nuevas propiedades.
Esto abrirá el navegador para autenticarte y generará google-analytics.yaml.
4. Crear credentials.json
Crea un archivo credentials.json con este formato:
{
"type": "authorized_user",
"client_id": "TU_CLIENT_ID",
"client_secret": "TU_CLIENT_SECRET",
"refresh_token": "TU_REFRESH_TOKEN",
"quota_project_id": "TU_PROJECT_ID"
}5. Verificar conexión
node test-connection.js🔌 Integración con Antigravity/Claude
Añade a tu mcp_config.json:
{
"mcpServers": {
"google-analytics": {
"command": "node",
"args": ["C:/ruta/a/google-analytics-mcp/mcp-server.js"]
}
}
}🛠️ Herramientas Disponibles
Herramienta | Descripción |
| Lista todas las cuentas de Analytics |
| Lista propiedades de una cuenta |
| Ejecuta un reporte con métricas/dimensiones |
| Usuarios activos en tiempo real |
Ejemplos de uso
"¿Cuántos usuarios tuvo mi sitio ayer?"
"Dame un reporte de países de los últimos 7 días"
"¿Cuánta gente hay navegando ahora?"📁 Estructura del Proyecto
google-analytics-mcp/
├── mcp-server.js # Servidor MCP principal
├── get-refresh-token.js # Script para obtener credenciales
├── test-connection.js # Test de conexión
├── credentials.json # (No subir) Credenciales OAuth
├── google-analytics.yaml # (No subir) Configuración
└── package.json🔒 Seguridad
⚠️ IMPORTANTE: Nunca subas
credentials.jsonogoogle-analytics.yamla Git.
Estos archivos contienen tokens de acceso a tus cuentas de Analytics.
📄 Licencia
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
SEO & marketing toolkit for AI agents: GA4, Search Console, AdSense, GTM, PageSpeed, Trends.
Read-only Google Search Console and Google Analytics for AI agents.
Connect Google Analytics to ChatGPT. Query GA4 data in plain English and get instant insights.
Marketing data and actions for AI agents: GA4, Search Console, ads, social, SEO and WordPress.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Google Analytics 4 data, providing tools for historical reporting, real-time activity monitoring, and property management. It supports secure service account authentication to access metrics like traffic summaries, user acquisition, and custom dimensions.MIT
- AlicenseAqualityCmaintenanceEnables LLMs to interact with Google Analytics Admin and Data APIs to retrieve account summaries, property details, and custom metrics. It allows users to run core and real-time reports to analyze website performance and configuration via natural language.71Apache 2.0
- AlicenseNot gradedqualityFmaintenanceEnables LLMs to interact with Google Analytics 4 data through the Google Analytics Data API, supporting standard reports, real-time data, and metadata retrieval.19MIT
- AlicenseAqualityDmaintenanceEnables LLMs to interact with Google Analytics via Admin and Data APIs, allowing users to retrieve account summaries, run reports, and analyze realtime data.6Apache 2.0