Google Search Console
STDIOGoogle搜索控制台API访问MCP服务器
Google搜索控制台API访问MCP服务器
A Model Context Protocol (MCP) server that provides programmatic access to Google Search Console API data through Claude Code and Cursor.
New to this MCP server? Jump to Step-by-Step Setup Guide for complete instructions.
Before using this MCP server, you need:
submit_url_for_indexing💡 Note: You only need to set up GCP once. The CLIENT_ID and CLIENT_SECRET are reusable across multiple sites in your Search Console.
Create .mcp.json in your project root:
{ "mcpServers": { "google-search-console": { "command": "npx", "args": ["-y", "-p", "google-search-console-mcp-server", "google-search-console-mcp"], "env": { "GOOGLE_CLIENT_ID": "your-client-id.apps.googleusercontent.com", "GOOGLE_CLIENT_SECRET": "your-client-secret", "GOOGLE_REFRESH_TOKEN": "your-refresh-token" } } } }
⚠️ Important: The args must include all three parts:
"-y" - Auto-confirm npx prompt"-p", "google-search-console-mcp-server" - Package name"google-search-console-mcp" - Executable name (different from package name!)💡 Note: GOOGLE_REDIRECT_URI defaults to http://localhost:8080 and doesn't need to be specified unless you want to use a different port.
💡 Tip: You can use an existing OAuth 2.0 Client ID from other services (Supabase, Firebase, etc.) or create a new one.
submit_url_for_indexinghttp://localhost:8080 (no trailing slash!)access_denied errors!💾 Save your credentials: Copy the CLIENT_ID and CLIENT_SECRET. You'll need them in the next step.
Run the interactive setup command:
npx -y -p google-search-console-mcp-server google-search-console-mcp-setup
You'll be prompted to enter:
GOOGLE_CLIENT_ID (from step 2)GOOGLE_CLIENT_SECRET (from step 2)GOOGLE_REDIRECT_URI (press Enter for default: http://localhost:8080)A browser window will open for authentication. After authorizing, the command will output the complete .mcp.json configuration with all three credentials including the GOOGLE_REFRESH_TOKEN.
Copy the configuration and paste it into your .mcp.json, then reload Claude Code window.
Once configured, you can use the tools in Claude Desktop or Claude Code:
Show me my Google Search Console sites
or
Get search performance data for example.com for the last 7 days
list_sitesGet all Search Console sites you have access to.
Parameters: None
Example:
Search Consoleのサイト一覧を教えて
get_analyticsQuery search performance data for a specified date range.
Parameters:
siteUrl (required): Site URL (e.g., "https://example.com/")startDate (required): Start date (YYYY-MM-DD)endDate (required): End date (YYYY-MM-DD)dimensions (optional): Array of dimensions ["query", "page", "country", "device", "searchAppearance"]rowLimit (optional): Max rows (default: 100, max: 25000)startRow (optional): Starting row for paginationExample:
example.comの過去7日間のトップクエリを取得して
example.comの2025年1月1日から1月31日までの、
ページ別とデバイス別のパフォーマンスを500件取得して
get_sitemapsRetrieve sitemap information for a site.
Parameters:
siteUrl (required): Site URLExample:
example.comのサイトマップ情報を確認して
inspect_urlInspect the indexing status of a specific URL.
Parameters:
siteUrl (required): Site URL (e.g., "https://example.com/")inspectionUrl (required): Full URL to inspectExample:
https://example.com/blog/article のインデックス状態を検査して
submit_url_for_indexingSubmit a URL to Google for indexing or request URL removal using the Indexing API.
Parameters:
url (required): Full URL to submit (e.g., "https://example.com/page")type (optional): Notification type - "URL_UPDATED" (default) or "URL_DELETED"Example:
https://example.com/new-article をインデックスに送信して
https://example.com/old-page を削除申請して(type: URL_DELETED)
Note: Requires Indexing API to be enabled in Google Cloud Console and the https://www.googleapis.com/auth/indexing scope.
compare_periodsCompare search performance metrics between two time periods (e.g., this week vs last week).
Parameters:
siteUrl (required): Site URL (e.g., "https://example.com/")currentStartDate (required): Current period start date (YYYY-MM-DD)currentEndDate (required): Current period end date (YYYY-MM-DD)previousStartDate (required): Previous period start date (YYYY-MM-DD)previousEndDate (required): Previous period end date (YYYY-MM-DD)dimensions (optional): Array of dimensions to group byrowLimit (optional): Max rows (default: 100, max: 25000)Example:
Compare this week vs last week performance for example.com
Compare query performance for example.com between January 2025 and December 2024
(currentStartDate: 2025-01-01, currentEndDate: 2025-01-31,
 previousStartDate: 2024-12-01, previousEndDate: 2024-12-31,
 dimensions: ["query"])
This MCP server includes comprehensive error handling:
All tools validate inputs before making API calls:
Error messages include:
Example:
Access denied for list sites (403)
Verify your authentication credentials and ensure you have access to this Search Console property.
You may need to add your account as a test user in Google Cloud Console.
Problem: When running the setup command, you get Error during authentication: invalid_client.
Causes & Solutions:
CLIENT_ID and CLIENT_SECRET mismatch
Missing http://localhost:8080 in Authorized redirect URIs
http://localhost:8080 to "Authorized redirect URIs" in the OAuth 2.0 Client settingshttps://xxx.supabase.co/auth/v1/callback AND http://localhost:8080)CLIENT_SECRET was regenerated
Problem: npx google-search-console-mcp-server fails with "could not determine executable to run".
Solution: The package name and executable name are different. Use the correct .mcp.json configuration:
{ "mcpServers": { "google-search-console": { "command": "npx", "args": ["-y", "-p", "google-search-console-mcp-server", "google-search-console-mcp"], "env": { ... } } } }
Debugging steps:
Check the error details:
Test manually:
cd your-project-directory export GOOGLE_CLIENT_ID="your-id" export GOOGLE_CLIENT_SECRET="your-secret" export GOOGLE_REFRESH_TOKEN="your-token" npx -y google-search-console-mcp-server
Common causes:
rm -rf ~/.npm/_npxReload Claude Code: After fixing .mcp.json, reload the window (Ctrl/Cmd + Shift + P → "Developer: Reload Window")
Make sure your .mcp.json file has all three environment variables: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN.
Ensure http://localhost:8080 (no trailing slash!) is added to Authorized redirect URIs in the OAuth 2.0 Client settings in Google Cloud Console.
Site URLs must be complete URLs like:
https://example.com/ (for URL-prefix properties)sc-domain:example.com (for domain properties)Search Console data is only available for the last 16 months.
The tool will automatically retry with backoff. If you continue to hit limits:
rowLimit in analytics queriesIf you see authentication errors, your refresh token may have expired. Re-run the authentication setup:
npx -y -p google-search-console-mcp-server google-search-console-mcp-setup
Copy the new GOOGLE_REFRESH_TOKEN to your .mcp.json.
npm run build
npm run dev
node build/auth/setup-auth.js
src/
├── index.ts                 # MCP server entry point
├── auth/
│   ├── google-auth.ts       # OAuth 2.0 client
│   └── setup-auth.ts        # Authentication CLI
├── tools/
│   ├── list-sites.ts        # List sites tool
│   ├── get-analytics.ts     # Search analytics tool
│   ├── get-sitemaps.ts      # Sitemap info tool
│   ├── inspect-url.ts       # URL inspection tool
│   ├── submit-url.ts        # Submit URL for indexing
│   └── compare-periods.ts   # Compare time periods
├── types/
│   └── index.ts             # Type definitions
└── utils/
    └── error-handler.ts     # Error handling & validation
.env or .mcp.json files to version controlwebmasters.readonly) when possibleMIT
Contributions are welcome! Please feel free to submit issues or pull requests.