Skip to content

Commit 6598282

Browse files
committed
Merge branch 'main' of github.com:cagnusmarlsen/google-analytics-mcp
2 parents ff67fa5 + 7a569b5 commit 6598282

4 files changed

Lines changed: 80 additions & 49 deletions

File tree

CONTRIBUTING.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Replace `PATH_TO_REPO` in the following snippet with the path where you cloned
6565
the repo:
6666
6767
```
68-
"command": "PATH_TO_REPO/.venv/bin/google-analytics-mcp",
68+
"command": "PATH_TO_REPO/.venv/bin/analytics-mcp",
6969
```
7070
7171
When running the `gemini` command from a terminal, add the `--debug` option so
@@ -90,8 +90,12 @@ branch named `awesome-feature-42` in this repo:
9090
"--no-cache",
9191
"--spec",
9292
"git+https://github.com/googleanalytics/google-analytics-mcp.git@awesome-feature-42",
93-
"google-analytics-mcp"
94-
]
93+
"analytics-mcp"
94+
],
95+
"env": {
96+
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
97+
"GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
98+
}
9599
}
96100
}
97101
}

README.md

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Google Analytics MCP Server (Experimental)
22

3+
[![PyPI version](https://img.shields.io/pypi/v/analytics-mcp.svg)](https://pypi.org/project/analytics-mcp/)
4+
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
5+
[![GitHub branch check runs](https://img.shields.io/github/check-runs/googleanalytics/google-analytics-mcp/main)](https://github.com/googleanalytics/google-analytics-mcp/actions?query=branch%3Amain++)
6+
[![PyPI - Downloads](https://img.shields.io/pypi/dm/analytics-mcp)](https://pypi.org/project/analytics-mcp/)
7+
[![GitHub stars](https://img.shields.io/github/stars/googleanalytics/google-analytics-mcp?style=social)](https://github.com/googleanalytics/google-analytics-mcp/stargazers)
8+
[![GitHub forks](https://img.shields.io/github/forks/googleanalytics/google-analytics-mcp?style=social)](https://github.com/googleanalytics/google-analytics-mcp/network/members)
9+
[![YouTube Video Views](https://img.shields.io/youtube/views/PT4wGPxWiRQ)](https://www.youtube.com/watch?v=PT4wGPxWiRQ)
10+
311
This repo contains the source code for running a local
412
[MCP](https://modelcontextprotocol.io) server that interacts with APIs for
513
[Google Analytics](https://support.google.com/analytics).
614

715
Join the discussion and ask questions in the
8-
[:robot:-analytics-mcp channel](https://discord.com/channels/971845904002871346/1398002598665257060)
16+
[🤖-analytics-mcp channel](https://discord.com/channels/971845904002871346/1398002598665257060)
917
on Discord.
1018

11-
## Tools :hammer_and_wrench:
19+
## Tools 🛠️
1220

1321
The server uses the
1422
[Google Analytics Admin API](https://developers.google.com/analytics/devguides/config/admin/v1)
@@ -17,46 +25,46 @@ and
1725
to provide several
1826
[Tools](https://modelcontextprotocol.io/docs/concepts/tools) for use with LLMs.
1927

20-
### Retrieve account and property information :orange_circle:
28+
### Retrieve account and property information 🟠
2129

2230
- `get_account_summaries`: Retrieves information about the user's Google
2331
Analytics accounts and properties.
2432
- `get_property_details`: Returns details about a property.
2533
- `list_google_ads_links`: Returns a list of links to Google Ads accounts for
2634
a property.
2735

28-
### Run core reports :orange_book:
36+
### Run core reports 📙
2937

3038
- `run_report`: Runs a Google Analytics report using the Data API.
3139
- `get_custom_dimensions_and_metrics`: Retrieves the custom dimensions and
3240
metrics for a specific property.
3341

34-
### Run realtime reports :hourglass_flowing_sand:
42+
### Run realtime reports
3543

3644
- `run_realtime_report`: Runs a Google Analytics realtime report using the
3745
Data API.
3846

39-
## Setup instructions
47+
## Setup instructions 🔧
4048

4149
Setup involves the following steps:
4250

4351
1. Configure Python.
4452
1. Configure credentials for Google Analytics.
4553
1. Configure Gemini.
4654

47-
### Configure Python :snake:
55+
### Configure Python 🐍
4856

4957
[Install pipx](https://pipx.pypa.io/stable/#install-pipx).
5058

51-
### Enable APIs in your project :white_check_mark:
59+
### Enable APIs in your project
5260

5361
[Follow the instructions](https://support.google.com/googleapi/answer/6158841)
5462
to enable the following APIs in your Google Cloud project:
5563

5664
* [Google Analytics Admin API](https://console.cloud.google.com/apis/library/analyticsadmin.googleapis.com)
5765
* [Google Analytics Data API](https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com)
5866

59-
### Configure credentials :key:
67+
### Configure credentials 🔑
6068

6169
Configure your [Application Default Credentials
6270
(ADC)](https://cloud.google.com/docs/authentication/provide-credentials-adc).
@@ -92,41 +100,26 @@ Here are some sample `gcloud` commands you might find useful:
92100
--scopes=https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform
93101
```
94102

103+
When the `gcloud auth application-default` command completes, copy the
104+
`PATH_TO_CREDENTIALS_JSON` file location printed to the console in the
105+
following message. You'll need this for the next step!
106+
107+
```
108+
Credentials saved to file: [PATH_TO_CREDENTIALS_JSON]
109+
```
110+
95111
### Configure Gemini
96112

97113
1. Install [Gemini
98114
CLI](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/index.md)
99115
or [Gemini Code
100-
Assist](https://marketplace.visualstudio.com/items?itemName=Google.geminicodeassist)
116+
Assist](https://marketplace.visualstudio.com/items?itemName=Google.geminicodeassist).
101117

102118
1. Create or edit the file at `~/.gemini/settings.json`, adding your server
103119
to the `mcpServers` list.
104120

105-
```json
106-
{
107-
"mcpServers": {
108-
"analytics-mcp": {
109-
"command": "pipx",
110-
"args": [
111-
"run",
112-
"--spec",
113-
"git+https://github.com/googleanalytics/google-analytics-mcp.git",
114-
"google-analytics-mcp"
115-
]
116-
}
117-
}
118-
}
119-
```
120-
121-
1. **Optional:** Configure the `GOOGLE_APPLICATION_CREDENTIALS` environment
122-
variable in Gemini settings. You may want to do this if you always want to
123-
use a specific set of credentials, regardless of which Application Default
124-
Credentials are selected in your current environment.
125-
126-
In `~/.gemini/settings.json`, add a `GOOGLE_APPLICATION_CREDENTIALS`
127-
attribute to the `env` object. Replace `PATH_TO_ADC_JSON` in the following
128-
example with the full path to the ADC JSON file you always want to use for
129-
your MCP server.
121+
Replace `PATH_TO_CREDENTIALS_JSON` with the path you copied in the previous
122+
step.
130123

131124
We also recommend that you add a `GOOGLE_CLOUD_PROJECT` attribute to the
132125
`env` object. Replace `YOUR_PROJECT_ID` in the following example with the
@@ -140,20 +133,18 @@ Here are some sample `gcloud` commands you might find useful:
140133
"command": "pipx",
141134
"args": [
142135
"run",
143-
"--spec",
144-
"git+https://github.com/googleanalytics/google-analytics-mcp.git",
145-
"google-analytics-mcp"
136+
"analytics-mcp"
146137
],
147138
"env": {
148-
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_ADC_JSON",
149-
"GOOGLE_CLOUD_PROJECT": "YOUR_PROJECT_ID"
139+
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
140+
"GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
150141
}
151142
}
152143
}
153144
}
154145
```
155146

156-
## Try it out :lab_coat:
147+
## Try it out 🥼
157148

158149
Launch Gemini Code Assist or Gemini CLI and type `/mcp`. You should see
159150
`analytics-mcp` listed in the results.
@@ -190,6 +181,6 @@ Here are some sample prompts to get you started:
190181
what are the custom dimensions and custom metrics in my property?
191182
```
192183
193-
## Contributing
184+
## Contributing
194185
195186
Contributions welcome! See the [Contributing Guide](CONTRIBUTING.md).

analytics_mcp/tools/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _get_package_version_with_fallback():
3131
Falls back to 'unknown' if the version can't be resolved.
3232
"""
3333
try:
34-
return metadata.version("google-analytics-mcp")
34+
return metadata.version("analytics-mcp")
3535
except:
3636
return "unknown"
3737

pyproject.toml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
11
[project]
2-
name = "google-analytics-mcp"
3-
version = "0.1.0"
2+
name = "analytics-mcp"
3+
description = "MCP server for Google Analytics"
4+
version = "0.1.1"
45
# Lower bound of 3.10 due to the 'mcp' dependency:
56
# https://github.com/modelcontextprotocol/python-sdk/blob/main/pyproject.toml
6-
requires-python = ">=3.10, <3.14"
7+
requires-python = ">=3.10"
78
license = "Apache-2.0"
9+
readme = "README.md"
810
dependencies = [
911
"google-analytics-data==0.18.19",
1012
"google-analytics-admin==0.24.1",
1113
"google-auth~=2.40",
1214
"mcp[cli]>=1.2.0",
1315
"httpx>=0.28.1"
1416
]
17+
keywords = [
18+
"google analytics",
19+
"analytics",
20+
"mcp",
21+
"ga4"
22+
]
23+
classifiers = [
24+
"Development Status :: 4 - Beta",
25+
"Intended Audience :: Developers",
26+
"Intended Audience :: End Users/Desktop",
27+
"Programming Language :: Python",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Programming Language :: Python :: 3.13",
32+
"Operating System :: OS Independent",
33+
"Topic :: Internet",
34+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
35+
"Topic :: Scientific/Engineering :: Information Analysis"
36+
]
37+
authors = [
38+
{ name = "Josh Radcliff", email = "jradcliff@users.noreply.github.com" },
39+
{ name = "Matt Landers", email = "matt-landers@users.noreply.github.com" }
40+
]
41+
42+
[project.urls]
43+
homepage = "https://github.com/googleanalytics/google-analytics-mcp"
44+
repository = "https://github.com/googleanalytics/google-analytics-mcp.git"
45+
issues = "https://github.com/googleanalytics/google-analytics-mcp/issues"
1546

1647
[project.scripts]
48+
analytics-mcp = "analytics_mcp.server:run_server"
49+
# The previous name of the script. Kept for backwards compatibility.
1750
google-analytics-mcp = "analytics_mcp.server:run_server"
1851

1952
[project.optional-dependencies]
@@ -22,3 +55,6 @@ dev = [
2255
"nox >=2025.5.1, <2026"
2356
]
2457

58+
[build-system]
59+
requires = ["setuptools>=69.0.0", "wheel"]
60+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)