Token导航 LogoToken导航TokenDH.com
MCP Gsc Oauth logo
搜索检索stdio官方级别未说明来源级核验

MCP Gsc Oauth

MCP Server

@modelcontextprotocol/inspector

一个提供LLMs程序化访问Google搜索控制台数据和功能的模型上下文协议(MCP)服务器。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
数据分析PythonClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

damupi

提供方

damupi

最后核验

2026/5/17 20:21

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx @modelcontextprotocol/inspector fastmcp dev src/mcp_gsc/server.py

详细介绍

谷歌搜索控制台MCP服务器

一种模型上下文协议(MCP)服务器,为LLM提供对Google Search Console数据和功能的编程访问。内置于 FastMCP.

特性

🛠️ 工具(13个动作)

搜索分析

  • query_search_analytics -使用过滤器和维度查询搜索流量数据

网站地图管理

  • list_sitemaps -列出站点的所有站点地图
  • get_sitemap -获取特定站点地图的详细信息
  • submit_sitemap -向谷歌提交网站地图
  • delete_sitemap -删除站点地图

站点管理

  • list_sites -列出您的Search Console帐户中的所有站点
  • get_site -获取特定网站的信息
  • add_site -将网站添加到搜索控制台
  • delete_site -从Search Console中删除网站

URL检查

  • inspect_url -检查特定URL的Google索引状态

📊 资源(6个数据源)

  • gsc://sites -列出所有可用网站
  • gsc://config -服务器配置和状态
  • gsc://sites/{site_url}/analytics/summary -最近分析摘要(28天)
  • gsc://sites/{site_url}/sitemaps -网站地图
  • gsc://sites/{site_url}/top-queries -前10个查询(7天)
  • gsc://sites/{site_url}/top-pages -前10页(7天)

💬 提示(4个模板)

  • analyze_search_performance -生成SEO性能分析提示
  • seo_recommendations -生成SEO建议提示
  • compare_periods -生成期间比较提示
  • indexing_health_check -生成索引健康检查提示

安装

先决条件

  • Python 3.10或更高版本
  • 启用搜索控制台API的谷歌云项目
  • 来自谷歌云控制台的OAuth 2.0凭据

再进行

# Clone the repository
git clone https://github.com/damupi/mcp-gsc.git
cd mcp-gsc

# Install with uv (recommended)
uv sync

# Or install in development mode
uv pip install -e .

身份验证设置

此服务器使用 FastMCP内置的Google OAuth集成.

步骤1:创建Google OAuth 2.0凭据

  1. 首选 谷歌云控制台
  2. 创建新项目或选择现有项目
  3. 启用 谷歌搜索控制台API
  4. 首选 凭证创建凭据OAuth 2.0客户端ID
  5. 在系统提示时配置OAuth同意屏幕
  6. 选择 Web应用程序 作为应用程序类型
  7. 添加授权的Javascript源代码: http://localhost
  8. 添加授权重定向URI: http://localhost:8000/auth/callback
  9. 保存您的 客户端ID客户端密钥

步骤2:配置环境变量

创建一个 .env 项目根目录中的文件:

cp .env.example .env

编辑 .env 并添加您的凭据:

FASTMCP_SERVER_AUTH=fastmcp.server.auth.providers.google.GoogleProvider
FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_SECRET=GOCSPX-your-client-secret
FASTMCP_SERVER_AUTH_GOOGLE_REQUIRED_SCOPES=openid,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/webmasters

用法

运行服务器

开发模式(STDIO)

fastmcp dev src/mcp_gsc/server.py

生产模式(HTTP传输)

# Run with HTTP transport for remote access
fastmcp run src/mcp_gsc/server.py --transport http

# Specify custom host and port
fastmcp run src/mcp_gsc/server.py --transport http --host 0.0.0.0 --port 8080

服务器将于启动 http://localhost:8000 默认情况下(HTTP模式)。

使用Docker运行

快速入门:

# Build the Docker image
make build

# Start the server
make up

# View logs
make logs

# Stop the server
make down

可用的生成命令:

  • make build -构建Docker镜像
  • make up -在后台启动MCP服务器
  • make down -停止MCP服务器
  • make restart -重新启动服务器
  • make logs -查看服务器日志(跟踪模式)
  • make logs-tail -查看最后100行日志
  • make status -检查服务器状态
  • make clean -删除所有Docker资源
  • make shell -在运行容器中打开一个shell
  • make rebuild -重建并重新启动
  • make dev -使用实时日志运行
  • make test -测试服务器运行状况端点

Docker配置:

服务器在Docker容器中运行:

  • Python 3.12精简基础镜像
  • UV用于快速依赖管理
  • 端口8000上的HTTP传输
  • 故障时自动重启
  • 每30秒进行一次健康检查

确保你的 .env 文件在运行前已配置 make up.

身份验证流程

  1. 启动服务器
  2. 连接MCP客户端(例如Claude Desktop)
  3. 您将被重定向到Google OAuth登录
  4. 授予访问Search Console数据的权限
  5. 您将被重定向并通过身份验证

与Claude Desktop一起使用

选项1:STDIO传输(本地)

添加到您的Claude Desktop配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):

{
  "mcpServers": {
    "gsc-mcp-server": {
      "command": "fastmcp",
      "args": ["run", "src/mcp_gsc/server.py"],
      "env": {
        "FASTMCP_SERVER_AUTH": "fastmcp.server.auth.providers.google.GoogleProvider",
        "FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
        "FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_SECRET": "GOCSPX-your-client-secret",
        "FASTMCP_SERVER_AUTH_GOOGLE_REQUIRED_SCOPES": "openid,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/webmasters"
      }
    }
  }
}

选项2:HTTP传输(远程)

首先,使用HTTP传输启动服务器:

fastmcp run src/mcp_gsc/server.py --transport http

然后配置Claude Desktop通过HTTP连接:

{
  "mcpServers": {
    "gsc-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote@latest",
        "http://localhost:8000/mcp"
      ]  
    }
  }
} 

使用MCP检查器进行调试

您可以使用 MCP检查员 测试和调试服务器。

地方发展:

npx @modelcontextprotocol/inspector fastmcp dev src/mcp_gsc/server.py

对于Docker/远程服务器:

npx @modelcontextprotocol/inspector http://localhost:8000/mcp

示例用法

查询搜索分析

# Ask Claude:
"Show me the top 10 search queries for https://example.com/ 
from 2024-01-01 to 2024-01-31"

# Claude will use:
query_search_analytics(
    site_url="https://example.com/",
    start_date="2024-01-01",
    end_date="2024-01-31",
    dimensions=["query"],
    row_limit=10
)

获取分析摘要

# Ask Claude:
"What's the recent search performance for https://example.com/?"

# Claude will access the resource:
gsc://sites/https%3A%2F%2Fexample.com%2F/analytics/summary

SEO分析

# Ask Claude:
"Analyze the search performance for https://example.com/ 
and give me SEO recommendations"

# Claude will use the prompt:
analyze_search_performance(
    site_url="https://example.com/",
    time_period="last 30 days"
)

分析的可用维度

使用时 query_search_analytics,您可以按以下方式对数据进行分组:

  • query -搜索查询
  • page -登录页面
  • country -国家
  • device -设备类型(台式机、移动设备、平板电脑)
  • searchAppearance -搜索结果如何显示
  • date -日期

API范围

服务器需要以下OAuth作用域:

  • openid -用户标识
  • https://www.googleapis.com/auth/userinfo.email -用户电子邮件
  • https://www.googleapis.com/auth/webmasters -完全搜索控制台访问权限

对于只读访问,请修改 src/mcp_gsc/auth.py 使用 webmasters.readonly 范围。

发展

项目结构

mcp-gsc/
├── src/mcp_gsc/
│   ├── __init__.py       # Package initialization
│   ├── server.py         # Main FastMCP server
│   ├── auth.py           # Google OAuth authentication
│   ├── tools.py          # MCP tools (13 actions)
│   ├── resources.py      # MCP resources (6 data sources)
│   ├── prompts.py        # MCP prompts (4 templates)
│   └── utils.py          # Utility functions
├── examples/             # Usage examples
├── pyproject.toml        # Project configuration
├── .env.example          # Environment variables template
└── README.md             # This file

运行测试

# Install dev dependencies
uv sync --all-extras

# Run tests
pytest

# Run linting
ruff check src/

故障排除

身份验证错误

问题:“身份验证失败”或“401未经授权”

解决方案:

  • 验证您的OAuth凭据是否正确
  • 检查重定向URI是否完全匹配: http://localhost:8000/auth/callback
  • 确保在Google Cloud项目中启用搜索控制台API

拒绝许可(403)

问题:访问网站时“权限被拒绝”

解决方案:

  • 验证您是否可以在谷歌搜索控制台中访问该网站
  • 检查您是否使用了正确的网站URL格式(例如。, https://example.com/)
  • 确保您的OAuth令牌具有所需的作用域

速率限制(429)

问题:“超出费率限制”

解决方案:

  • 谷歌搜索控制台API的查询限制为每分钟1200次
  • 减少请求的频率
  • 在客户机中实现指数回退

网站URL编码

使用带有网站URL的资源时,URL必须进行URL编码:

# Correct
gsc://sites/https%3A%2F%2Fexample.com%2F/analytics/summary

# Incorrect
gsc://sites/https://example.com//analytics/summary

贡献

欢迎投稿!请随时提交拉取请求。

许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

资源

支持

对于问题和疑问:

目录标签

目录标签

数据分析PythonClaude搜索引擎优化本地部署网站管理API集成搜索分析

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

oauth

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

@modelcontextprotocol/inspector

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiooauth部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP