mcpField
G
google-search-console

google-search-console

github.com/acedatacloud营销与增长17178 次安装今天更新
代码仓库

关于 google-search-console

通过 curl 和 jq 调用 Google Search Console API 的命令行技能,供站点管理者查询搜索表现、已提交的网站地图和 URL 索引状态。

主要功能

  1. 01列出已验证的网站资源
  2. 02查询不同维度的搜索分析
  3. 03筛选分析结果
  4. 04查看网站地图状态
  5. 05检查 URL 索引情况

适用场景

  1. 01按查询词查看点击量与曝光量
  2. 02按网页或国家比较表现
  3. 03检查网站地图错误与警告
  4. 04检查 URL 是否已编入索引

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/acedatacloud/skills --skill google-search-console

安装后在 Claude Code 中输入/google-search-console确认已加载。

详细介绍

通过 curl + jq 查询 Google Search Console。用户的 OAuth bearer token 位于 $GOOGLE_SEARCH_CONSOLE_TOKEN 中(范围为 webmasters.readonly);每次调用都需要 Authorization: Bearer $GOOGLE_SEARCH_CONSOLE_TOKEN。基础 URL: https://searchconsole.googleapis.com。

失败时会返回 {"error":{"code","message","status"}} — 请原样显示。401 = 重新安装。403 = 此 token 对应的账号不拥有或未验证该站点。

AUTH="Authorization: Bearer $GOOGLE_SEARCH_CONSOLE_TOKEN"
# Verified sites (siteUrl is the property — URL-encode it in later calls)
curl -sS -H "$AUTH" "https://searchconsole.googleapis.com/webmasters/v3/sites" \
  | jq '.siteEntry[] | {siteUrl, permissionLevel}'

搜索分析

# Top queries by clicks for the last 28 days. siteUrl must be URL-encoded
# (https%3A%2F%2Fexample.com%2F  or  sc-domain%3Aexample.com).
SITE="https%3A%2F%2Fexample.com%2F"
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" -d '{
  "startDate":"2026-05-24","endDate":"2026-06-21",
  "dimensions":["query"],"rowLimit":10
}' "https://searchconsole.googleapis.com/webmasters/v3/sites/$SITE/searchAnalytics/query" \
  | jq '.rows[] | {query: .keys[0], clicks, impressions, ctr, position}'

将 dimensions 替换为 ["page"]、["country"]、["date"],或组合使用 ["query","page"]。添加 "dimensionFilterGroups",按页面/国家筛选。

站点地图与 URL 检查

# Submitted sitemaps
curl -sS -H "$AUTH" "https://searchconsole.googleapis.com/webmasters/v3/sites/$SITE/sitemaps" \
  | jq '.sitemap[] | {path, lastDownloaded, errors, warnings}'

# Is a URL indexed?
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"inspectionUrl":"https://example.com/page","siteUrl":"https://example.com/"}' \
  "https://searchconsole.googleapis.com/v1/urlInspection/index:inspect" \
  | jq '.inspectionResult.indexStatusResult | {verdict, coverageState, lastCrawlTime}'

注意事项

  • 两种属性格式: URL 前缀(https://example.com/)与网域 (sc-domain:example.com)。请使用站点列表中的确切 siteUrl,并进行 URL 编码。
  • 数据会延迟约 2–3 天;最近的日期可能数据不完整或为空 — 若要获取稳定的数据,请将 endDate 设为提前几天。
  • ctr 的取值范围为 0–1;position 为平均排名(越低越好)。

评论

支持 Markdown