mcp-google-gsc
Enables querying Google Search Console search analytics (clicks, impressions, CTR, position) with flexible dimensions, inspecting URL indexing and mobile usability, and listing verified properties, all via Claude.
README
mcp-google-gsc
MCP server for Google Search Console -- search analytics, URL inspection, and site management via Claude.
Features
- Search Analytics -- Query clicks, impressions, CTR, and position with flexible dimension filters (query, page, device, country, date)
- URL Inspection -- Check indexing status, mobile usability, and rich results for any URL
- Site Listing -- List all verified Search Console properties accessible to your authenticated account (OAuth user or service account)
- Multi-Client Support -- Manage multiple GSC properties with per-directory config mapping
Installation
From npm
npm install mcp-google-gsc
From source
git clone https://github.com/mharnett/mcp-search-console.git
cd mcp-google-gsc
npm install
npm run build
Configuration
Security: Never share your .mcp.json file or commit it to git -- it may contain API credentials. Add .mcp.json to your .gitignore.
mcp-gsc supports two authentication modes. Pick whichever fits your setup. Neither requires any file living at a hardcoded machine-local path -- credentials come from environment variables (or a config.json you create).
Which mode to use:
- Service Account (Mode B) -- recommended for unattended / server / headless use. A service account has no interactive login to expire or re-consent, so it is the right fit for always-on deployments. The one setup requirement is that the service account's email must be granted access on each Search Console property you want to query (see Mode B).
- User OAuth (Mode A) -- for personal / interactive use, where you want to authorize with your own Google login.
Precedence when both are configured: if a service-account keyfile is explicitly set (GOOGLE_APPLICATION_CREDENTIALS, or credentials_file in config.json), it wins over any OAuth refresh token or stored OAuth credentials. If neither is configured, the server fails loudly at startup with an onboarding message rather than silently guessing -- there is no machine-local default and no silent runtime failover between modes.
Mode A: User OAuth (bring your own Google account)
Use this if you want to authorize with your own Google login (the account that has Search Console access). Best for personal / interactive use.
- In the Google Cloud Console, create an OAuth 2.0 Client ID of type Desktop app and enable the Search Console API. (For a Desktop-app client, Google accepts any
http://localhostloopback redirect -- you do not need to pre-register a port.) - Export your client credentials:
export GOOGLE_GSC_CLIENT_ID=...apps.googleusercontent.com export GOOGLE_GSC_CLIENT_SECRET=... - Mint a refresh token (opens your browser, uses PKCE +
access_type=offline):node get-refresh-token.cjsDo not redirect this command's stdout to a shared log -- it prints the refresh token to stdout by design.
- Copy the printed line into your environment:
export GOOGLE_GSC_REFRESH_TOKEN=...
The server reads GOOGLE_GSC_CLIENT_ID, GOOGLE_GSC_CLIENT_SECRET, and GOOGLE_GSC_REFRESH_TOKEN from the environment at runtime.
Alternatively, run the guided helper npx mcp-gsc-auth, which performs the same PKCE OAuth flow, lets you pick a default Search Console property, and writes the result to a per-user credentials file.
Mode B: Service Account (recommended for unattended / server use)
Use this for server / headless / always-on contexts -- it is the recommended path when no human is present to complete or refresh an interactive login.
- Create a Google Cloud service account with Search Console API access and download its JSON key file.
- Grant the service account's email access on each Search Console property you want to query (add it as a user in Search Console). Without this grant on the property, the service account can authenticate but will see no sites.
- Point the server at the key file via an environment variable (no hardcoded path):
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-key.json
OAuth scope
Both modes request a single, read-only scope: https://www.googleapis.com/auth/webmasters.readonly. All four tools are reads -- nothing writes -- so the server never asks for read/write access.
The scope is defined once in config.json under oauth.scope (see config.example.json). The OAuth helper and the runtime read the same value, so they never drift. If config.json is absent (e.g. a fresh install), the committed read-only default is used.
Multi-client config (optional)
To map working directories to Search Console properties, create a config.json in the project root (see config.example.json):
{
"oauth": {
"scope": "https://www.googleapis.com/auth/webmasters.readonly"
},
"clients": {
"my-project": {
"name": "My Project",
"folder": "/path/to/project",
"site_url": "https://example.com/"
}
}
}
Usage
Add to your Claude Code .mcp.json:
{
"mcpServers": {
"gsc": {
"command": "node",
"args": ["/path/to/mcp-gsc/dist/index.js"]
}
}
}
Or if installed globally:
{
"mcpServers": {
"gsc": {
"command": "npx",
"args": ["mcp-google-gsc"]
}
}
}
Claude Desktop: Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows).
Tools
| Tool | Description |
|---|---|
gsc_get_client_context |
Detect the GSC property from your working directory based on config mapping |
gsc_list_sites |
List all verified Search Console properties accessible to the authenticated account |
gsc_search_analytics |
Query search performance data (clicks, impressions, CTR, position) with dimension and filter support |
gsc_inspection |
Inspect a URL for indexing status, mobile usability, and rich results |
gsc_search_analytics
Supports dimensions: query, page, device, country, date. Filter by any dimension with operators like equals, contains, notContains. Date range defaults to the last 28 days.
gsc_inspection
Returns index coverage, crawl status, mobile usability verdict, and rich result details for a specific URL within a property.
Architecture
- Resilience -- Uses cockatiel for retry with exponential backoff and circuit breaker patterns on all Google API calls
- Logging -- Structured logging via pino with configurable log levels
- Response Handling -- Responses truncated at 200KB to stay within MCP transport limits
License
MIT -- see LICENSE.
Built by Mark Harnett / drak-marketing
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。