DEV Community

Mofidul Islam
Mofidul Islam

Posted on

How I Connected Google Search Console to Claude Code with MCP

I wanted to analyze Google Search Console data without jumping between GSC, spreadsheets, and my codebase.

So I connected GSC to Claude Code using Amin Forou's open-source mcp-gsc server.

Now I can ask:

  • Which high-impression queries are close to page one?
  • Which ranking pages have low CTR?
  • Are multiple pages competing for the same keyword?
  • Which important URLs have indexing problems?

Claude retrieves the relevant data, analyzes it alongside my code, and helps me decide what to change.

How it works

Claude Code
    ↓ MCP over stdio
mcp-gsc running locally
    ↓ OAuth 2.0
Google Search Console API
Enter fullscreen mode Exit fullscreen mode

The MCP server converts Search Console operations into tools Claude can call. It supports performance analysis, URL inspection, sitemap management, period comparisons, and property discovery.

I used OAuth so the server could access the same GSC properties as my Google account.

1. Create the Google Cloud test app

Open the Google Cloud Console and create a dedicated project.

Then:

  1. Go to APIs & Services → Library.
  2. Find and enable the Google Search Console API.
  3. Open Google Auth Platform.
  4. Configure the app name and support email under Branding.
  5. Set the audience to External and keep the app in Testing.
  6. Add your Google account under Test users.

The authorized Google account must already have access to the Search Console property.

The server requests this scope:

https://www.googleapis.com/auth/webmasters
Enter fullscreen mode Exit fullscreen mode

This is the read/write Search Console scope. Destructive mcp-gsc operations remain disabled unless GSC_ALLOW_DESTRUCTIVE=true is explicitly set.

Important: for an external app in Testing, Google normally expires the authorization and refresh token after seven days. If authentication suddenly stops, run the reauthentication tool and approve access again.

2. Download the OAuth client

In Google Auth Platform → Clients:

  1. Create an OAuth client.
  2. Select Desktop app.
  3. Download the JSON file.
  4. Store it in a permanent private location.

Example:

/Users/yourname/Documents/credentials/gsc-client-secrets.json
Enter fullscreen mode Exit fullscreen mode

Never commit this file to Git.

3. Install mcp-gsc

The simplest method uses uvx, which runs the package in an isolated Python environment.

Install uv using its official installation guide, then verify it:

uv --version
uvx --version
which uvx
Enter fullscreen mode Exit fullscreen mode

Keep the full path returned by which uvx. Claude Code may not inherit your terminal's PATH, so using only uvx can cause a spawn uvx ENOENT error.

4. Connect it to Claude Code

Replace the example paths with absolute paths from your machine:

claude mcp add-json --scope user gscServer '{
  "type": "stdio",
  "command": "/Users/yourname/.local/bin/uvx",
  "args": ["mcp-search-console"],
  "env": {
    "GSC_OAUTH_CLIENT_SECRETS_FILE": "/Users/yourname/Documents/credentials/gsc-client-secrets.json"
  }
}'
Enter fullscreen mode Exit fullscreen mode

I used user scope so the integration was available across my local projects without committing credential paths to a repository.

Verify the configuration:

claude mcp list
claude mcp get gscServer
Enter fullscreen mode Exit fullscreen mode

5. Authorize and test

Start Claude Code and ask:

Call the GSC get_capabilities tool and report the authentication status.
Enter fullscreen mode Exit fullscreen mode

The first request opens Google's OAuth flow in your browser. Sign in with the test-user account and approve access.

Then ask:

List every Search Console property I can access and show its exact identifier.
Enter fullscreen mode Exit fullscreen mode

Use the identifier returned by the API. Search Console has two formats:

Domain property:     sc-domain:example.com
URL-prefix property: https://www.example.com/
Enter fullscreen mode Exit fullscreen mode

The protocol, hostname, and trailing slash must match exactly for URL-prefix properties.

Useful tools

The server exposes tools including:

  • get_performance_overview
  • get_search_analytics
  • get_advanced_search_analytics
  • compare_search_periods
  • get_search_by_page_query
  • inspect_url_enhanced
  • batch_url_inspection
  • check_indexing_issues
  • list_sitemaps_enhanced
  • reauthenticate

For recent dashboard-like data, keep the default GSC_DATA_STATE=all. For stable reporting with a short delay, use GSC_DATA_STATE=final.

Prompts I use

Find quick SEO opportunities

For sc-domain:example.com, find non-branded queries with at least 500 impressions and positions from 11 to 20 in the last 28 days. Group them by ranking page and recommend whether to update an existing page or create a new one.
Enter fullscreen mode Exit fullscreen mode

Diagnose low CTR

Find pages ranking in positions 1 to 10 with at least 1,000 impressions and CTR below 2%. Show their leading queries and suggest accurate title improvements.
Enter fullscreen mode Exit fullscreen mode

Compare performance

Compare the latest 28 complete days with the previous 28 days. Separate changes caused by impressions, CTR, and position. Show the ten biggest winning and losing pages.
Enter fullscreen mode Exit fullscreen mode

Check indexing

Inspect the ten highest-click landing pages. Flag canonical mismatches, robots restrictions, crawl failures, and pages missing from Google's index.
Enter fullscreen mode Exit fullscreen mode

Common problems

Authentication fails after seven days: Your external OAuth app is still in Testing. Call reauthenticate and approve access again.

spawn uvx ENOENT: Use the complete path returned by which uvx.

Credentials file not found: Use an absolute path in GSC_OAUTH_CLIENT_SECRETS_FILE.

Property returns 404: Run list_properties and copy the exact sc-domain: or URL-prefix value.

No MCP tools appear: Check claude mcp list. Manual repository installations also require Python 3.11 or newer.

Security notes

  • Keep the client JSON and cached OAuth token outside your repository.
  • Never publish or share their contents.
  • Leave destructive operations disabled.
  • Review MCP tool calls before approving them.
  • Revoke the OAuth app from your Google Account if credentials are exposed.

The result

My SEO workflow changed from:

GSC → CSV export → spreadsheet → codebase
Enter fullscreen mode Exit fullscreen mode

to:

Search data → opportunity → page → code change → measurement
Enter fullscreen mode Exit fullscreen mode

The biggest benefit is not generating more SEO content. It is giving the coding assistant real search data so it can investigate the correct page before making a change.

References

Disclosure: I used AI to help edit this article. The setup is based on my own implementation and was manually verified.

Top comments (0)