SA

Samarth GTM MCP

Google Tag Manager and GA4 tools for your AI agent. Read-only by default; writes, deletes and publishes each need a flag plus confirm.

Grade A Local · stdio API key 112 tools v1.497.5 · 11 Nov 2026 MIT
No reviews yet by Samarth Analyticsnpm 150,541 Runs on your machine, nothing hosted
97/100
trust score
18
downloads a day
local
runs on your machine
3k
downloads in 30d

What it does

Samarth GTM MCP gives Claude, Cursor and other MCP clients guarded access to the Google Tag Manager API v2, the GA4 Admin API and the GA4 Data API. It runs on your own machine over stdio with your own Google OAuth client. Nothing is hosted and no data passes through a third party.

What your agent can do

  • Read every GTM account, container, workspace, tag, trigger, variable, folder, version and environment
  • Create and update tags, triggers and variables, including typed GA4 event tags with event parameters
  • Work with server-side GTM: clients, transformations, zones, custom templates and Google tag config
  • Audit a workspace for common GA4 and GTM issues, and export it as structured JSON
  • Review workspace changes, sync, resolve conflicts, preview, create versions and publish
  • Manage GTM user permissions and environments
  • GA4 Admin reads: properties, data streams and measurement IDs, custom dimensions and metrics, key events, data retention, enhanced measurement and Google Ads links
  • GA4 Admin writes: key events, custom definitions, audiences, channel groups, product links, access bindings and property settings
  • GA4 reporting: standard and realtime reports, to confirm the events a container sends actually reach GA4

Safety model

  • Read-only out of the box at the server level. Sign-in asks Google for edit, publish and user-management access; the switches below decide what the server will actually do
  • Writes, deletes and publishes are switched on separately with GTM_MCP_ENABLE_WRITES, GTM_MCP_ENABLE_DELETES, GTM_MCP_ENABLE_PUBLISH, GA4_MCP_ENABLE_WRITES and GA4_MCP_ENABLE_DELETES
  • Every change also needs confirm: true in the tool call
  • DRY_RUN=true simulates every change without calling Google
  • Reads retry with backoff on rate limits and server errors; changes are never retried automatically

Setup

  • Needs Node.js 18 or newer
  • In Google Cloud, enable the Tag Manager API, Google Analytics Admin API and Google Analytics Data API
  • Create an OAuth client of type Desktop app and add your Google account as a test user
  • Export GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET, and set GTM_MCP_TOKEN_FILE to an absolute path so the sign-in and the server use the same token file
  • Sign in once: npx -p samarth-gtm-mcp samarth-gtm-auth
  • Add the server with the install line on this page, then restart your client

Limits

  • Service accounts do not work with GTM unless added as a GTM user
  • OAuth apps left in Testing mode need a fresh sign-in every 7 days
  • No GA4 pivot, cohort or funnel reports, and no data filters or referral exclusions, because the Admin API does not expose them

Built by Samarth Analytics, Pune.

Quickstart

Run once first — the server needs this before it answers:

npx -y -p samarth-gtm-mcp samarth-gtm-auth
# 1 — add it to Claude Code claude mcp add --scope user --env 'GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID}' --env 'GOOGLE_OAUTH_CLIENT_SECRET=${GOOGLE_OAUTH_CLIENT_SECRET}' --env 'GTM_MCP_TOKEN_FILE=${GTM_MCP_TOKEN_FILE:-}' --transport stdio samarth-gtm-mcp '--' npx -y samarth-gtm-mcp # 2 — ask your agent for something these tools do # accounts_list, accounts_get, audit_container and 109 more

It needs GOOGLE_OAUTH_CLIENT_ID, GOOGLE_OAUTH_CLIENT_SECRET: this reads them from your environment, so export them first. Its publisher recommends GTM_MCP_TOKEN_FILE: export it first, or leave it unset — the server also starts without it.

Samarth GTM costs nothing on mcprush: there is no plan to choose here, no cap to set and nothing mcprush can bill you for.

PublisherVerified · since 2026
SA
Samarth Analytics1 server
1 category · publishing since 2026
All 1 server
More in this category

See also

See all