Google Analytics MCP Server

Google Analytics MCP Server

Enables AI agents to query Google Analytics 4 data, including listing accounts and properties, running historical and real-time reports with customizable metrics and dimensions.

Category
Visit Server

README

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

📋 Requisitos Previos

  1. Node.js v18 o superior
  2. Proyecto en Google Cloud con las siguientes APIs habilitadas:
    • Google Analytics Admin API
    • Google Analytics Data API
  3. 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 install

2. Configurar Google Cloud

  1. Ve a Google Cloud Console
  2. Crea un proyecto o selecciona uno existente
  3. Habilita las APIs:
  4. Ve a APIs & Services > Credentials
  5. Crea credenciales OAuth 2.0 Client ID (tipo: Desktop App)
  6. 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.js

Nota: 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
list_accounts Lista todas las cuentas de Analytics
list_properties Lista propiedades de una cuenta
run_report Ejecuta un reporte con métricas/dimensiones
run_realtime_report 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.json o google-analytics.yaml a Git.

Estos archivos contienen tokens de acceso a tus cuentas de Analytics.

📄 Licencia

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured