mcp -ga4
MCP Server for Google Analytics 4
claude mcp add --transport stdio hosakakeigo-mcp-server-ga4 node /path/to/mcp-server-ga4/dist/index.js \ --env GA_PROPERTY_ID="your-ga4-property-id" \ --env GOOGLE_PROJECT_ID="your-project-id" \ --env GOOGLE_PRIVATE_KEY="your-private-key" \ --env GOOGLE_CLIENT_EMAIL="your-service-account-email@example.iam.gserviceaccount.com"
How to use
This MCP server provides GA4 data access through a set of tools that fetch metrics for a given date range. The available tools include get-page-views, get-active-users, get-events, and get-user-behavior, which retrieve page view counts, active user metrics, events, and user behavior data respectively from your GA4 property. It also exposes lightweight resources such as ga4://dimensions, ga4://metrics, ga4://filters-help, and ga4://property-info to help you discover available dimensions, metrics, and property metadata. You can combine these tools with prompts like analyze-data, create-report, and select-dimensions to perform data analysis, generate templates, and assist with choosing appropriate dimensions for your analysis goals. The server supports parameterized queries via filter, limit, and offset to narrow results and manage pagination.
How to install
Prerequisites:
- A Google Analytics 4 property
- A Google Cloud service account with access to the GA4 API
- Node.js 20 or higher
- pnpm package manager
Installation steps:
- Clone the repository
# Clone the repository
git clone https://github.com/yourusername/mcp-server-ga4.git
cd mcp-server-ga4
- Install dependencies with pnpm
# Install dependencies using pnpm
pnpm install
- Create the .env file from example
# Create the .env file
cp .env.example .env
- Edit credentials in .env (example variables shown):
GOOGLE_CLIENT_EMAIL=your-service-account-email@example.iam.gserviceaccount.com
GOOGLE_PRIVATE_KEY=your-private-key
GA_PROPERTY_ID=your-ga4-property-id
- Build and run the server
# Build the server
pnpm run build
# Run the server
pnpm start
Additional notes
Notes and tips:
- The server authenticates using a service account if GOOGLE_CLIENT_EMAIL and GOOGLE_PRIVATE_KEY are set; otherwise it uses default credentials (Application Default Credentials).
- Ensure the Google Analytics API is enabled and the service account has analytics.readonly permission.
- To use default credentials locally, you can set GOOGLE_APPLICATION_CREDENTIALS to a JSON key file path.
- The integration examples show how to wire the MCP server into Claude Desktop. Adjust the paths and environment variables to match your deployment.
- When querying large datasets, use the limit and offset parameters to paginate results and avoid timeouts.
Related MCP Servers
obsidian -tools
Add Obsidian integrations like semantic search and custom Templater prompts to Claude or any MCP client.
mcp
Octopus Deploy Official MCP Server
furi
CLI & API for MCP management
mcp -arangodb
This is a TypeScript-based MCP server that provides database interaction capabilities through ArangoDB. It implements core database operations and allows seamless integration with ArangoDB through MCP tools. You can use it wih Claude app and also extension for VSCode that works with mcp like Cline!
CodeRAG
Advanced graph-based code analysis for AI-assisted software development
mcp-bundler
Is the MCP configuration too complicated? You can easily share your own simplified setup!