Google Analytics MCP Server

Google Analytics MCP Server

By Kirill812 GitHub

Google Analytics MCP server for accessing analytics data through tools and resources

google-analytics mcp-server
Overview

what is Google Analytics MCP Server?

Google Analytics MCP Server is a Model Context Protocol (MCP) server that provides access to Google Analytics data through various tools and resources.

how to use Google Analytics MCP Server?

To use the server, clone the repository, install dependencies, set up your Google Analytics credentials in a .env file, and run the server using Node.js.

key features of Google Analytics MCP Server?

  • Access Google Analytics metrics and dimensions through MCP resources.
  • Fetch analytics data with flexible filtering options.
  • Get formatted data with insights and recommendations.
  • TypeScript implementation with strong typing.

use cases of Google Analytics MCP Server?

  1. Analyzing user engagement metrics for a website.
  2. Fetching and filtering analytics data for reporting purposes.
  3. Integrating Google Analytics data into other applications or services.

FAQ from Google Analytics MCP Server?

  • What is required to run the server?

You need Node.js, npm, and valid Google Analytics credentials.

  • Can I customize the data I fetch?

Yes! You can use various parameters to filter and customize the data retrieval.

  • Is there a license for this project?

Yes, the project is licensed under MIT.

Content

Google Analytics MCP Server

A Model Context Protocol (MCP) server that provides access to Google Analytics data through tools and resources.

Test results (2024-03-26):

  • Total active users: 102,883
  • Belarus active users: 64,837 (63%)
  • Total page views: 2,422,925
  • Belarus page views: 1,950,160 (80%)

Features

  • Access Google Analytics metrics and dimensions through MCP resources
  • Fetch analytics data with flexible filtering options
  • Get formatted data with insights and recommendations
  • TypeScript implementation with strong typing

Installation

  1. Clone the repository
  2. Install dependencies
    npm install
    
  3. Create a .env file based on .env.example with your Google Analytics credentials
  4. Build the project
    npm run build
    

Setup Google Analytics Credentials

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Google Analytics Data API
  4. Create a service account with appropriate permissions
  5. Download the service account key (JSON format)
  6. Extract the client email and private key from the JSON file
  7. Add these to your .env file:
    GA_PROPERTY_ID=your_property_id
    GA_CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com
    GA_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\nYourPrivateKeyHere\n-----END PRIVATE KEY-----
    

Usage

Running the Server

node build/index.js

MCP Configuration

Add the server to your cline_mcp_settings.json file:

{
  "mcpServers": {
    "google-analytics": {
      "command": "node",
      "args": ["/path/to/GAnalytics-MCP-server/build/index.js"],
      "env": {
        "GA_PROPERTY_ID": "your_property_id",
        "GA_CLIENT_EMAIL": "your-service-account@your-project.iam.gserviceaccount.com",
        "GA_PRIVATE_KEY": "-----BEGIN PRIVATE KEY-----\\nYourPrivateKeyHere\\n-----END PRIVATE KEY-----"
      }
    }
  }
}

Available Tools

get_analytics_data

Get Google Analytics data with optional filtering and analysis.

Parameters:

  • metrics (required): Array of metric names to fetch
  • dimensions (optional): Array of dimension names
  • startDate (required): Start date in YYYY-MM-DD format
  • endDate (required): End date in YYYY-MM-DD format
  • filters (optional): Object containing metric and dimension filters
  • orderBy (optional): Array of fields to sort by
  • limit (optional): Number of records to return
  • offset (optional): Index of first record to return

Example:

{
  "metrics": ["activeUsers", "newUsers"],
  "dimensions": ["country", "deviceCategory"],
  "startDate": "2023-01-01",
  "endDate": "2023-01-31",
  "filters": {
    "metrics": [
      {
        "metric": "activeUsers",
        "operation": "GREATER_THAN",
        "value": 10
      }
    ],
    "dimensions": [
      {
        "dimension": "country",
        "operation": "EXACT",
        "value": "United States"
      }
    ]
  },
  "orderBy": [
    {
      "field": "activeUsers",
      "desc": true
    }
  ],
  "limit": 10
}

Available Resources

analytics://metrics

List of available Google Analytics metrics.

analytics://dimensions

List of available Google Analytics dimensions.

analytics://reports/{reportId}

Access specific analytics report data.

Development

Running Tests

npm test

Building

npm run build

License

MIT

No tools information available.

Mirror of

image-generation mcp-server
View Details

Secure MCP server for analyzing Excel files with oletools

oletools mcp-server
View Details

Mirror of

bigquery mcp-server
View Details

MCPHubs is a website that showcases projects related to Anthropic's Model Context Protocol (MCP)

mcp mcp-server
View Details
Dealx
Dealx by DealExpress

-

dealx mcp-server
View Details

A Python-based MCP server that lets Claude run boto3 code to query and manage AWS resources. Execute powerful AWS operations directly through Claude with proper sandboxing and containerization. No need for complex setups - just pass your AWS credentials and start interacting with all AWS services.

aws mcp-server
View Details

Mirror of

opendota mcp-server
View Details