ga-mcp-full 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ga_mcp_full-0.3.0/PKG-INFO +225 -0
- ga_mcp_full-0.3.0/README.md +193 -0
- ga_mcp_full-0.3.0/ga_mcp/__init__.py +0 -0
- ga_mcp_full-0.3.0/ga_mcp/auth.py +376 -0
- ga_mcp_full-0.3.0/ga_mcp/cli.py +96 -0
- ga_mcp_full-0.3.0/ga_mcp/coordinator.py +247 -0
- ga_mcp_full-0.3.0/ga_mcp/server.py +47 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/__init__.py +0 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/__init__.py +0 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/audiences.py +100 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/bigquery_links.py +89 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/custom_definitions.py +265 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/data_streams.py +136 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/firebase_links.py +72 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/google_ads_links.py +95 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/info.py +69 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/key_events.py +136 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/measurement_protocol.py +113 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/admin/properties.py +144 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/reporting/__init__.py +0 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/reporting/core.py +105 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/reporting/metadata.py +78 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/reporting/realtime.py +92 -0
- ga_mcp_full-0.3.0/ga_mcp/tools/utils.py +222 -0
- ga_mcp_full-0.3.0/ga_mcp_full.egg-info/PKG-INFO +225 -0
- ga_mcp_full-0.3.0/ga_mcp_full.egg-info/SOURCES.txt +30 -0
- ga_mcp_full-0.3.0/ga_mcp_full.egg-info/dependency_links.txt +1 -0
- ga_mcp_full-0.3.0/ga_mcp_full.egg-info/entry_points.txt +2 -0
- ga_mcp_full-0.3.0/ga_mcp_full.egg-info/requires.txt +7 -0
- ga_mcp_full-0.3.0/ga_mcp_full.egg-info/top_level.txt +1 -0
- ga_mcp_full-0.3.0/pyproject.toml +48 -0
- ga_mcp_full-0.3.0/setup.cfg +4 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ga-mcp-full
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: GA4 MCP server with full Admin API read/write access
|
|
5
|
+
Author: Ryan Robson
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ringo380/ga-mcp-full
|
|
8
|
+
Project-URL: Repository, https://github.com/ringo380/ga-mcp-full
|
|
9
|
+
Project-URL: Issues, https://github.com/ringo380/ga-mcp-full/issues
|
|
10
|
+
Project-URL: Privacy Policy, https://github.com/ringo380/ga-mcp-full/blob/main/PRIVACY.md
|
|
11
|
+
Keywords: google-analytics,ga4,mcp,claude-code,analytics
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: google-analytics-data==0.20.0
|
|
26
|
+
Requires-Dist: google-analytics-admin==0.27.0
|
|
27
|
+
Requires-Dist: google-auth~=2.40
|
|
28
|
+
Requires-Dist: google-auth-oauthlib~=1.2
|
|
29
|
+
Requires-Dist: mcp>=1.24.0
|
|
30
|
+
Requires-Dist: google-adk>=1.24.1
|
|
31
|
+
Requires-Dist: httpx>=0.28.1
|
|
32
|
+
|
|
33
|
+
# ga-mcp-full
|
|
34
|
+
|
|
35
|
+
A [Model Context Protocol](https://modelcontextprotocol.io/) server that exposes the **full** Google Analytics 4 surface — both the Admin API (property & configuration management) and the Data API (reporting) — to MCP-compatible clients such as [Claude Code](https://claude.com/product/claude-code), [Claude Desktop](https://claude.ai/download), Cursor, Zed, and anything else that speaks stdio MCP.
|
|
36
|
+
|
|
37
|
+
Thirty-plus tools cover:
|
|
38
|
+
|
|
39
|
+
- **Property management** — create, list, update, delete, archive, retention settings
|
|
40
|
+
- **Custom dimensions & metrics** — create, list, update, archive
|
|
41
|
+
- **Audiences** — create, list, archive
|
|
42
|
+
- **Key events** — CRUD
|
|
43
|
+
- **Data streams** — CRUD
|
|
44
|
+
- **Linked accounts** — Firebase, BigQuery, Google Ads
|
|
45
|
+
- **Measurement Protocol secrets** — CRUD
|
|
46
|
+
- **Reporting** — standard reports, realtime reports, metadata discovery
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
The preferred install is via the **Robworks Claude Code Plugins** marketplace:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install ga-mcp-full # once published to PyPI; for now use: pip install -e /path/to/ga-mcp-full
|
|
54
|
+
claude plugin marketplace add ringo380/robworks-claude-code-plugins
|
|
55
|
+
claude plugin install ga-mcp-full@robworks-claude-code-plugins
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Why a two-step install: the plugin just wraps the Python CLI — it does not bundle the Python interpreter. You install the CLI once (`pip`), then the plugin registers the MCP server, slash commands, and SessionStart hook with Claude Code.
|
|
59
|
+
|
|
60
|
+
### Alternative: direct from the plugin repo
|
|
61
|
+
|
|
62
|
+
If you prefer to install the plugin directly from this repo without going through the Robworks marketplace:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install -e /path/to/ga-mcp-full
|
|
66
|
+
claude plugin marketplace add ringo380/ga-mcp-full # uses the plugin repo as its own marketplace (once marketplace.json is added here)
|
|
67
|
+
claude plugin install ga-mcp-full
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
> Note: this repo currently only ships a `plugin.json`, not a `marketplace.json`. Use the Robworks marketplace above as the install path.
|
|
71
|
+
|
|
72
|
+
### Alternative: standalone MCP (no Claude Code plugin)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install -e /path/to/ga-mcp-full
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then add to your MCP client config. Example for Claude Desktop (`claude_desktop_config.json`):
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"ga-mcp-full": {
|
|
84
|
+
"command": "ga-mcp-full",
|
|
85
|
+
"args": ["serve"]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For Cursor, Zed, or other clients, consult their MCP integration docs — the server command and arg pair is always `ga-mcp-full serve`.
|
|
92
|
+
|
|
93
|
+
## Requirements
|
|
94
|
+
|
|
95
|
+
- Python 3.10 or newer
|
|
96
|
+
- Google Analytics 4 property you have **Editor** or **Administrator** access to (the scope requested is `analytics.edit`)
|
|
97
|
+
|
|
98
|
+
That's it — no Google Cloud Console visit needed for the default install. A public Desktop OAuth client is bundled with the package.
|
|
99
|
+
|
|
100
|
+
## Authentication
|
|
101
|
+
|
|
102
|
+
The server resolves credentials in this order (see `ga_mcp/auth.py`):
|
|
103
|
+
|
|
104
|
+
1. **Cached OAuth tokens** at `~/.config/ga-mcp/credentials.json`. Refresh tokens renew expired access tokens silently.
|
|
105
|
+
2. **Application Default Credentials** — from `gcloud auth application-default login`.
|
|
106
|
+
3. **Fresh OAuth browser flow** — using `GA_MCP_CLIENT_ID` + `GA_MCP_CLIENT_SECRET` env vars, `~/.config/ga-mcp/client_secrets.json`, or the bundled public Desktop client (in that order).
|
|
107
|
+
|
|
108
|
+
### First-time setup (majority path)
|
|
109
|
+
|
|
110
|
+
1. Install: `pip install ga-mcp-full` (or `pip install -e .` for a dev checkout).
|
|
111
|
+
2. Run `/ga-mcp-full:auth-login` in Claude Code (or `ga-mcp-full auth login` at the shell).
|
|
112
|
+
3. Approve the `analytics.edit` scope when the browser opens.
|
|
113
|
+
4. The refresh token lands in `~/.config/ga-mcp/credentials.json` (mode `0600`).
|
|
114
|
+
|
|
115
|
+
The OAuth flow uses PKCE (S256) and binds the loopback redirect to a random free port on `127.0.0.1`, per Google's installed-app OAuth guidance. No prior Google Cloud Console client configuration is required.
|
|
116
|
+
|
|
117
|
+
#### You'll see an "unverified app" warning — this is expected for now
|
|
118
|
+
|
|
119
|
+
The bundled OAuth client is a real production app owned by this project, but Google's brand verification for sensitive scopes (like `analytics.edit`) takes several business days the first time. Until verification clears, the consent screen displays:
|
|
120
|
+
|
|
121
|
+
> Google hasn't verified this app
|
|
122
|
+
> The app is requesting access to sensitive info in your Google Account…
|
|
123
|
+
|
|
124
|
+
To proceed: click **Advanced** → **Go to ga-mcp-full (unsafe)**. The warning is Google's default posture for unverified apps — it doesn't indicate anything is actually wrong with the tool. Review the [privacy policy](./PRIVACY.md) if you want to know exactly what data is accessed (it's all local, per-user, per the scope you approved). The warning will disappear once Google's review completes.
|
|
125
|
+
|
|
126
|
+
Users who want to avoid the warning entirely can use their own OAuth client — see **Power users** below.
|
|
127
|
+
|
|
128
|
+
### Power users: use your own OAuth client
|
|
129
|
+
|
|
130
|
+
If you want quota isolation, a custom consent screen, or to avoid the verification-window warning:
|
|
131
|
+
|
|
132
|
+
1. Create an **OAuth 2.0 Client ID** of type **Desktop app** at **Google Cloud Console → APIs & Services → Credentials** in a project where the Google Analytics Admin API and Data API are enabled.
|
|
133
|
+
2. Override the bundled defaults via either:
|
|
134
|
+
- Env vars in your shell profile: `GA_MCP_CLIENT_ID=...` and `GA_MCP_CLIENT_SECRET=...`
|
|
135
|
+
- Or drop the downloaded JSON at `~/.config/ga-mcp/client_secrets.json` (mode `0600`).
|
|
136
|
+
3. Run `ga-mcp-full auth login` as usual — the env vars / legacy JSON take precedence over the bundled client.
|
|
137
|
+
|
|
138
|
+
### Already using `gcloud`?
|
|
139
|
+
|
|
140
|
+
If you have `gcloud auth application-default login --scopes=https://www.googleapis.com/auth/analytics.edit` configured, the server auto-detects ADC and skips OAuth entirely. No further setup needed.
|
|
141
|
+
|
|
142
|
+
### Why not the `/mcp` Authenticate button?
|
|
143
|
+
|
|
144
|
+
Claude Code's `/mcp` menu OAuth flow only applies to **HTTP-transport** MCP servers per the MCP 2025-06-18 authorization spec (stdio servers "SHOULD NOT" use it). `ga-mcp-full` is stdio, so auth is handled out-of-band via the bundled slash commands and the SessionStart hook. An HTTP transport mode that participates in the `/mcp` OAuth flow is a possible future addition.
|
|
145
|
+
|
|
146
|
+
## Bundled Claude Code components
|
|
147
|
+
|
|
148
|
+
### Slash commands
|
|
149
|
+
|
|
150
|
+
| Command | Purpose |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `/ga-mcp-full:setup` | Guided first-run — install the CLI (if needed) and run the browser login |
|
|
153
|
+
| `/ga-mcp-full:auth-login` | Run the OAuth browser flow and cache tokens |
|
|
154
|
+
| `/ga-mcp-full:auth-logout` | Remove cached OAuth credentials |
|
|
155
|
+
| `/ga-mcp-full:auth-status` | Show current auth state and credential source |
|
|
156
|
+
|
|
157
|
+
### SessionStart hook
|
|
158
|
+
|
|
159
|
+
`hooks/scripts/ensure-auth.sh` runs at the start of every Claude Code session (`startup|resume|clear|compact`). It is non-blocking and only writes to stderr — if authentication is missing, it prints a one-line hint pointing at `/ga-mcp-full:setup`; it never exits non-zero and never blocks the session.
|
|
160
|
+
|
|
161
|
+
### MCP tools
|
|
162
|
+
|
|
163
|
+
After plugin install the server registers as `plugin:ga-mcp-full:ga-mcp-full` and tools surface as `mcp__ga-mcp-full__*`. Browse them with `/mcp` inside Claude Code.
|
|
164
|
+
|
|
165
|
+
## CLI reference
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
ga-mcp-full # Start the MCP server over stdio
|
|
169
|
+
ga-mcp-full serve # Same as above (explicit)
|
|
170
|
+
ga-mcp-full auth login # OAuth browser flow; caches refresh token
|
|
171
|
+
ga-mcp-full auth logout # Clear cached credentials
|
|
172
|
+
ga-mcp-full auth status # Show current auth state and credential source
|
|
173
|
+
ga-mcp-full --help # Full help
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Development
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
git clone https://github.com/ringo380/ga-mcp-full.git
|
|
180
|
+
cd ga-mcp-full
|
|
181
|
+
python -m venv .venv && source .venv/bin/activate
|
|
182
|
+
pip install -e .
|
|
183
|
+
ga-mcp-full auth status
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Project layout:
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
ga_mcp/
|
|
190
|
+
├── server.py # MCP server entrypoint
|
|
191
|
+
├── cli.py # CLI dispatcher
|
|
192
|
+
├── auth.py # OAuth + credential resolution
|
|
193
|
+
└── tools/
|
|
194
|
+
├── admin/ # 11 modules — property, custom dimensions/metrics, audiences, etc.
|
|
195
|
+
├── reporting/ # 3 modules — core, realtime, metadata
|
|
196
|
+
└── utils.py
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Public Claude Code artifacts: `.claude-plugin/plugin.json`, `.mcp.json`, `commands/`, `hooks/`.
|
|
200
|
+
|
|
201
|
+
Issues and PRs welcome at https://github.com/ringo380/ga-mcp-full/issues.
|
|
202
|
+
|
|
203
|
+
## Troubleshooting
|
|
204
|
+
|
|
205
|
+
| Symptom | Fix |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| "Google hasn't verified this app" on the consent screen | Expected during brand verification. Click **Advanced** → **Go to ga-mcp-full**. Or set up your own OAuth client (see README "Power users") |
|
|
208
|
+
| `GA auth required: run /ga-mcp-full:auth-login in Claude Code, then retry.` | The cached refresh token is missing or revoked. Rerun the slash command — it's the entire fix |
|
|
209
|
+
| OAuth browser window shows "access_denied" during login | Your Google account doesn't have Editor/Admin on any GA4 property. Grant access in **GA4 → Admin → Account/Property Access Management** |
|
|
210
|
+
| Token refresh failed | `ga-mcp-full auth logout && ga-mcp-full auth login` |
|
|
211
|
+
| `/mcp` shows the server but no tools | Confirm `ga-mcp-full auth status` reports authenticated; tools are gated behind a working Analytics API client |
|
|
212
|
+
| Claude Code doesn't see the plugin | `claude plugin list` — confirm `ga-mcp-full@robworks-claude-code-plugins` is installed and enabled. Restart the session if you just enabled it |
|
|
213
|
+
| "insufficientPermissions" errors on Admin API writes | Verify your Google account has Editor/Admin role on the target GA4 property |
|
|
214
|
+
|
|
215
|
+
## Related
|
|
216
|
+
|
|
217
|
+
- [Robworks Claude Code Plugins marketplace](https://github.com/ringo380/robworks-claude-code-plugins) — catalogs this plugin alongside future plugins from `@ringo380`
|
|
218
|
+
- [Claude Code plugin docs](https://code.claude.com/docs/en/plugins)
|
|
219
|
+
- [MCP specification](https://modelcontextprotocol.io/)
|
|
220
|
+
- [Google Analytics Admin API](https://developers.google.com/analytics/devguides/config/admin/v1)
|
|
221
|
+
- [Google Analytics Data API](https://developers.google.com/analytics/devguides/reporting/data/v1)
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT — see [LICENSE](./LICENSE) (once added).
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# ga-mcp-full
|
|
2
|
+
|
|
3
|
+
A [Model Context Protocol](https://modelcontextprotocol.io/) server that exposes the **full** Google Analytics 4 surface — both the Admin API (property & configuration management) and the Data API (reporting) — to MCP-compatible clients such as [Claude Code](https://claude.com/product/claude-code), [Claude Desktop](https://claude.ai/download), Cursor, Zed, and anything else that speaks stdio MCP.
|
|
4
|
+
|
|
5
|
+
Thirty-plus tools cover:
|
|
6
|
+
|
|
7
|
+
- **Property management** — create, list, update, delete, archive, retention settings
|
|
8
|
+
- **Custom dimensions & metrics** — create, list, update, archive
|
|
9
|
+
- **Audiences** — create, list, archive
|
|
10
|
+
- **Key events** — CRUD
|
|
11
|
+
- **Data streams** — CRUD
|
|
12
|
+
- **Linked accounts** — Firebase, BigQuery, Google Ads
|
|
13
|
+
- **Measurement Protocol secrets** — CRUD
|
|
14
|
+
- **Reporting** — standard reports, realtime reports, metadata discovery
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
The preferred install is via the **Robworks Claude Code Plugins** marketplace:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install ga-mcp-full # once published to PyPI; for now use: pip install -e /path/to/ga-mcp-full
|
|
22
|
+
claude plugin marketplace add ringo380/robworks-claude-code-plugins
|
|
23
|
+
claude plugin install ga-mcp-full@robworks-claude-code-plugins
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Why a two-step install: the plugin just wraps the Python CLI — it does not bundle the Python interpreter. You install the CLI once (`pip`), then the plugin registers the MCP server, slash commands, and SessionStart hook with Claude Code.
|
|
27
|
+
|
|
28
|
+
### Alternative: direct from the plugin repo
|
|
29
|
+
|
|
30
|
+
If you prefer to install the plugin directly from this repo without going through the Robworks marketplace:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install -e /path/to/ga-mcp-full
|
|
34
|
+
claude plugin marketplace add ringo380/ga-mcp-full # uses the plugin repo as its own marketplace (once marketplace.json is added here)
|
|
35
|
+
claude plugin install ga-mcp-full
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> Note: this repo currently only ships a `plugin.json`, not a `marketplace.json`. Use the Robworks marketplace above as the install path.
|
|
39
|
+
|
|
40
|
+
### Alternative: standalone MCP (no Claude Code plugin)
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install -e /path/to/ga-mcp-full
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then add to your MCP client config. Example for Claude Desktop (`claude_desktop_config.json`):
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"ga-mcp-full": {
|
|
52
|
+
"command": "ga-mcp-full",
|
|
53
|
+
"args": ["serve"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For Cursor, Zed, or other clients, consult their MCP integration docs — the server command and arg pair is always `ga-mcp-full serve`.
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- Python 3.10 or newer
|
|
64
|
+
- Google Analytics 4 property you have **Editor** or **Administrator** access to (the scope requested is `analytics.edit`)
|
|
65
|
+
|
|
66
|
+
That's it — no Google Cloud Console visit needed for the default install. A public Desktop OAuth client is bundled with the package.
|
|
67
|
+
|
|
68
|
+
## Authentication
|
|
69
|
+
|
|
70
|
+
The server resolves credentials in this order (see `ga_mcp/auth.py`):
|
|
71
|
+
|
|
72
|
+
1. **Cached OAuth tokens** at `~/.config/ga-mcp/credentials.json`. Refresh tokens renew expired access tokens silently.
|
|
73
|
+
2. **Application Default Credentials** — from `gcloud auth application-default login`.
|
|
74
|
+
3. **Fresh OAuth browser flow** — using `GA_MCP_CLIENT_ID` + `GA_MCP_CLIENT_SECRET` env vars, `~/.config/ga-mcp/client_secrets.json`, or the bundled public Desktop client (in that order).
|
|
75
|
+
|
|
76
|
+
### First-time setup (majority path)
|
|
77
|
+
|
|
78
|
+
1. Install: `pip install ga-mcp-full` (or `pip install -e .` for a dev checkout).
|
|
79
|
+
2. Run `/ga-mcp-full:auth-login` in Claude Code (or `ga-mcp-full auth login` at the shell).
|
|
80
|
+
3. Approve the `analytics.edit` scope when the browser opens.
|
|
81
|
+
4. The refresh token lands in `~/.config/ga-mcp/credentials.json` (mode `0600`).
|
|
82
|
+
|
|
83
|
+
The OAuth flow uses PKCE (S256) and binds the loopback redirect to a random free port on `127.0.0.1`, per Google's installed-app OAuth guidance. No prior Google Cloud Console client configuration is required.
|
|
84
|
+
|
|
85
|
+
#### You'll see an "unverified app" warning — this is expected for now
|
|
86
|
+
|
|
87
|
+
The bundled OAuth client is a real production app owned by this project, but Google's brand verification for sensitive scopes (like `analytics.edit`) takes several business days the first time. Until verification clears, the consent screen displays:
|
|
88
|
+
|
|
89
|
+
> Google hasn't verified this app
|
|
90
|
+
> The app is requesting access to sensitive info in your Google Account…
|
|
91
|
+
|
|
92
|
+
To proceed: click **Advanced** → **Go to ga-mcp-full (unsafe)**. The warning is Google's default posture for unverified apps — it doesn't indicate anything is actually wrong with the tool. Review the [privacy policy](./PRIVACY.md) if you want to know exactly what data is accessed (it's all local, per-user, per the scope you approved). The warning will disappear once Google's review completes.
|
|
93
|
+
|
|
94
|
+
Users who want to avoid the warning entirely can use their own OAuth client — see **Power users** below.
|
|
95
|
+
|
|
96
|
+
### Power users: use your own OAuth client
|
|
97
|
+
|
|
98
|
+
If you want quota isolation, a custom consent screen, or to avoid the verification-window warning:
|
|
99
|
+
|
|
100
|
+
1. Create an **OAuth 2.0 Client ID** of type **Desktop app** at **Google Cloud Console → APIs & Services → Credentials** in a project where the Google Analytics Admin API and Data API are enabled.
|
|
101
|
+
2. Override the bundled defaults via either:
|
|
102
|
+
- Env vars in your shell profile: `GA_MCP_CLIENT_ID=...` and `GA_MCP_CLIENT_SECRET=...`
|
|
103
|
+
- Or drop the downloaded JSON at `~/.config/ga-mcp/client_secrets.json` (mode `0600`).
|
|
104
|
+
3. Run `ga-mcp-full auth login` as usual — the env vars / legacy JSON take precedence over the bundled client.
|
|
105
|
+
|
|
106
|
+
### Already using `gcloud`?
|
|
107
|
+
|
|
108
|
+
If you have `gcloud auth application-default login --scopes=https://www.googleapis.com/auth/analytics.edit` configured, the server auto-detects ADC and skips OAuth entirely. No further setup needed.
|
|
109
|
+
|
|
110
|
+
### Why not the `/mcp` Authenticate button?
|
|
111
|
+
|
|
112
|
+
Claude Code's `/mcp` menu OAuth flow only applies to **HTTP-transport** MCP servers per the MCP 2025-06-18 authorization spec (stdio servers "SHOULD NOT" use it). `ga-mcp-full` is stdio, so auth is handled out-of-band via the bundled slash commands and the SessionStart hook. An HTTP transport mode that participates in the `/mcp` OAuth flow is a possible future addition.
|
|
113
|
+
|
|
114
|
+
## Bundled Claude Code components
|
|
115
|
+
|
|
116
|
+
### Slash commands
|
|
117
|
+
|
|
118
|
+
| Command | Purpose |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `/ga-mcp-full:setup` | Guided first-run — install the CLI (if needed) and run the browser login |
|
|
121
|
+
| `/ga-mcp-full:auth-login` | Run the OAuth browser flow and cache tokens |
|
|
122
|
+
| `/ga-mcp-full:auth-logout` | Remove cached OAuth credentials |
|
|
123
|
+
| `/ga-mcp-full:auth-status` | Show current auth state and credential source |
|
|
124
|
+
|
|
125
|
+
### SessionStart hook
|
|
126
|
+
|
|
127
|
+
`hooks/scripts/ensure-auth.sh` runs at the start of every Claude Code session (`startup|resume|clear|compact`). It is non-blocking and only writes to stderr — if authentication is missing, it prints a one-line hint pointing at `/ga-mcp-full:setup`; it never exits non-zero and never blocks the session.
|
|
128
|
+
|
|
129
|
+
### MCP tools
|
|
130
|
+
|
|
131
|
+
After plugin install the server registers as `plugin:ga-mcp-full:ga-mcp-full` and tools surface as `mcp__ga-mcp-full__*`. Browse them with `/mcp` inside Claude Code.
|
|
132
|
+
|
|
133
|
+
## CLI reference
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
ga-mcp-full # Start the MCP server over stdio
|
|
137
|
+
ga-mcp-full serve # Same as above (explicit)
|
|
138
|
+
ga-mcp-full auth login # OAuth browser flow; caches refresh token
|
|
139
|
+
ga-mcp-full auth logout # Clear cached credentials
|
|
140
|
+
ga-mcp-full auth status # Show current auth state and credential source
|
|
141
|
+
ga-mcp-full --help # Full help
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Development
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
git clone https://github.com/ringo380/ga-mcp-full.git
|
|
148
|
+
cd ga-mcp-full
|
|
149
|
+
python -m venv .venv && source .venv/bin/activate
|
|
150
|
+
pip install -e .
|
|
151
|
+
ga-mcp-full auth status
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Project layout:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
ga_mcp/
|
|
158
|
+
├── server.py # MCP server entrypoint
|
|
159
|
+
├── cli.py # CLI dispatcher
|
|
160
|
+
├── auth.py # OAuth + credential resolution
|
|
161
|
+
└── tools/
|
|
162
|
+
├── admin/ # 11 modules — property, custom dimensions/metrics, audiences, etc.
|
|
163
|
+
├── reporting/ # 3 modules — core, realtime, metadata
|
|
164
|
+
└── utils.py
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Public Claude Code artifacts: `.claude-plugin/plugin.json`, `.mcp.json`, `commands/`, `hooks/`.
|
|
168
|
+
|
|
169
|
+
Issues and PRs welcome at https://github.com/ringo380/ga-mcp-full/issues.
|
|
170
|
+
|
|
171
|
+
## Troubleshooting
|
|
172
|
+
|
|
173
|
+
| Symptom | Fix |
|
|
174
|
+
| --- | --- |
|
|
175
|
+
| "Google hasn't verified this app" on the consent screen | Expected during brand verification. Click **Advanced** → **Go to ga-mcp-full**. Or set up your own OAuth client (see README "Power users") |
|
|
176
|
+
| `GA auth required: run /ga-mcp-full:auth-login in Claude Code, then retry.` | The cached refresh token is missing or revoked. Rerun the slash command — it's the entire fix |
|
|
177
|
+
| OAuth browser window shows "access_denied" during login | Your Google account doesn't have Editor/Admin on any GA4 property. Grant access in **GA4 → Admin → Account/Property Access Management** |
|
|
178
|
+
| Token refresh failed | `ga-mcp-full auth logout && ga-mcp-full auth login` |
|
|
179
|
+
| `/mcp` shows the server but no tools | Confirm `ga-mcp-full auth status` reports authenticated; tools are gated behind a working Analytics API client |
|
|
180
|
+
| Claude Code doesn't see the plugin | `claude plugin list` — confirm `ga-mcp-full@robworks-claude-code-plugins` is installed and enabled. Restart the session if you just enabled it |
|
|
181
|
+
| "insufficientPermissions" errors on Admin API writes | Verify your Google account has Editor/Admin role on the target GA4 property |
|
|
182
|
+
|
|
183
|
+
## Related
|
|
184
|
+
|
|
185
|
+
- [Robworks Claude Code Plugins marketplace](https://github.com/ringo380/robworks-claude-code-plugins) — catalogs this plugin alongside future plugins from `@ringo380`
|
|
186
|
+
- [Claude Code plugin docs](https://code.claude.com/docs/en/plugins)
|
|
187
|
+
- [MCP specification](https://modelcontextprotocol.io/)
|
|
188
|
+
- [Google Analytics Admin API](https://developers.google.com/analytics/devguides/config/admin/v1)
|
|
189
|
+
- [Google Analytics Data API](https://developers.google.com/analytics/devguides/reporting/data/v1)
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT — see [LICENSE](./LICENSE) (once added).
|
|
File without changes
|