Google Tag Manager + read-only GA4 MCP server. Read-only by default, gated writes, audits.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
A production-ready Model Context Protocol (MCP) server for the Google Tag Manager API v2, built for Samarth Analytics.
Use it through Samarth Desktop - the local Electron app with a chat UI that embeds this server (Quick Start). Full, guarded access to GTM: read workspace contents, create/update tags/triggers/variables, audit implementations, publish versions, and more.
New: browser portal with live QC audit. A white-label, browser-based customer experience lives in
apps/portal/. Customers sign in with Google OAuth, pick a GTM account/container/workspace, and run a live, read-only QC audit. Publishes still require Samarth approval. See the portal README for OAuth setup; run withnpm run portal:dev.
ga4_*) plus GA4 Data API reporting (ga4_run_report, ga4_run_realtime_report) for intent-vs-reality reconciliation. Reads and reporting need only analytics.readonly; the GA4 Admin write tools are off by default behind GA4_MCP_ENABLE_WRITES / GA4_MCP_ENABLE_DELETES and additionally need analytics.editnextPageToken to return all results, with optional maxPages/pageToken boundsGTM_MCP_RETRY_*)confirm=true required on all write/delete/publish operationsThe 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).
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):
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:
Full guide - Windows/macOS specifics, first-run setup, building a real
.exe/.dmg installer, and the Error: Electron uninstall fix:
apps/desktop/INSTALL.md.
ga4_* Admin tools)ga4_run_report / ga4_run_realtime_report).env:
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 by GA4_MCP_ENABLE_WRITES)https://www.googleapis.com/auth/analytics.manage.users (GA4 access-binding write tools)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.
Or, if you prefer the older paste-the-code helper:
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.
If you still want to use a service account:
my-sa@project.iam.gserviceaccount.com)GOOGLE_SERVICE_ACCOUNT_KEY_FILE=/path/to/key.json in .envCaveats: This only works if the GTM container is associated with a Google account, not a Google Workspace that restricts external sharing.
For Google Workspace organizations:
https://www.googleapis.com/auth/tagmanager.edit.containers (and others as needed).env, set:
buildGoogleAuth()Caveats: Requires a paid Google Workspace account. Only available for your own domain.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/samarth-gtm-mcp)<a href="https://allmcps.com/mcp/samarth-gtm-mcp"><img src="https://allmcps.com/api/badge/samarth-gtm-mcp?style=directory" alt="Samarth Gtm MCP on AllMCPs" /></a>