Google Analytics MCP Server

Google Analytics MCP Server

A local MCP server for Google Analytics 4 that provides tools for SEO and paid reporting, enabling queries on organic and paid search performance, landing pages, channels, campaigns, and real-time data.

Category
访问服务器

README

Google Analytics MCP

Local MCP server for Google Analytics 4. Wraps the GA4 Data API behind tools focused on SEO and Paid reporting.

Tools

Tool Purpose
ga4_organic_search_performance SEO: Organic Search sessions/users/engagement/conversions by landing page, source, country, or device
ga4_paid_search_performance Paid: Paid Search sessions/conversions/cost/CPC by campaign, landing page, keyword, or source
ga4_all_paid_performance Paid: all paid channels (Search + Social + Video + Display) with cost and ROAS
ga4_google_ads_performance Paid: Google Ads campaign × ad group × keyword (requires GA4 ↔ Google Ads link)
ga4_landing_page_performance Top landing pages by sessions/engagement/conversions (optional channel filter)
ga4_channel_performance Default channel group rollup
ga4_campaign_performance Campaign × source × medium breakdown
ga4_conversions_by_source Conversions and key events by source/medium/channel
ga4_realtime_active_users Active users in last 30 min
ga4_run_report Flexible escape hatch — any dimensions + metrics

Setup

git clone https://github.com/ZLeventer/google-analytics-mcp-server.git
cd google-analytics-mcp-server
npm install
npm run build

Credentials

Copy .env.example to .env and fill in:

  • GA4_PROPERTY_ID — numeric property ID from GA4 Admin → Property Settings (e.g. 123456789). Not the Measurement ID (G-XXXXXXX).
  • GOOGLE_APPLICATION_CREDENTIALS — absolute path to the service account JSON key file.

Create the service account

  1. Go to console.cloud.google.com → pick/create a project
  2. APIs & Services → Library → enable Google Analytics Data API
  3. IAM & Admin → Service Accounts → Create service account (name it ga4-mcp or similar)
  4. On the created account → Keys → Add key → Create new key → JSON → download
  5. Save the JSON as service-account.json in this directory (already in .gitignore)
  6. In GA4 → Admin → Property Access Management, click + → paste the service account email (ga4-mcp@project-id.iam.gserviceaccount.com) → assign Viewer

The Google SDK auto-reads GOOGLE_APPLICATION_CREDENTIALS — no code changes needed.

Install into Claude Code

claude mcp add google-analytics \
  --env-file "/absolute/path/to/google-analytics-mcp-server/.env" \
  -- node "/absolute/path/to/google-analytics-mcp-server/dist/index.js"

Or add to ~/.claude.json manually:

{
  "mcpServers": {
    "google-analytics": {
      "command": "node",
      "args": ["/absolute/path/to/google-analytics-mcp-server/dist/index.js"],
      "env": {
        "GA4_PROPERTY_ID": "123456789",
        "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/google-analytics-mcp-server/service-account.json"
      }
    }
  }
}

Restart Claude Code after install.

Date formats

All date args accept GA4 formats:

  • YYYY-MM-DD (e.g. 2026-04-01)
  • NdaysAgo (e.g. 28daysAgo, 90daysAgo)
  • yesterday, today

Defaults: 28daysAgo → yesterday.

Verification

After credentials are in place:

node -e '
  import("./dist/tools/reports.js").then(m =>
    m.channelPerformance({ start_date: "7daysAgo", end_date: "yesterday", limit: 10 })
  ).then(r => console.log(JSON.stringify(r, null, 2)))
'

If that returns rows, everything works. Expected errors:

  • GA4_PROPERTY_ID is not set — check .env
  • PERMISSION_DENIED — service account isn't granted Viewer on the property
  • 403 Google Analytics Data API has not been used — enable the API in the GCP project

Roadmap

  • [ ] Admin API tools (list custom dimensions, conversion events, audiences) once needed
  • [ ] Search Console MCP as sibling server for rankings / impressions / CTR data (complements this one)
  • [ ] Pair with Demandbase MCP to join GA4 traffic with firmographics (account-level attribution)

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选