Skip to main content
Glama
houtini-ai

Better Google Search Console

by houtini-ai

All Properties Overview

get_overview

View an interactive grid of all synced Google Search Console properties with key metrics like clicks, impressions, CTR, and trends. Click any property to open its full dashboard for detailed analysis.

Instructions

See all your sites at a glance. Shows an interactive grid of every synced GSC property with clicks, impressions, CTR, position, percentage changes, and sparkline trends. Click any property card to open its full dashboard. If no data appears, run setup first to sync your properties.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateRangeNoDate range: "7d", "28d", "3m", "6m", "12m", "16m". Default: "28d".
sortByNoSort order for property cards. Default: "alpha".
searchNoFilter properties by domain name substring.

Implementation Reference

  • Main handler function that executes the get_overview tool logic. Fetches all GSC properties, queries SQLite databases for each property's metrics (clicks, impressions, CTR, position), calculates percentage changes vs prior period, generates sparkline data, and sorts results by the specified criteria.
    export async function getOverviewData(
      gscClient: GscClient,
      params: OverviewParams
    ): Promise<OverviewData> {
      const { dateRange = '28d', sortBy = 'alpha', search } = params;
      const { current, prior } = getPeriodDates(dateRange);
      const dataDir = getDataDir();
    
      // Get all properties from GSC API
      const allProperties = await gscClient.listProperties();
      const properties: PropertyOverview[] = [];
    
      const pctChange = (curr: number, prev: number): number | null =>
        prev === 0 ? null : Math.round(((curr - prev) / prev) * 1000) / 10;
    
      for (const prop of allProperties) {
        const dbFilename = sanitizeSiteUrl(prop.siteUrl) + '.db';
        const dbPath = join(dataDir, dbFilename);
    
        // Skip properties without synced data
        if (!existsSync(dbPath)) continue;
    
        // Extract clean domain
        let domain = prop.siteUrl
          .replace(/^sc-domain:/, '')
          .replace(/^https?:\/\//, '')
          .replace(/\/+$/, '');
    
        // Filter by search substring
        if (search && !domain.toLowerCase().includes(search.toLowerCase())) continue;
    
        const db = new Database(dbPath);
        try {
          // Summary for current period
          const currentSummary = db.queryOne(`
            SELECT
              COALESCE(SUM(clicks), 0) as clicks,
              COALESCE(SUM(impressions), 0) as impressions,
              ROUND(CAST(SUM(clicks) AS REAL) / NULLIF(SUM(impressions), 0), 4) as ctr,
              ROUND(AVG(position), 1) as avg_position
            FROM search_analytics
            WHERE date BETWEEN ? AND ?
          `, [current.startDate, current.endDate]);
    
          // Summary for prior period
          const priorSummary = db.queryOne(`
            SELECT
              COALESCE(SUM(clicks), 0) as clicks,
              COALESCE(SUM(impressions), 0) as impressions,
              ROUND(CAST(SUM(clicks) AS REAL) / NULLIF(SUM(impressions), 0), 4) as ctr,
              ROUND(AVG(position), 1) as avg_position
            FROM search_analytics
            WHERE date BETWEEN ? AND ?
          `, [prior.startDate, prior.endDate]);
    
          // Skip if no data at all
          if (currentSummary.clicks === 0 && currentSummary.impressions === 0 &&
              priorSummary.clicks === 0 && priorSummary.impressions === 0) continue;
    
          // Daily sparkline data
          const sparkline = db.query(`
            SELECT date,
              SUM(clicks) as clicks,
              SUM(impressions) as impressions
            FROM search_analytics
            WHERE date BETWEEN ? AND ?
            GROUP BY date
            ORDER BY date ASC
          `, [current.startDate, current.endDate]);
    
          // Last synced
          const meta = db.getPropertyMeta(prop.siteUrl);
    
          properties.push({
            siteUrl: prop.siteUrl,
            domain,
            lastSyncedAt: meta?.lastSyncedAt ?? null,
            current: {
              clicks: currentSummary.clicks,
              impressions: currentSummary.impressions,
              ctr: currentSummary.ctr ?? 0,
              avgPosition: currentSummary.avg_position ?? null,
            },
            changes: {
              clicksPct: pctChange(currentSummary.clicks, priorSummary.clicks),
              impressionsPct: pctChange(currentSummary.impressions, priorSummary.impressions),
              ctrPct: pctChange(currentSummary.ctr ?? 0, priorSummary.ctr ?? 0),
              avgPositionPct: (currentSummary.avg_position != null && priorSummary.avg_position != null)
                ? pctChange(currentSummary.avg_position, priorSummary.avg_position)
                : null,
            },
            sparkline,
          });
        } finally {
          db.close();
        }
      }
    
      // Sort
      switch (sortBy) {
        case 'clicks':
          properties.sort((a, b) => b.current.clicks - a.current.clicks);
          break;
        case 'impressions':
          properties.sort((a, b) => b.current.impressions - a.current.impressions);
          break;
        case 'ctr':
          properties.sort((a, b) => b.current.ctr - a.current.ctr);
          break;
        case 'position':
          properties.sort((a, b) => (a.current.avgPosition ?? 999) - (b.current.avgPosition ?? 999)); // lower is better, null sorts last
          break;
        case 'alpha':
        default:
          properties.sort((a, b) => a.domain.localeCompare(b.domain));
          break;
      }
    
      return { dateRange, sortBy, properties };
    }
  • src/server.ts:151-176 (registration)
    Registration of the get_overview tool with the MCP server. Defines the tool name, description, input schema (dateRange, sortBy, search parameters), and wraps the handler function with error handling and response formatting.
    registerAppTool(
      server,
      'get_overview',
      {
        title: 'All Properties Overview',
        description: 'See all your sites at a glance. Shows an interactive grid of every synced GSC property with clicks, impressions, CTR, position, percentage changes, and sparkline trends. Click any property card to open its full dashboard. If no data appears, run setup first to sync your properties.',
        inputSchema: {
          dateRange: z.string().optional().describe('Date range: "7d", "28d", "3m", "6m", "12m", "16m". Default: "28d".'),
          sortBy: z.enum(['alpha', 'clicks', 'impressions', 'ctr', 'position']).optional().describe('Sort order for property cards. Default: "alpha".'),
          search: z.string().optional().describe('Filter properties by domain name substring.'),
        },
        _meta: { ui: { resourceUri: overviewResourceUri } },
      },
      async (args) => {
        try {
          const data = await getOverviewData(gscClient, args);
    
          if (data.properties.length === 0) {
            return {
              content: [{
                type: 'text',
                text: 'No synced properties found. Run setup to connect and sync your Google Search Console properties.',
              }],
              structuredContent: data as any,
            };
          }
  • Type definitions for the get_overview tool: OverviewParams (input parameters), PropertyOverview (per-property metrics including current stats, percentage changes, and sparkline data), and OverviewData (complete response structure).
    export interface OverviewParams {
      dateRange?: string;
      sortBy?: 'alpha' | 'clicks' | 'impressions' | 'ctr' | 'position';
      search?: string;
    }
    
    interface PropertyOverview {
      siteUrl: string;
      domain: string;
      lastSyncedAt: string | null;
      current: {
        clicks: number;
        impressions: number;
        ctr: number;
        avgPosition: number | null;
      };
      changes: {
        clicksPct: number | null;
        impressionsPct: number | null;
        ctrPct: number | null;
        avgPositionPct: number | null;
      };
      sparkline: Array<{ date: string; clicks: number; impressions: number }>;
    }
    
    interface OverviewData {
      dateRange: string;
      sortBy: string;
      properties: PropertyOverview[];
    }
  • Helper function getPeriodDates used by get_overview to calculate current and prior period date ranges for comparison metrics. Supports multiple comparison modes and handles edge cases like leap years and month overflow.
    export function getPeriodDates(
      range: string,
      referenceDate?: Date,
      comparisonMode: ComparisonMode = 'previous_period',
      matchWeekdays: boolean = false
    ): {
      current: { startDate: string; endDate: string };
      prior: { startDate: string; endDate: string };
    } {
      const current = parseDateRange(range, referenceDate);
    
      if (comparisonMode === 'disabled') {
        // Return empty prior period — callers should check for this
        return {
          current,
          prior: { startDate: current.startDate, endDate: current.startDate },
        };
      }
    
      const startMs = new Date(current.startDate).getTime();
      const endMs = new Date(current.endDate).getTime();
      const DAY = 24 * 60 * 60 * 1000;
      const durationMs = endMs - startMs;
    
      let priorStart: Date;
      let priorEnd: Date;
    
      switch (comparisonMode) {
        case 'year_over_year': {
          const s = new Date(current.startDate);
          const e = new Date(current.endDate);
          const sDay = s.getDate();
          const eDay = e.getDate();
          s.setFullYear(s.getFullYear() - 1);
          // Handle leap year: Feb 29 → Feb 28 (setFullYear may roll to Mar 1)
          if (s.getDate() !== sDay) s.setDate(0); // last day of previous month
          e.setFullYear(e.getFullYear() - 1);
          if (e.getDate() !== eDay) e.setDate(0);
          priorStart = s;
          priorEnd = e;
          break;
        }
        case 'previous_month': {
          const s = new Date(current.startDate);
          const e = new Date(current.endDate);
          const sMonth = (s.getMonth() - 1 + 12) % 12;
          const eMonth = (e.getMonth() - 1 + 12) % 12;
          s.setMonth(s.getMonth() - 1);
          // Handle day overflow: e.g. Mar 31 → setMonth(-1) → "Feb 31" → Mar 3
          if (s.getMonth() !== sMonth) s.setDate(0); // last day of intended month
          e.setMonth(e.getMonth() - 1);
          if (e.getMonth() !== eMonth) e.setDate(0);
          priorStart = s;
          priorEnd = e;
          break;
        }
        case 'previous_period':
        default: {
          priorEnd = new Date(startMs - DAY);
          priorStart = new Date(priorEnd.getTime() - durationMs);
          break;
        }
      }
    
      // Match weekdays: shift prior period so that the start day-of-week matches
      if (matchWeekdays) {
        const currentStartDay = new Date(current.startDate).getDay();
        const priorStartDay = priorStart.getDay();
        let diff = currentStartDay - priorStartDay;
        // Find the closest shift that aligns weekdays (within ±3 days)
        if (diff > 3) diff -= 7;
        if (diff < -3) diff += 7;
        priorStart = new Date(priorStart.getTime() + diff * DAY);
        priorEnd = new Date(priorEnd.getTime() + diff * DAY);
    
        // Safety: ensure prior period never overlaps with current period
        const currentStartMs = new Date(current.startDate).getTime();
        if (priorEnd.getTime() >= currentStartMs) {
          const overshoot = priorEnd.getTime() - currentStartMs + DAY;
          priorStart = new Date(priorStart.getTime() - overshoot);
          priorEnd = new Date(priorEnd.getTime() - overshoot);
        }
      }
    
      return {
        current,
        prior: {
          startDate: formatDate(priorStart),
          endDate: formatDate(priorEnd),
        },
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the output format ('interactive grid') and includes a prerequisite action ('run setup first'), which adds useful context. However, it doesn't cover other behavioral aspects like whether this is a read-only operation, performance characteristics, or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by additional details in a logical flow. Every sentence earns its place by explaining features, interaction, and prerequisites without redundancy. It's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is mostly complete. It explains what the tool does, the output format, and a prerequisite. However, it could improve by mentioning the tool's read-only nature or linking to sibling tools for related actions, which would enhance completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, such as explaining how 'search' interacts with the grid or default behaviors. This meets the baseline of 3 when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('see', 'shows') and resources ('all your sites', 'every synced GSC property'). It distinguishes from siblings like 'list_properties' by specifying it shows an interactive grid with detailed metrics (clicks, impressions, CTR, etc.) and trends, rather than just listing properties.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('see all your sites at a glance') and includes a prerequisite ('If no data appears, run setup first to sync your properties'). However, it doesn't explicitly state when not to use it or name alternatives among siblings, such as 'get_dashboard' for individual property details.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/houtini-ai/better-search-console'

If you have feedback or need assistance with the MCP directory API, please join our Discord server