mcp-server-google-analytics

mcp-server-google-analytics

30

This project implements an MCP server for accessing Google Analytics 4 data using the Model Context Protocol TypeScript SDK. It provides features like customizable page view metrics, active and new user tracking, event analysis, and user behavior monitoring.

Google Analytics MCP Server

An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.

Features

  • Get page view metrics with customizable dimensions
  • Track active and new users over time
  • Analyze specific events and their metrics
  • Monitor user behavior metrics (session duration, bounce rate)
  • Flexible date range selection for all queries

Prerequisites

  • Node.js 20 or higher
  • Google Analytics 4 property
  • Google Cloud project with Analytics Data API enabled
  • Service account credentials with appropriate permissions

Setup

  1. Create a Google Cloud project and enable the Analytics Data API
  2. Create a service account and download the credentials JSON file
  3. Grant the service account appropriate access to your GA4 property
  4. Set up environment variables for client email, private key, and GA property ID.

Installation

  • Install via Smithery using the command provided
  • Manual installation with pnpm

Security Considerations

  • Use environment variables for credentials
  • Implement CORS settings
  • Follow least privilege principle for permissions
  • Regularly rotate credentials
  • Monitor API usage and implement rate limiting

Contributing

Contributions are welcome! See the Contributing Guide for details.

License

Licensed under the MIT License.