samarth-analytics-mcp
MCP server for Samarth Analytics Google Tag Manager operations
Install / Use
claude mcp add samarthanalytics-sj -- npx -y github:samarthanalytics-sj/samarth-analytics-mcpIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
Data & AnalyticsSupported Platforms
Tags
Our assessment of samarth-analytics-mcp
samarth-analytics-mcp scores 80/100 on our quality scale, 532nd of 597 Data & Analytics skills we index.
Its MCP Server is 38 KB long, well organised into 68 sections with 17 code examples: a thorough specification that gives an agent plenty to work with.
It has 3 GitHub stars, so there is little community track record yet; judge it on its content.
Maintenance, license and trust
- The repository was last updated today, so samarth-analytics-mcp is actively maintained.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 87/100, with 2 cautions from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
samarth-analytics-mcp compared with similar skills
All 4 of these similar skills score higher than samarth-analytics-mcp; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| samarth-analytics-mcp (this skill)by samarthanalytics-sj | 80 | 3 | today | MCP Server |
| Agent-Reachby Panniantong | 100 | 108.0k | 1d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 78.7k | today | CLAUDE.md |
| CowAgentby zhayujie | 100 | 47.8k | today | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 92.8k | today | MCP Server |
Frequently asked questions
- How do I install samarth-analytics-mcp?
- Run
claude mcp add samarthanalytics-sj -- npx -y github:samarthanalytics-sj/samarth-analytics-mcp. The install tabs above show the steps for each supported agent. - Which AI agents does samarth-analytics-mcp work with?
- It is written for Claude Code and Claude Desktop, as a MCP Server file. Other agents that read the same format can often use it too.
- Is samarth-analytics-mcp safe to use?
- It is MIT-licensed and scores 87/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is samarth-analytics-mcp still maintained?
- The repository was last updated today, so samarth-analytics-mcp is actively maintained.
Skill content
View source on GitHubSamarth Analytics MCP
An open-source Model Context Protocol (MCP) server that lets AI assistants such as Claude Desktop, Claude Code and Cursor work with Google Tag Manager and GA4. It covers the full GTM API v2 surface (100+ tools, including server-side containers), the GA4 Admin and Data APIs, a built-in implementation audit, and a second server that crawls a website to check its tags and Consent Mode v2 setup. Built by Samarth Analytics for our own client work and released under the MIT license for the analytics community.
Read-only by default. Creating, updating, publishing and deleting are each behind a separate environment flag, every write also requires confirm=true, and a dry-run mode simulates writes without touching the API. See Guardrails.
Use it at your own risk, and start on a dummy container. The server acts with your Google credentials, so every change it makes is yours. Try it first on a sandbox GTM container and a test GA4 property, keep the write flags off until you have watched how it behaves, and review the container's version history after any write session. We run it in production, but your setup is not ours.
Three ways to use it
| | What you get | Where to start |
|---|---|---|
| Hosted, no install | Our community instance at https://mcp.samarthanalytics.com/mcp. Sign in with your own Google account; it only sees your containers and properties, and it is locked to read-only. Shared, best-effort, no uptime promise. | Add it to your MCP client with mcp-remote:<br>{"mcpServers":{"samarth-gtm":{"command":"npx","args":["mcp-remote@next","https://mcp.samarthanalytics.com/mcp"]}}} |
| Local | The server on your machine over stdio, with your own Google OAuth client, and the write flags under your control. | Quick Start and Google Cloud OAuth Setup |
| Self-hosted | The MCP server, the web-audit server and the capture worker as one docker-compose stack behind your own token. | docs/SELF_HOSTING_DOCKER.md and Cloud Deployment |
The repo also ships Samarth Desktop, a local Electron app with a chat UI that embeds this server (Quick Start), and a browser-based customer portal in apps/portal/ that runs live, read-only QC audits.
Contributions are welcome. Bug reports with a reproducible container setup are the most useful thing you can send. Read CONTRIBUTING.md first; CI runs on every pull request.
Table of Contents
- Features
- Quick Start
- Google Cloud OAuth Setup
- Service Account Limitations
- Environment Variables Reference
- Guardrails
- Available Tools
- Cloud Deployment
- Security Notes
- Development
- Releases
- Troubleshooting
Features
- Full GTM API v2 surface — accounts, containers, workspaces, tags, triggers, variables, folders, built-in variables, versions, sync, publish, preview
- Server-side & advanced GTM coverage — environments, user permissions, destinations, clients, transformations, zones, custom templates, gtag config, plus container snippet/lookup/combine/move-tag-id and workspace change-diff status
- GA4 coverage — GA4 Admin tools (
ga4_*) plus GA4 Data API reporting (ga4_run_report,ga4_run_realtime_report) for intent-vs-reality reconciliation. Reads and reporting need onlyanalytics.readonly; the GA4 Admin write tools are off by default behindGA4_MCP_ENABLE_WRITES/GA4_MCP_ENABLE_DELETESand additionally needanalytics.edit - Automatic pagination — every paginated list tool transparently follows
nextPageTokento return all results, with optionalmaxPages/pageTokenbounds - Retry with exponential backoff + jitter — transient Google API failures (HTTP 408/429/5xx, network errors) on read requests are retried automatically; mutations are never auto-retried (tunable via
GTM_MCP_RETRY_*) - Two transport modes: stdio (local, for Claude Desktop/Cursor) and Streamable HTTP (cloud/team)
- Guardrails by default: read-only unless explicitly enabled; publish and delete gated separately
- Dry-run mode: simulate all writes without touching the API
confirm=truerequired on all write/delete/publish operations- Audit tool: inspects workspace for common GA4/GTM implementation issues
- Export tool: full workspace dump as structured JSON
- Zod schema validation on all inputs
- Detailed Google API error messages surfaced to the MCP client
Quick Start
The way to run Samarth is the desktop app - a local Electron app with a chat UI that embeds the MCP server in-process. Multi-account Google sign-in, per-account LLM keys (OpenAI / Anthropic / Gemini), secrets in the OS keychain. Nothing to configure by hand: the Google OAuth client and your LLM key are entered in the app on first run.
You need: Node.js 18 or newer, Git, and a free Google "Desktop app" OAuth client - two values you create once in your Google Cloud project (exact click-by-click steps).
git clone https://github.com/samarthanalytics-sj/samarth-analytics-mcp.git
cd samarth-analytics-mcp/apps/desktop
npm install # downloads the Electron binary (~100 MB first time)
npm run dev
The window opens; paste your OAuth client ID + secret and an LLM API key when asked, sign in to Google, and start chatting with your GTM / GA4 setup.
Prefer a config file over typing in the app? Put the OAuth client in a
.env file instead - the app reads it on launch (values typed in the app and
real shell variables always take precedence):
GOOGLE_DESKTOP_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_DESKTOP_CLIENT_SECRET=your-client-secret
Save it as apps/desktop/.env or at the repo root (already gitignored - never
commit it). A repo-root .env using the server's GOOGLE_OAUTH_CLIENT_ID /
GOOGLE_OAUTH_CLIENT_SECRET names works too, so one file can serve both the
app and the MCP server. A packaged install reads .env from its data
directory instead (%APPDATA% on Windows).
Your everyday launch afterwards is just:
cd samarth-analytics-mcp/apps/desktop && npm run dev
Full guide - Windows/macOS specifics, first-run setup, building a real
.exe/.dmg installer, and the Error: Electron uninstall fix:
apps/desktop/INSTALL.md.
Google Cloud OAuth Setup
Step 1: Enable the GTM API
- Go to Google Cloud Console
- Select or create a project
- Navigate to APIs & Services → Library
- Search for "Tag Manager API" and click Enable
- Search for "Google Analytics Admin API" and click Enable (required for the read-only
ga4_*Admin tools) - Search for "Google Analytics Data API" and click Enable (required for
ga4_run_report/ga4_run_realtime_report)
Step 2: Create OAuth 2.0 Credentials
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth 2.0 Client ID
- Choose application type:
- Desktop app — simplest for local stdio use (no redirect URI needed)
- Web application — for the HTTP server (add your redirect URI)
- Download the JSON or copy the Client ID and Client Secret
- Add to
.env:GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=your-client-secret GOOGLE_REDIRECT_URI=http://localhost:3001/oauth/callback
Step 3: Configure OAuth Consent Screen
- Go to APIs & Services → OAuth consent screen
- Choose External (or Internal if you have Google Workspace)
- Fill in App name, support email
- Add scopes:
https://www.googleapis.com/auth/tagmanager.readonlyhttps://www.googleapis.com/auth/tagmanager.edit.containershttps://www.googleapis.com/auth/tagmanager.edit.containerversionshttps://www.googleapis.com/auth/tagmanager.manage.accountshttps://www.googleapis.com/auth/tagmanager.manage.usershttps://www.googleapis.com/auth/tagmanager.publishhttps://www.googleapis.com/auth/analytics.readonly(read-only GA4 Admin and Data API tools)https://www.googleapis.com/auth/analytics.edit(GA4 Admin write tools — gated byGA4_MCP_ENABLE_WRITES)https://www.googleapis.com/auth/analytics.manage.users(GA4 access-binding write tools)
- Add your Google account as a test user (while the app is in "testing" mode)
Note: For personal/agency use, keeping the app in "Testing" mode is fine. You will need to re-authorize every 7 days unless you publish the app or get it verified.
Step 4: Run OAuth Setup
npm run auth:google
Or, if you prefer the older paste-the-code helper:
npm run oauth:setup
Service Account Limitations
Short version: Service accounts do NOT work with GTM by default. Use OAuth 2.0.
The Google Tag Manager API is a user-data API — it manages resources owned by individual Google accounts. Service accounts are not Google users and are not automatically granted access to GTM containers.
Option A: Add the service account as a GTM user (simplest)
If you still want to use a service account:
- Get the service account email (e.g.,
my-sa@project.iam.gserviceaccount.com) - In GTM, go to Admin → User Management at the account or container level
- Add the service account email with the appropriate role (Read, Edit, Approve, Publish)
- Set
GOOGLE_SERVICE_ACCOUNT_KEY_FILE=/path/to/key.jsonin.env
Caveats: This only works if the GTM container is associated with a Google account, not a Google Workspace that restricts external sharing.
Option B: Domain-Wide Delegation (Google Workspace only)
For Google Workspace organizations:
- Create a service account with a JSON key
- Enable Domain-Wide Delegation on the service account in Google Cloud Console
- In Google Workspace Admin Console → Security → API Controls → Domain-wide Delegation:
- Add the service account client ID
- Add scopes:
https://www.googleapis.com/auth/tagmanager.edit.containers(and others as needed)
- In
.env, set:GOOGLE_SERVICE_ACCOUNT_KEY_FILE=/path/to/key.json - The server will impersonate the user automatically if you set a subject in
buildGoogleAuth()
Caveats: Requires a paid Google Workspace account. Only available for your own domain.
Environment Variables Reference
| Variable | Default | Description |
|---|---|---|
| GOOGLE_OAUTH_CLIENT_ID | — | OAuth client ID (preferred). Falls back to GOOGLE_CLIENT_ID. |
| GOOGLE_OAUTH_CLIENT_SECRET | — | OAuth client secret (preferred). Falls back to GOOGLE_CLIENT_SECRET. |
| GOOGLE_OAUTH_REDIRECT_URI | http://localhost:3001/oauth/callback | OAuth redirect URI. Falls back to GOOGLE_REDIRECT_URI. |
| GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET / GOOGLE_REDIRECT_URI | — | Legacy names, still supported. |
| SAMARTH_GOOGLE_OAUTH_CLIENT_ID | — | Hosted-only. Samarth-owned public OAuth client. Takes precedence over the self-hosted va
Truncated for display — read the full file on GitHub.
Related Skills
Agent-Reach
108.0kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
78.7kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
CowAgent
47.8kOpen-source personal AI assistant & Agent Harness. Plans tasks, runs tools and skills, self-evolves with memory and knowledge. Multi-agent, multi-model, multi-channel. Lightweight, extensible, one-line install.
Scrapling
92.8k🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
