home / mcp / google analytics data api mcp server
A MCP server for Google Analytics Data API
Configuration
View docs{
"mcpServers": {
"eno-graph-mcp-server-google-analytics": {
"command": "node",
"args": [
"/path/to/mcp-server-google-analytics/build/index.js"
],
"env": {
"GA_PROPERTY_ID": "your-ga4-property-id",
"GOOGLE_PRIVATE_KEY": "your-private-key",
"GOOGLE_CLIENT_EMAIL": "[email protected]"
}
}
}
}You deploy this MCP server to access the Google Analytics Data API through a convenient, programmable interface. It provides tools to fetch standard and real-time reports and exposes property metadata, all controllable from your MCP client.
Use this MCP server with your MCP client to run analytics queries against Google Analytics Data API. You can retrieve reports over a specified date range using get_report and fetch real-time data using get_realtime_data. Access the GA4 property metadata through the ga4://property/{propertyId}/metadata resource to discover available metrics and dimensions. Start the server, then issue tool invocations from your client by referencing the available tools and resources.
Prerequisites: ensure you have Node.js and npm installed on your system.
Step by step commands to set up and run the MCP server locally:
# Clone the repository
git clone https://github.com/eno-graph/mcp-server-google-analytics.git
cd mcp-server-google-analytics
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm start
```
If you prefer to run the provided script, you can execute:
```bash
./run-server.sh
```
Environment variables needed (set in your environment before starting the server):
```bash
export GOOGLE_CLIENT_EMAIL="[email protected]"
export GOOGLE_PRIVATE_KEY="your-private-key"
export GA_PROPERTY_ID="your-ga4-property-id"
```
For Claude Desktop integration, you can configure the server by providing the same environment variables in the client configuration.Environment variables described here must be supplied to the local process running the MCP server. The server exposes two main capabilities: the get_report tool for standard reports over a date range and the get_realtime_data tool for current activity. Use ga4://property/{propertyId}/metadata to inspect available metrics and dimensions for your GA4 property.
Claude Desktop configuration example shows how to wire the MCP server into a client. You can place this configuration in your Claude Desktop settings under the mcpServers section. The example uses a stdio approach to start the Node process that serves the MCP endpoints.
Fetch a report based on a specified date range, metrics, and dimensions. Returns aggregated metrics for the requested scope.
Retrieve real-time metrics and dimensions to monitor current activity.