GA4和Google搜索控制台管理工具

GA4-MCP是一个为AI代理设计的服务器,提供16种工具用于管理Google Analytics 4、Google Search Console和索引API,包括运行报告、检查URL、提交站点地图和管理属性等功能。

  • by chimpmatic
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 chimpmatic/ga4-mcp

使用说明

ga4 mcp

GA4+谷歌搜索控制台MCP服务器。适用于Claude、Copilot、Cursor、Codex、Gemini和任何兼容MCP的AI代理。

用于Google Analytics 4、搜索控制台和索引API的16个工具-运行报告、检查URL、提交网站地图、管理属性和请求索引,所有这些都来自您的AI代理。

快速开始

npx -y ga4-mcp

或者全局安装以加快启动速度:

npm install -g ga4-mcp
ga4-mcp

先决条件

使用Google进行身份验证(包括所有必需的范围):

gcloud auth application-default login \
  --scopes="https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/analytics.edit,https://www.googleapis.com/auth/webmasters,https://www.googleapis.com/auth/indexing"

或设置 GOOGLE_APPLICATION_CREDENTIALS 到服务帐户JSON密钥文件。

代理配置

克劳德代码

{
  "mcpServers": {
    "ga4-analytics": {
      "command": "npx",
      "args": ["-y", "ga4-mcp"]
    }
  }
}

光标/风帆/继续

添加 .cursor/mcp.json 或同等产品:

{
  "mcpServers": {
    "ga4-analytics": {
      "command": "npx",
      "args": ["-y", "ga4-mcp"]
    }
  }
}

仅加载特定的工具组

{
  "mcpServers": {
    "ga4-analytics": {
      "command": "npx",
      "args": ["-y", "ga4-mcp", "--tools", "ga4,gsc"]
    }
  }
}

CLI选项

ga4-mcp [options]

--tools <groups>     Tool groups to enable: ga4, gsc, indexing, admin, all (default: all)
                     "ga4" = read-only analytics. "admin" = write/delete mega-tool.
--transport <type>   Transport: stdio (default) or http (Streamable HTTP)
--port <number>      HTTP port (default: 3000)
--version            Show version
--help               Show help

环境变量: GA4_MCP_TOOLS, GA4_MCP_TRANSPORT, GA4_MCP_PORT

工具(共16个)

实用工具(1个工具)

工具 说明
ping 健康检查-返回pong(始终注册)

GA4分析(6种工具)——组: ga4

工具 说明
get_account_summaries 列出所有GA4帐户和属性
get_property_details 物业详细信息(名称、时区、货币)
run_report 运行GA4 Data API报告
run_realtime_report 运行GA4实时报告
get_custom_dimensions_and_metrics 自定义尺寸和度量
list_google_ads_links 酒店的Google Ads链接

GA4管理员(1个大型工具,14个操作)——组: admin

工具 说明
ga4_admin 创建/更新/删除属性、流、关键事件、受众

谷歌搜索控制台(6个工具)——组: gsc

工具 说明
gsc_list_sites 列出所有GSC属性
gsc_search_analytics 查询搜索分析(展示、点击、点击率、位置)
gsc_inspect_url URL检查(索引状态、爬网信息、移动可用性)
gsc_list_sitemaps 列出提交的网站地图
gsc_add_site 向GSC添加站点
gsc_submit_sitemap 提交站点地图

API索引(2个工具)-组: indexing

工具 说明
indexing_notify 通知Google抓取/删除URL
indexing_status 检查URL的通知状态

许可证

麻省理工学院