MCP Server for Google Analytics API access
Project description
Google Analytics MCP Server
A Model Context Protocol (MCP) server for comprehensive Google Analytics API access. Built with FastMCP and maintained by Locomotive Agency for use with mcpanywhere.com.
This server provides access to the Google Analytics Admin API and Google Analytics Data API through MCP tools for LLM integration.
Features
The server provides the following MCP tools:
Account & Property Information
get_account_summaries- Retrieves information about Google Analytics accounts and propertiesget_property_details- Returns details about a specific propertylist_google_ads_links- Lists Google Ads account links for a property
Core Reports
run_report- Runs a Google Analytics report using the Data APIget_custom_dimensions_and_metrics- Retrieves custom dimensions and metrics for a property
Realtime Reports
run_realtime_report- Runs a Google Analytics realtime report using the Data API
Installation
Recommended (via uv)
uv tool install google-analytics-mcp-python
Alternative (via pip)
pip install google-analytics-mcp-python
Alternative (via pipx)
pipx install google-analytics-mcp-python
Configuration
1. Enable Google Analytics APIs
Enable the following APIs in your Google Cloud project:
2. Create Service Account
- Go to the Google Cloud Console
- Create a service account with the Analytics API scope
- Download the JSON key file
3. Set Environment Variables
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
Domain-Wide Delegation (Optional)
If you need to access Analytics properties on behalf of a user:
export ANALYTICS_MCP_SUBJECT="user@yourdomain.com"
Note: For backward compatibility, GOOGLE_IMPERSONATED_SUBJECT is also supported.
Required OAuth scope:
https://www.googleapis.com/auth/analytics.readonly
Usage with MCP Clients
Claude Desktop / Gemini
Add to your MCP settings file (~/.gemini/settings.json or Claude Desktop config):
{
"mcpServers": {
"google-analytics": {
"command": "uvx",
"args": ["google-analytics-mcp-python"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account-key.json",
"ANALYTICS_MCP_SUBJECT": "user@yourdomain.com"
}
}
}
}
Docker Deployment
Example Dockerfile for containerized deployment:
FROM python:3.12-slim
RUN pip install --no-cache-dir google-analytics-mcp-python
ENV GOOGLE_APPLICATION_CREDENTIALS=/var/secrets/service-account.json
CMD ["google-analytics-mcp"]
Required environment variables:
GOOGLE_APPLICATION_CREDENTIALS- Path to service account JSONANALYTICS_MCP_SUBJECT(optional) - User email for domain-wide delegation
Example Prompts
Once configured, you can interact with your Google Analytics data:
What are the most popular events in my Google Analytics property in the last 180 days?
Give me details about my Google Analytics property with 'xyz' in the name
What are the custom dimensions and custom metrics in my property?
Were most of my users in the last 6 months logged in?
Development
This server is maintained by Locomotive Agency as part of the MCP Anywhere ecosystem.
Original implementation by Google Analytics team. Enhanced with domain-wide delegation support for enterprise use cases.
License
Apache License 2.0 - See LICENSE file for details.
Contributing
Contributions welcome! See the Contributing Guide.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_analytics_mcp_python-0.1.3.tar.gz.
File metadata
- Download URL: google_analytics_mcp_python-0.1.3.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cf379a4470c2bab213be4e98cb2590b369bc0752d5ccca197830fa9066d0cd4
|
|
| MD5 |
f055935927910aa2957bf72f077b7341
|
|
| BLAKE2b-256 |
67d23a283d1522fb2465419ba6f087a88bcf3a09f803bf3b1cbfc6f05d2a1f35
|
Provenance
The following attestation bundles were made for google_analytics_mcp_python-0.1.3.tar.gz:
Publisher:
deploy.yml on locomotive-agency/google-analytics-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_analytics_mcp_python-0.1.3.tar.gz -
Subject digest:
6cf379a4470c2bab213be4e98cb2590b369bc0752d5ccca197830fa9066d0cd4 - Sigstore transparency entry: 612679902
- Sigstore integration time:
-
Permalink:
locomotive-agency/google-analytics-mcp@7ba9015974bfdf10aaf4a1462384f4fa16804afc -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/locomotive-agency
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@7ba9015974bfdf10aaf4a1462384f4fa16804afc -
Trigger Event:
release
-
Statement type:
File details
Details for the file google_analytics_mcp_python-0.1.3-py3-none-any.whl.
File metadata
- Download URL: google_analytics_mcp_python-0.1.3-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e2e510cb717e1fa05cb013e5e1c7f6e351ddb36591aba0e43415d4e9531bd2d
|
|
| MD5 |
6267d582ebfd1200a276215b89be6cb4
|
|
| BLAKE2b-256 |
c54e0654b3b4c1ff3f64c82a0573a3c0b1a8751c9a1ebf4bbc00bf552ea0a91e
|
Provenance
The following attestation bundles were made for google_analytics_mcp_python-0.1.3-py3-none-any.whl:
Publisher:
deploy.yml on locomotive-agency/google-analytics-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_analytics_mcp_python-0.1.3-py3-none-any.whl -
Subject digest:
1e2e510cb717e1fa05cb013e5e1c7f6e351ddb36591aba0e43415d4e9531bd2d - Sigstore transparency entry: 612679919
- Sigstore integration time:
-
Permalink:
locomotive-agency/google-analytics-mcp@7ba9015974bfdf10aaf4a1462384f4fa16804afc -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/locomotive-agency
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@7ba9015974bfdf10aaf4a1462384f4fa16804afc -
Trigger Event:
release
-
Statement type: