Samarth GTM MCP Server
OfficialServer Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| DRY_RUN | No | Simulate all writes without calling the API. | false |
| GOOGLE_CLIENT_ID | No | Legacy OAuth client ID. | |
| GTM_MCP_HTTP_PORT | No | HTTP server port (http transport only; falls back to PORT). | 3001 |
| GTM_MCP_RETRY_MAX | No | Retry attempts for transient read failures (408/429/5xx, network). 0 disables retries. Mutations are never auto-retried. | 3 |
| GTM_MCP_TRANSPORT | No | Transport: stdio or http. | stdio |
| GTM_MCP_TOKEN_FILE | No | Path to the local OAuth token file written by npm run auth:google (gitignored). | ./.gtm-mcp-tokens.json |
| GOOGLE_ACCESS_TOKEN | No | Current OAuth access token. Env vars take precedence over the token file. | |
| GOOGLE_REDIRECT_URI | No | Legacy OAuth redirect URI. | |
| GOOGLE_CLIENT_SECRET | No | Legacy OAuth client secret. | |
| GOOGLE_REFRESH_TOKEN | No | OAuth refresh token (long-lived). Env vars take precedence over the token file. | |
| GTM_MCP_ENABLE_WRITES | No | Allow create/update operations. | false |
| GOOGLE_OAUTH_CLIENT_ID | No | OAuth client ID (preferred). Falls back to GOOGLE_CLIENT_ID. | |
| GTM_DEFAULT_ACCOUNT_ID | No | Optional default accountId. | |
| GTM_MCP_ENABLE_DELETES | No | Allow delete operations. | false |
| GTM_MCP_ENABLE_PUBLISH | No | Allow publish operations. | false |
| GTM_MCP_HTTP_AUTH_TOKEN | No | Bearer token gating /mcp (http transport). Required before exposing the server beyond localhost; unset = open + startup warning. | |
| GTM_DEFAULT_CONTAINER_ID | No | Optional default containerId. | |
| GTM_DEFAULT_WORKSPACE_ID | No | Optional default workspaceId. | |
| GOOGLE_OAUTH_REDIRECT_URI | No | OAuth redirect URI. Falls back to GOOGLE_REDIRECT_URI. | http://localhost:3001/oauth/callback |
| GOOGLE_OAUTH_CLIENT_SECRET | No | OAuth client secret (preferred). Falls back to GOOGLE_CLIENT_SECRET. | |
| GTM_MCP_RETRY_MAX_DELAY_MS | No | Cap on a single backoff sleep (exponential backoff with jitter). | 30000 |
| GTM_MCP_RETRY_TOTAL_TIMEOUT_MS | No | Cap on total wall time from first request to last retry. | 60000 |
| SAMARTH_GOOGLE_OAUTH_CLIENT_ID | No | Hosted-only. Samarth-owned public OAuth client. Takes precedence over self-hosted vars when set. | |
| GOOGLE_SERVICE_ACCOUNT_KEY_FILE | No | Path to service account JSON key (see limitations above). | |
| SAMARTH_GOOGLE_OAUTH_CLIENT_SECRET | No | Hosted-only. Inject from your platform secret manager. Never commit. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| prompts | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| accounts_listB | List all GTM accounts accessible to the authenticated user. Returns account IDs, names, and share-data flags. |
| accounts_getA | Get details of a specific GTM account. |
| containers_listA | List all GTM containers within a GTM account. Automatically follows pagination to return all containers. |
| containers_getB | Get details of a specific GTM container. |
| containers_createA | [WRITE] Create a new GTM container. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| containers_set_tagging_server_urlsA | [WRITE] Set a SERVER container's taggingServerUrls (the deployed tagging-server URL, e.g. from Cloud Run/Stape). Read-modify-write via containers.update so the other container fields are preserved; rejects a non-server container. Records the URL in config only — it does NOT deploy the host. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| containers_snippetA | Get the GTM installation snippet (HTML/JS tagging code) for a container. |
| containers_lookupA | Look up a GTM container by its linked destination ID (e.g. a GA4 measurement ID or tag ID). |
| containers_combineA | [WRITE] Combine (merge) another container into this one. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. ⚠️ This merges the source container identified by containerIdToCombine into the target container. |
| containers_move_tag_idC | [WRITE] Move a Tag ID out of a container into a new container. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| destinations_listA | List all destinations (linked Google tags / GA4 destinations) for a GTM container. |
| destinations_getC | Get details of a specific GTM destination. |
| destinations_linkA | [WRITE] Link a destination (Google tag / GA4 destination) to a GTM container. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| workspaces_listA | List all workspaces within a GTM container. Automatically follows pagination to return all workspaces. |
| workspaces_getB | Get details of a specific GTM workspace. |
| workspaces_createC | [WRITE] Create a new workspace. Requires GTM_MCP_ENABLE_WRITES=true. |
| workspace_get_statusA | Get the status of a GTM workspace: the list of changed entities (workspaceChange) relative to the latest container version, plus any merge conflicts. Use this to review a change diff before creating a version or publishing. |
| workspace_syncA | Syncs a workspace to the latest container version by updating all unmodified workspace entities. Returns a list of merge conflicts if any. |
| workspace_resolve_conflictA | Resolve a merge conflict for a workspace entity. You supply the resolved entity body plus its type; the GTM API wraps it in an Entity envelope ({ "tag": {...} } / { "trigger": {...} } / …), which this tool builds for you. NOTE: This is a complex operation — review the GTM UI conflict resolution first. |
| tags_listA | List all GTM tags in a workspace. Automatically follows pagination to return all tags. |
| tags_getB | Get details of a specific GTM tag. |
| tags_createA | [WRITE] Create a new GTM tag. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full tag configuration as parameters. |
| tags_updateA | [WRITE] Update an existing GTM tag (read-modify-write). Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. GTM's API replaces the WHOLE tag on update, so this tool first fetches the tag and only overlays the fields you pass — omitted fields are preserved. |
| tags_add_ga4_event_parametersA | [WRITE] Add GA4 event parameters to a GA4 Event tag (type "gaawe"). Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Fetches the tag, APPENDS the parameters to its eventSettingsTable (the correct place for GA4 event parameters — top-level params are ignored by GA4 event tags), and saves the FULL tag so eventName/measurementId stay intact. A parameter whose name already exists has its value updated (not duplicated). Values may be GTM variables, e.g. {{Click Text}}. |
| tags_deleteA | [DELETE] Delete a GTM tag. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. This is irreversible in the workspace (the tag is removed from the workspace). |
| triggers_listC | List all GTM triggers in a workspace. Automatically follows pagination to return all triggers. |
| triggers_getC | Get a specific GTM trigger. |
| triggers_createA | [WRITE] Create a GTM trigger. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| triggers_updateA | [WRITE] Update a GTM trigger (read-modify-write — omitted fields are preserved; |
| triggers_deleteB | [DELETE] Delete a GTM trigger. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| variables_listA | List all user-defined GTM variables in a workspace. Automatically follows pagination to return all variables. |
| variables_getC | Get a specific GTM variable. |
| variables_createC | [WRITE] Create a GTM variable. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| variables_updateA | [WRITE] Update a GTM variable (read-modify-write — omitted fields are preserved; |
| variables_deleteC | [DELETE] Delete a GTM variable. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| folders_listB | List all GTM folders in a workspace. Automatically follows pagination to return all folders. |
| folders_getC | Get a specific GTM folder. |
| folders_entitiesA | List all entities (tags, triggers, variables) within a specific GTM folder. Automatically follows pagination to return all entities. |
| folders_createB | [WRITE] Create a GTM folder. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| folders_updateB | [WRITE] Update a GTM folder. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| folders_deleteB | [DELETE] Delete a GTM folder. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. Contents of the folder will be unfoldered, not deleted. |
| folders_move_entitiesB | [WRITE] Move tags/triggers/variables into a folder. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| built_in_variables_listB | List all currently enabled built-in variables in a GTM workspace. |
| built_in_variables_enableA | [WRITE] Enable one or more built-in variables in a GTM workspace. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| built_in_variables_disableA | [DELETE] Disable one or more built-in variables in a GTM workspace. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| built_in_variables_revertA | [WRITE] Revert changes to a built-in variable in the workspace to the original container version. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| create_gtm_tracking_tagA | [WRITE] PREFERRED way to create a GA4 event tag that fires on an event. Builds a CORRECT GTM resource from plain fields, so you never hand-write GTM JSON. ONE call: enables the built-in variables the tag and trigger reference, reuses or creates the named trigger, and creates the tag linked to it in the draft workspace. Use this instead of tags_create + triggers_create + built_in_variables_enable, which needs three round trips and gets the shapes wrong. eventParameters values may reference built-in variables ({{Click URL}}, {{Click Text}}, {{Page URL}}, {{Form ID}}) and those are enabled automatically. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| create_gtm_variable_typedA | [WRITE] Create a GTM variable by KIND rather than by GTM's internal type code, so the right shape is guaranteed. kind: "constant" (a fixed reused value, e.g. a Measurement ID); "data_layer" (read a key the SITE pushes to the dataLayer, dot-notation for nested, e.g. ecommerce.value) - only correct when the site actually pushes that key; "javascript" (Custom JavaScript: a function(){...} that COMPUTES a value, and the right choice for deriving something from the page or the click, e.g. extracting the address out of a mailto: {{Click URL}} - a data_layer variable CANNOT do this and would report blank); "event_data" and "request_header" (SERVER containers only). Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| versions_listB | List all container version headers (summary) for a GTM container. |
| versions_getA | Get the full contents of a specific GTM container version. Pass "live" as containerVersionId to get the currently live version. |
| versions_createA | [WRITE] Create a new GTM container version from a workspace (checkpoint). Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. This takes a snapshot of the workspace into a versioned checkpoint without publishing. |
| versions_set_latestA | [WRITE] Set a specific container version as the "latest" (synchronizes the default workspace with this version). Note: This does NOT publish. Use versions_publish to go live. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| versions_undeleteB | [WRITE] Undelete a previously deleted GTM container version. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| versions_deleteA | [DELETE] Delete a GTM container version. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. Cannot delete a currently published (live) version. |
| workspace_quick_previewA | Generate a quick-preview (debug) link for a GTM workspace. This does NOT publish — it just enables preview mode. Returns a preview container version with any compilation errors. |
| versions_publishC | [PUBLISH] Publish a specific GTM container version to live. Requires GTM_MCP_ENABLE_PUBLISH=true and confirm=true. ⚠️ This immediately makes the version live in production. |
| workspace_create_version_and_publishA | [PUBLISH] Create a new container version from a workspace and immediately publish it. Requires GTM_MCP_ENABLE_PUBLISH=true and confirm=true. ⚠️ This is the most powerful write operation — it goes live in production immediately. |
| environments_listB | List all environments in a GTM container. Automatically follows pagination. |
| environments_getB | Get details of a specific GTM environment. |
| environments_createA | [WRITE] Create a new GTM environment. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| environments_updateB | [WRITE] Update an existing GTM environment. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| environments_reauthorizeA | [PUBLISH] Re-generate the authorization code for a GTM environment. Requires GTM_MCP_ENABLE_PUBLISH=true and confirm=true. ⚠️ This rotates the environment auth token; any embedded snippet using the old token stops working until updated. |
| environments_deleteA | [DELETE] Delete a GTM environment. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| user_permissions_listA | List all user permissions for a GTM account. Automatically follows pagination. Each record shows a user email plus their account and per-container access levels. |
| user_permissions_getB | Get a specific user permission record for a GTM account. |
| user_permissions_createA | [WRITE] Grant a user access to a GTM account (and optionally containers). Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| user_permissions_updateA | [WRITE] Update a user's account and/or container access levels. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Provide the full intended access (account + container) as the API replaces the record. |
| user_permissions_deleteA | [DELETE] Revoke a user's access to a GTM account. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| clients_listB | List all GTM clients in a workspace. Automatically follows pagination. |
| clients_getB | Get a specific GTM client. |
| clients_createA | [WRITE] Create a new GTM client. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| clients_updateA | [WRITE] Update an existing GTM client. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| clients_deleteA | [DELETE] Delete a GTM client. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| clients_revertA | [WRITE] Revert workspace changes to a GTM client back to its last container-version state. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| transformations_listB | List all GTM transformations in a workspace. Automatically follows pagination. |
| transformations_getB | Get a specific GTM transformation. |
| transformations_createA | [WRITE] Create a new GTM transformation. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| transformations_updateA | [WRITE] Update an existing GTM transformation. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| transformations_deleteA | [DELETE] Delete a GTM transformation. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| transformations_revertA | [WRITE] Revert workspace changes to a GTM transformation back to its last container-version state. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| zones_listA | List all GTM zones in a workspace. Automatically follows pagination. |
| zones_getB | Get a specific GTM zone. |
| zones_createA | [WRITE] Create a new GTM zone. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| zones_updateA | [WRITE] Update an existing GTM zone. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| zones_deleteA | [DELETE] Delete a GTM zone. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| zones_revertA | [WRITE] Revert workspace changes to a GTM zone back to its last container-version state. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| templates_listA | List all GTM templates in a workspace. Automatically follows pagination. |
| templates_getB | Get a specific GTM template. |
| templates_createA | [WRITE] Create a new GTM template. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| templates_updateA | [WRITE] Update an existing GTM template. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| templates_deleteA | [DELETE] Delete a GTM template. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| templates_revertA | [WRITE] Revert workspace changes to a GTM template back to its last container-version state. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. |
| gtag_config_listA | List all GTM gtag configs in a workspace. Automatically follows pagination. |
| gtag_config_getC | Get a specific GTM gtag config. |
| gtag_config_createB | [WRITE] Create a new GTM gtag config. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| gtag_config_updateA | [WRITE] Update an existing GTM gtag config. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. Pass the full resource as a JSON string in bodyJson. |
| gtag_config_deleteA | [DELETE] Delete a GTM gtag config. Requires GTM_MCP_ENABLE_DELETES=true and confirm=true. |
| templates_import_from_galleryA | [WRITE] Install a Community Template Gallery template into a workspace by GitHub owner and repository, so a THIRD-PARTY pixel can use its official sandboxed template instead of Custom HTML. NOT for Google's own tags. GA4, Google Ads and Floodlight are BUILT IN to GTM as native tag types (googtag, gaawe, awct, sp, flc), there is no gallery repository for them, and asking for one answers "404 Not found or permission denied". To build a GA4 event tag call tags_create with type "gaawe" directly; do not import anything first. Requires GTM_MCP_ENABLE_WRITES=true and confirm=true. The GTM API DOES support this (templates.import_from_gallery); never tell the user it is UI-only. Idempotent: importing one already present returns it unchanged rather than creating a duplicate. Returns the installed template. To build a tag on it you need its tag TYPE (a cvt_... string): READ that from the container rather than constructing it from the templateId, because the format is not what it appears to be. Pass the exact string as |
| audit_containerA | Inspect a GTM workspace for common analytics implementation issues. Returns structured findings with severity levels (error/warning/info). This is a read-only operation — it never modifies anything. |
| export_containerA | Export a full GTM workspace summary as structured JSON. Returns all tags, triggers, variables, folders, and built-in variables. This is a read-only operation. Use this for documentation, auditing, or feeding container data to other tools. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
| setup_server_side_container | One guided flow to create a server-side (sGTM) container: the SERVER container + GA4 client + built-ins + Event-Data/Constant/Request-Header variables + per-event triggers + GA4 (and optional Google Ads) server tags, in the correct order with the exact resource shapes. Optional args: accountId, containerName, measurementId, adsConversionId. |
| setup_ecommerce_funnel | One guided flow to install the full GA4 ecommerce funnel in a WEB container: per-event Custom Event triggers + GA4 event tags with native ecommerce forwarding (sendEcommerceData), the dlv - ecommerce.* variables, and a Consent Mode v2 defaults tag on Consent Initialization — then a verification checklist. Optional args: accountId, containerId, measurementId, events (comma-separated). |
| audit | Run a read-only GTM container audit and summarise the findings by severity (error/warning/info) + category (missing_trigger, paused_tag, broken_reference, ga4_config, duplicate_name, broad_trigger, unused_trigger, missing_builtin_variable, empty_folder). Optional args: account, container (a GTM-XXXXXXX id or name). |
| report | Run a read-only GA4 report (sessions / users / conversions by channel, default last 28 days) and summarise it. Optional args: property (properties/NNNNNNN), dateRange, metrics (comma-separated). |
| create-tag | Guide the end-to-end creation of a GA4 event tag (event name → trigger → variables → tag), DRAFT-ONLY and gated behind GTM_MCP_ENABLE_WRITES + confirm=true. Optional args: description (what to track), account, container. |
| debug | A read-only diagnostic flow to find why a tag is not firing: audit → tag config (paused? trigger?) → trigger conditions → referenced variables → Consent Mode, then the single most likely cause + fix. Optional args: tag, symptom, account, container. |
| explain | Explain a GTM/GA4 concept in plain terms, OR fetch a specific tag/trigger/variable/container (read-only) and explain what it does and when it fires. Optional args: topic, account, container. |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/samarthanalytics-sj/samarth-analytics-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server