MCP server to operate Google Tag Manager (GTM) from LLM clients.
Authentication uses Google OAuth 2.0.
- English:
README.md(this file) - Japanese:
README.ja.md
- Generate OAuth consent URL, exchange auth code, check status, revoke auth
- Generic GTM API v2 call (
gtm_request) - Tag operations:
list/create/update/delete - Trigger operations:
list/create/update/delete - Variable operations:
list/create/update/delete
- This repo includes a skill:
skills/gtm-mcp/SKILL.md
- It covers setup, MCP registration, first OAuth flow, and practical GTM tool usage.
- Node.js 18+
- npm
- Codex CLI and/or Claude Code CLI (for MCP registration)
- Google Cloud OAuth client credentials
- Create or select a Google Cloud project
- Enable
Tag Manager API - Configure
OAuth consent screen - Create an
OAuth client ID - Add redirect URI:
http://127.0.0.1:8085 - Keep your
Client IDandClient Secret
git clone <this-repo-url>
cd gtm-mcp
npm install
npm run setupnpm run setup does:
- Create/update
.envinteractively - Build TypeScript output (
dist/)
Use only what you need:
npm run register:codex
npm run register:claude
npm run register:claude:local
npm run register:claude:user
npm run register:claude:projectNotes:
register:clauderegisters inuserscope (stored in~/.claude.json)register:claude:localregisters inlocalscope (stored in~/.claude.jsonunder project entry)register:claude:useris explicituserscoperegister:claude:projectregisters inprojectscope (.mcp.json)- If
gtmalready exists,register:codexandregister:claude*skip overwrite
From another directory:
npm --prefix /absolute/path/to/gtm-mcp run register:codex
npm --prefix /absolute/path/to/gtm-mcp run register:claude
npm --prefix /absolute/path/to/gtm-mcp run register:claude:local
npm --prefix /absolute/path/to/gtm-mcp run register:claude:user
npm --prefix /absolute/path/to/gtm-mcp run register:claude:projectregister:claude:project uses the caller directory (INIT_CWD) as the project scope target.
Open a new Codex/Claude session, then:
- Call
oauth_get_consent_url - Open the returned URL in an external browser
- Copy
codefrom redirect URL - Call
oauth_exchange_codewith the code - Verify with
oauth_status
npm run devnpm run build
npm startGOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=http://127.0.0.1:8085
GTM_MCP_TOKEN_PATH=.gtm-mcp/tokens.json- Tokens are stored at
GTM_MCP_TOKEN_PATH - Write operations require
https://www.googleapis.com/auth/tagmanager.edit.containers