你会建立什么
这篇教学会把基本的 Gemini CLI 工作区升级成使用 MCP 的唯读 SEO/GEO 资料管线。目标不是把所有可能的操作都交给 CLI,而是只公开 Gemini 产生报告所需要的资料工具,让它能读取 GSC、Bing、GA4、SERP 快照与 AI 能见度检查结果。
完成后,你会有:
.gemini/settings.json
seo-geo/exports/YYYY-MM-DD/
seo-geo/reports/YYYY-MM-DD-mcp-report.md
scripts/mcp-seo-data-server.mjs
图说:MCP 是资料传输升级,不是授权 CLI 自动发布或修改网站。
步骤 1:决定 Gemini CLI 可以使用哪些工具
| Tool type | 第一版设定 | 原因 |
|---|---|---|
| Read GSC pages | Allow | 产生 opportunity reports 需要 |
| Read Bing queries | Allow | 补上非 Google 搜寻讯号 |
| Read GA4 landing pages | 只允许 aggregated | 避免 raw user data |
| Read AI visibility snapshots | Allow | GEO tracking 需要 |
| Submit URLs | Block | 这是写入操作 |
| Publish CMS post | Block | 这是 production action |
| Delete or redirect pages | Block | 高风险操作 |
步骤 2:建立 placeholder MCP server
mkdir -p scripts .gemini
cat > scripts/mcp-seo-data-server.mjs <<'EOF'
#!/usr/bin/env node
// Placeholder MCP server for planning. Replace with a real MCP implementation later.
console.error('TODO: implement MCP tools: get_gsc_pages, get_bing_queries, get_ai_visibility_snapshot');
setInterval(() => {}, 1000);
EOF
chmod +x scripts/mcp-seo-data-server.mjs
这个 placeholder 不会抓真实资料。它的用途是在接触 credentials 之前,让团队先讨论工具名称、权限与资料形状。
步骤 3:建立 .gemini/settings.json
Gemini CLI MCP docs 说明,MCP servers 会公开 tools 与 resources,让 CLI 可以和 external systems / data sources 互动。先从保守设定开始:
{
"mcpServers": {
"seo-data": {
"command": "node",
"args": ["scripts/mcp-seo-data-server.mjs"],
"includeTools": [
"get_gsc_pages",
"get_bing_queries",
"get_ga4_landing_pages",
"get_ai_visibility_snapshot"
],
"excludeTools": [
"submit_url",
"publish_post",
"delete_page",
"create_redirect"
]
}
}
}
如果你的 Gemini CLI 版本或 MCP server 使用不同的 config shape,原则仍然一样:先允许资料读取,阻挡写入操作。
步骤 4:定义正规化输出
mkdir -p seo-geo/exports/schema
cat > seo-geo/exports/schema/normalized-seo-geo-snapshot.json <<'EOF'
{
"date": "YYYY-MM-DD",
"pages": [
{
"url": "https://example.com/page",
"gsc_impressions": 0,
"gsc_clicks": 0,
"bing_clicks": 0,
"ga4_sessions": 0,
"ai_prompts_mentioned": 0,
"ai_citations": [],
"notes": ""
}
]
}
EOF
Gemini CLI 应该从正规化快照写报告,而不是直接把五种无关 raw formats 混在一起。
步骤 5:第一个 MCP prompt
Use only read-only SEO/GEO MCP tools.
Do not submit URLs, publish CMS content, delete pages, create redirects, or edit website files.
Task:
1. Inspect the configured MCP server names and available read tools.
2. Tell me which tools are available and which expected tools are missing.
3. Propose the normalized snapshot shape for today's SEO/GEO report.
4. Do not call any write-capable tool.
好的回答应该会提到允许的 tool names,以及被封锁的 actions。
步骤 6:产生第一份 MCP-based report
等真实 read tools 做好后,再使用:
Use read-only MCP tools to fetch today's GSC pages, Bing queries, GA4 landing page summary, and AI visibility snapshot.
Save normalized output under:
seo-geo/exports/YYYY-MM-DD/normalized-seo-geo-snapshot.json
Then create:
seo-geo/reports/YYYY-MM-DD-mcp-report.md
The report must include:
- data sources used;
- missing data;
- top page opportunities;
- prompt/citation gaps;
- technical or indexing risks;
- recommended next actions;
- actions that require human approval.
Do not edit website files.
预期报告格式
# MCP SEO/GEO Report - YYYY-MM-DD
## Data sources
| Source | Tool | Status | Notes |
## Top opportunities
| URL | Signal | Diagnosis | Recommended action | Risk |
## AI visibility gaps
| Prompt | Brand mentioned | Citation | Competitors | Next page action |
## Approval-needed actions
- Any URL submission
- Any CMS publish
- Any robots/canonical/redirect change
Troubleshooting
| 问题 | 可能原因 | 修正 |
|---|---|---|
| Gemini 看不到 MCP tools | settings path 错误或 server failed | 重新开 CLI 并检查 config path |
| Tool 暴露写入 actions | 没有 allowlist | 加上 include/exclude policy |
| Report 混用 raw formats | 没有 normalized schema | 强制输出 snapshot JSON |
| API keys 出现在 chat | credential handling 不安全 | keys 放到 env/config,不放 prompts |
FAQ
MCP tools 应该提交 URL 或发布 CMS 内容吗?
初学者设定不要这样做。直到 reporting 稳定、approval gates 成熟之前,MCP 都应保持唯读。
可以不使用 MCP 开始吗?
可以。先用 CSV exports。MCP 是 transport upgrade,不是 workflow 本身。
成功讯号是什么?
Gemini CLI 可以读取或取得资料,正规化成一个 snapshot,并且不碰 production files 就产生报告。
AI coding agents for SEO/GEO 学习路径
这篇属于 Gemini CLI SEO/GEO track。请先完成这些 terminal-focused tutorials,再用 operating model 与 editor / workflow agents 搭配。
- Cursor vs Windsurf vs Gemini CLI:SEO/GEO 自动化怎么选
- 如何设定 Gemini CLI SEO/GEO Automation 工作区
- 如何用 MCP 将 Gemini CLI 接上 SEO 资料
- 如何用 Gemini CLI 做每日 SEO/GEO Monitoring
- 如何用 Gemini CLI Checkpointing 安全修 SEO
- Cursor、Windsurf、Gemini CLI、Codex、Claude Code 的 SEO/GEO 营运模型
下一篇
上一篇: 如何设定 Gemini CLI SEO/GEO Automation 工作区
下一篇: 如何用 Gemini CLI 做每日 SEO/GEO Monitoring
Sources and notes
- Gemini CLI documentation: Gemini CLI Docs and MCP servers with Gemini CLI 。
- Related Auspia guide: Cursor vs Windsurf vs Gemini CLI for SEO/GEO Automation 。
Author: Gabriel Finch, Auspia Search Retrieval Researcher,已 review 1,200+ AI Answers。Gabriel 撰写 retrieval systems、AI discovery 与 search infrastructure workflows。