Google Search Console MCP Server

repository·master·Indexed 42 days ago

https://github.com/ahonn/mcp-server-gsc

A Model Context Protocol (MCP) server providing AI assistants with access to Google Search Console performance data. Version 0.3.0 features include a 25K row limit, regex filters, URL index inspection, sitemap management, and automatic 'Quick Wins' detection to identify SEO optimization opportunities.

Tokens
4.3K
Snippets
15
Records
22
Agent score
54%

What's inside mcp-server-gsc

  1. Configure Google Search Console API credentials

    master

    To use this server, you must set up a Google Cloud Project and a Service Account with access to your Search Console properties.

    1. Enable the API: In the Google Cloud Console, go to "APIs & Services" > "Library", search for "Search Console API", and enable it.
    2. Create a Service Account:
      • Navigate to "APIs & Services" > "Credentials".
      • Click "Create Credentials" > "Service Account".
      • Complete the setup and create a new key in JSON format. This file will be downloaded automatically.
    3. Grant Property Access:
      • Open your Google Search Console property.
      • Add the service account email (e.g., name@project.iam.gserviceaccount.com) as a Property Administrator.
  2. Use enhanced_search_analytics for advanced SEO data

    master

    The enhanced_search_analytics tool allows for more complex queries than the standard search_analytics tool. It supports:

    • High Row Limits: Up to 25,000 rows.
    • Regex Filters: Advanced filtering using regular expressions.
    • Quick Wins Detection: Identifying optimization opportunities based on specific thresholds.
    • Dimension Filtering: Filtering by page, query, country, or device.

    Note that country and device filters use an equals operator, while page and query filters can use a user-provided filterOperator (e.g., for regex).

  3. Configure Claude Desktop for GSC

    master

    Add the following configuration to your Claude Desktop configuration file to enable the gsc MCP server. Ensure the GOOGLE_APPLICATION_CREDENTIALS environment variable points to the absolute path of your downloaded JSON credentials file.

    {
      "mcpServers": {
        "gsc": {
          "command": "npx",
          "args": ["-y", "mcp-server-gsc"],
          "env": {
            "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/credentials.json"
          }
        }
      }
    }
  4. Enable Quick Wins detection in Search Analytics

    master

    The EnhancedSearchAnalyticsSchema allows you to automatically detect 'Quick Wins'—SEO opportunities where small changes could yield significant traffic.

    To use this, set enableQuickWins: true. You can optionally customize the detection thresholds using quickWinsThresholds.

    Quick Win Thresholds

    • minImpressions: Minimum impressions threshold (default: 50).
    • maxCtr: Maximum CTR percentage (default: 2.0).
    • positionRangeMin: Minimum position (default: 4).
    • positionRangeMax: Maximum position (default: 10).
    • estimatedClickValue: Estimated value per click for ROI (default: 1.0).
    • conversionRate: Estimated conversion rate for ROI (default: 0.03).
    {
      "siteUrl": "http://www.example.com/",
      "startDate": "2023-01-01",
      "endDate": "2023-01-31",
      "enableQuickWins": true,
      "quickWinsThresholds": {
        "minImpressions": 100,
        "maxCtr": 1.5,
        "positionRangeMin": 3,
        "positionRangeMax": 8
      }
    }
  5. Use detect_quick_wins to find SEO opportunities

    master

    The detect_quick_wins tool automates the process of finding SEO 'low-hanging fruit'. It performs a comprehensive analysis by fetching up to 25,000 rows of search data and then applying thresholds to identify queries or pages that are performing well but have room for improvement.

    It uses the following thresholds for detection:

    • minImpressions: Minimum impressions required.
    • maxCtr: Maximum Click-Through Rate (CTR) to target.
    • positionRangeMin: Minimum search position.
    • positionRangeMax: Maximum search position.

    The tool returns a JSON object containing the list of quickWins, the totalOpportunities count, and the applied thresholds.

  6. Run the Google Search Console MCP Server via CLI

    master

    The server is designed to run as a Node.js executable using stdio transport. To run the server, you must provide a path to your Google Service Account credentials via the GOOGLE_APPLICATION_CREDENTIALS environment variable. The server will then start and listen for requests over standard input/output.

    export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-file.json"
    node path/to/mcp-server-gsc/dist/index.js
  7. Advanced search_analytics examples

    master

    Below are advanced usage patterns for the search_analytics tool, including regex filtering and Quick Wins detection.

    // Advanced Filtering with Regex
    {
      "siteUrl": "https://example.com",
      "startDate": "2024-01-01",
      "endDate": "2024-01-31",
      "dimensions": "page,query",
      "queryFilter": "regex:(AI|machine learning|ML)",
      "filterOperator": "includingRegex",
      "deviceFilter": "MOBILE",
      "rowLimit": 10000
    }
    
    // Quick Wins Detection
    {
      "siteUrl": "https://example.com",
      "startDate": "2024-01-01",
      "endDate": "2024-01-31",
      "dimensions": "query,page",
      "detectQuickWins": true,
      "quickWinsConfig": {
        "positionRange": [4, 15],
        "minImpressions": 500,
        "minCtr": 2
      }
    }
  8. Use the search_analytics tool

    master

    The search_analytics tool retrieves performance data from Google Search Console. It supports advanced filtering, regex, and automatic 'Quick Wins' detection.

    Required Parameters

    • siteUrl: Site URL (e.g., http://www.example.com/ or sc-domain:example.com)
    • startDate: Start date (YYYY-MM-DD)
    • endDate: End date (YYYY-MM-DD)

    Optional Parameters

    • dimensions: Comma-separated list: query, page, country, device, searchAppearance, date
    • type: Search type: web, image, video, news, discover, googleNews
    • aggregationType: auto, byNewsShowcasePanel, byProperty, byPage
    • rowLimit: Max rows (default: 1000, max: 25000)
    • dataState: all or final (default: final)

    Filter Parameters

    • pageFilter: URL filter (use regex: prefix for regex)
    • queryFilter: Query filter (use regex: prefix for regex)
    • countryFilter: ISO 3166-1 alpha-3 code (e.g., USA, CHN)
    • deviceFilter: DESKTOP, MOBILE, TABLET
    • searchAppearanceFilter: e.g., AMP_BLUE_LINK, AMP_TOP_STORIES
    • filterOperator: equals, contains, notEquals, notContains, includingRegex, excludingRegex

    Quick Wins Detection

    Enable detectQuickWins: true to automatically identify optimization opportunities. You can configure this via quickWinsConfig:

    • positionRange: Position range to consider (default: [4, 20])
    • minImpressions: Minimum impressions threshold (default: 100)
    • minCtr: Minimum CTR percentage (default: 1)
    {
      "siteUrl": "https://example.com",
      "startDate": "2024-01-01",
      "endDate": "2024-01-31",
      "dimensions": "query,page",
      "rowLimit": 5000
    }
  9. Configure the GOOGLE_APPLICATION_CREDENTIALS environment variable

    master
    The server requires the GOOGLE_APPLICATION_CREDENTIALS environment variable to be set. This variable must contain the absolute file path to a valid Google Service Account JSON key file. If this variable is missing, the server will exit with an error: GOOGLE_APPLICATION_CREDENTIALS environment variable is required.
  10. Create an MCP server with createServer()

    master

    The createServer function is the primary entrypoint for initializing a Google Search Console MCP server. It requires a credentials string (typically a service account key or authentication token) to initialize the SearchConsoleService. The returned Server instance provides access to various Google Search Console tools via the Model Context Protocol.

    Usage

    import { createServer } from './src/server.js';
    
    const credentials = 'YOUR_GOOGLE_SEARCH_CONSOLE_CREDENTIALS';
    const server = createServer(credentials);
    
    // The server instance can now be used with an MCP transport (e.g., Stdio)
    import { createServer } from './src/server.js';
    
    const credentials = 'YOUR_GOOGLE_SEARCH_CONSOLE_CREDENTIALS';
    const server = createServer(credentials);
  11. Manage Sitemaps

    master

    The service provides methods to manage sitemaps for a site. Like searchAnalytics, these methods automatically attempt to normalize the siteUrl to a sc-domain: format if a permission error occurs.

    • listSitemaps(requestBody): Lists sitemaps for a site.
    • getSitemap(requestBody): Retrieves a specific sitemap.
    • submitSitemap(requestBody): Submits a new sitemap.

    All methods accept request bodies conforming to the webmasters_v3 API types.

    // List sitemaps
    const sitemaps = await service.listSitemaps({ siteUrl: 'https://example.com/' });
    
    // Submit a sitemap
    await service.submitSitemap({
      siteUrl: 'https://example.com/',
      feedpath: '/sitemap.xml'
    });