Cover image
Try Now
2025-01-29

Model Context Protocol server for Google Analytics, enabling LLMs to fetch and analyze web analytics data

3 years

Works with Finder

1

Github Watches

5

Github Forks

17

Github Stars

Google Analytics MCP Server

smithery badge

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:
export GOOGLE_CLIENT_EMAIL="your-service-account@project.iam.gserviceaccount.com"
export GOOGLE_PRIVATE_KEY="your-private-key"
export GA_PROPERTY_ID="your-ga4-property-id"

Installation

Installing via Smithery

To install Google Analytics Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install mcp-server-google-analytics --client claude

Manual Installation

pnpm install mcp-server-google-analytics

Usage

Starting the Server

pnpm start

Configuration in Claude Desktop

Add this to your Claude Desktop configuration:

{
  "mcpServers": {
    "google-analytics": {
      "command": "npx",
      "args": ["-y", "mcp-server-google-analytics"],
      "env": {
        "GOOGLE_CLIENT_EMAIL": "your-service-account@project.iam.gserviceaccount.com",
        "GOOGLE_PRIVATE_KEY": "your-private-key",
        "GA_PROPERTY_ID": "your-ga4-property-id"
      }
    }
  }
}

Available Functions

getPageViews

Get page view metrics for a specific date range:

{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "dimensions": ["page", "country"] // Optional
}

getActiveUsers

Get active users metrics:

{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31"
}

getEvents

Get event metrics:

{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "eventName": "purchase" // Optional
}

getUserBehavior

Get user behavior metrics:

{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31"
}

Security Considerations

  • Always use environment variables for sensitive credentials
  • Implement appropriate CORS settings
  • Follow the principle of least privilege when setting up service account permissions
  • Regularly rotate service account credentials
  • Monitor API usage and implement rate limiting if needed

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • https://tovuti.be
  • Oede knorrepot die vasthoudt an de goeie ouwe tied van 't boerenleven

  • Gil kaminski
  • Make sure you are post-ready before you post on social media

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • WILLIAM JOEL FOTEPING
  • Friendly music guide for 60s-2000s songs, with links to listen online.

  • momi
  • Provides initial medical assessments and advice.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • oatpp
  • Anthropic’s Model Context Protocol implementation for Oat++

  • huahuayu
  • A unified API gateway for integrating multiple etherscan-like blockchain explorer APIs with Model Context Protocol (MCP) support for AI assistants.

  • deemkeen
  • control your mbot2 with a power combo: mqtt+mcp+llm

  • zhaoyunxing92
  • 本项目是一个钉钉MCP(Message Connector Protocol)服务,提供了与钉钉企业应用交互的API接口。项目基于Go语言开发,支持员工信息查询和消息发送等功能。

  • justmywyw
  • Short and sweet example MCP server / client implementation for Tools, Resources and Prompts.

    Reviews

    5 (1)
    Avatar
    user_wydu5PRQ
    2025-04-15

    I've been using "VSCode as MCP Server" by acomagu for a while, and it's a fantastic integration. It allows me to leverage the power and flexibility of VSCode while managing my MCP projects efficiently. Highly recommended for developers looking to streamline their workflow. Check it out at https://mcp.so/server/vscode-as-mcp-server/acomagu.