Google Tag Manager MCP Server

Google Tag Manager MCP Server

Enables comprehensive management of Google Tag Manager accounts, containers, workspaces, tags, triggers, and variables through OAuth2 authentication, allowing users to create, update, and publish GTM configurations via natural language.

Category
Visit Server

README

Google Tag Manager MCP Server

Google Tag Managerを操作するためのMCP(Model Context Protocol)サーバーです。Macローカル環境で動作します。

機能

このMCPサーバーは以下のGoogle Tag Manager操作を提供します:

  • アカウント管理: アカウント一覧の取得
  • コンテナ管理: コンテナの一覧取得、詳細取得、作成
  • ワークスペース管理: ワークスペースの一覧取得、詳細取得
  • タグ管理: タグの一覧取得、作成、更新、削除
  • トリガー管理: トリガーの一覧取得、作成
  • 変数管理: 変数の一覧取得、作成
  • バージョン管理: バージョンの作成(公開準備)

セットアップ

1. 依存関係のインストール

npm install

2. Google Cloud OAuth2認証情報の設定

Google Tag Manager APIを使用するには、OAuth2認証情報が必要です。

  1. Google Cloud Consoleでプロジェクトを作成
  2. APIとサービス > 認証情報 に移動
  3. 認証情報を作成 > OAuth クライアント ID を選択
  4. アプリケーションの種類で デスクトップアプリ を選択
  5. 名前を入力して作成
  6. クライアントIDクライアントシークレット をコピー
  7. APIとサービス > ライブラリTag Manager API を有効化

3. 環境変数の設定

.envファイルを作成し、OAuth2認証情報を設定します:

GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/oauth2callback

注意: GOOGLE_REDIRECT_URIは、Google Cloud ConsoleのOAuth2認証情報設定で「承認済みのリダイレクト URI」に追加する必要があります。

4. 初回認証

MCPサーバーを起動後、以下の手順で認証を行います:

  1. get_auth_urlツールを使用して認証URLを取得
  2. ブラウザで認証URLにアクセス
  3. Googleアカウントでログインし、権限を承認
  4. リダイレクト先のURLから認証コードを取得(code=の後の値)
  5. authenticateツールに認証コードを渡して認証を完了

認証情報は ~/.gtm-mcp-token.json に保存され、次回以降は自動的に使用されます。

使用方法

MCPクライアントとして設定

CursorなどのMCPクライアントで、このサーバーを設定します。

設定例(~/.cursor/mcp.json または適切な設定ファイル):

{
  "mcpServers": {
    "gtm": {
      "command": "node",
      "args": ["/Users/01035280/Documents/タグマネTテスト/GTM_MCP/src/index.js"],
      "env": {
        "GOOGLE_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
        "GOOGLE_CLIENT_SECRET": "your-client-secret",
        "GOOGLE_REDIRECT_URI": "http://localhost:3000/oauth2callback"
      }
    }
  }
}

または、.envファイルを使用する場合は、環境変数の設定を省略できます。

利用可能なツール

認証操作

  • get_auth_url: OAuth2認証URLを取得
  • authenticate: 認証コードを使用して認証を完了
  • check_auth_status: 現在の認証状態を確認
  • reset_auth: 保存された認証情報をリセット

アカウント操作

  • list_accounts: アカウント一覧を取得

コンテナ操作

  • list_containers: コンテナ一覧を取得
  • get_container: コンテナの詳細を取得
  • create_container: 新しいコンテナを作成

ワークスペース操作

  • list_workspaces: ワークスペース一覧を取得
  • get_workspace: ワークスペースの詳細を取得

タグ操作

  • list_tags: タグ一覧を取得
  • create_tag: 新しいタグを作成
  • update_tag: 既存のタグを更新
  • delete_tag: タグを削除

トリガー操作

  • list_triggers: トリガー一覧を取得
  • create_trigger: 新しいトリガーを作成

変数操作

  • list_variables: 変数一覧を取得
  • create_variable: 新しい変数を作成

バージョン操作

  • create_version: ワークスペースの変更をバージョンとして作成

開発

開発モードで実行

npm run dev

通常モードで実行

npm start

注意事項

  • このサーバーは標準入出力(stdio)経由で通信します
  • Google Tag Manager APIのレート制限に注意してください
  • OAuth2認証情報(クライアントID、クライアントシークレット)は安全に管理してください
  • 認証トークンは ~/.gtm-mcp-token.json に保存されます(.gitignoreに含まれています)
  • リフレッシュトークンは自動的に使用され、アクセストークンが期限切れになる前に更新されます

ライセンス

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured