Skip to main content
Glama

search_analytics_query

Retrieve and analyze Google Search Console traffic metrics including clicks, impressions, CTR, and position data with flexible filtering and grouping options.

Instructions

Query search traffic data from Google Search Console. Returns clicks, impressions, CTR, and position data with flexible filtering and grouping.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteUrlYesThe site URL
startDateYesStart date in YYYY-MM-DD format
endDateYesEnd date in YYYY-MM-DD format
dimensionsNoDimensions to group by: country, device, page, query, searchAppearance, date, hour (hour requires dataState='hourly_all')
typeNoSearch type filter: web, image, video, news, discover, googleNews (default: web)
dimensionFilterGroupsNoFilter groups to apply to the query
aggregationTypeNoHow data is aggregated (default: auto)
rowLimitNoMaximum number of rows to return (1-25000, default: 1000)
startRowNoZero-based row offset for pagination
dataStateNo'all' includes fresh (possibly incomplete) data, 'final' only finalized data, 'hourly_all' required when using 'hour' dimension

Implementation Reference

  • The handler for search_analytics_query, which constructs the API request body and calls the Google Search Console API.
    async ({
      siteUrl,
      startDate,
      endDate,
      dimensions,
      type,
      dimensionFilterGroups,
      aggregationType,
      rowLimit,
      startRow,
      dataState,
    }) => {
      try {
        const body: Record<string, unknown> = { startDate, endDate };
        if (dimensions) body.dimensions = dimensions;
        if (type) body.type = type;
        if (dimensionFilterGroups)
          body.dimensionFilterGroups = dimensionFilterGroups;
        if (aggregationType) body.aggregationType = aggregationType;
        if (rowLimit !== undefined) body.rowLimit = rowLimit;
        if (startRow !== undefined) body.startRow = startRow;
        if (dataState) body.dataState = dataState;
    
        const result = await apiCall(
          `${WEBMASTERS_BASE}/sites/${encodeSiteUrl(siteUrl)}/searchAnalytics/query`,
          {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify(body),
          },
        );
        return toolResult(result);
      } catch (e) {
        return errorResult(e);
  • src/index.ts:403-450 (registration)
    The registration and schema definition for the search_analytics_query tool using zod validation.
    server.tool(
      "search_analytics_query",
      "Query search traffic data from Google Search Console. Returns clicks, impressions, CTR, and position data with flexible filtering and grouping.",
      {
        siteUrl: z.string().describe("The site URL"),
        startDate: z
          .string()
          .describe("Start date in YYYY-MM-DD format"),
        endDate: z
          .string()
          .describe("End date in YYYY-MM-DD format"),
        dimensions: z
          .array(dimensionEnum)
          .optional()
          .describe(
            "Dimensions to group by: country, device, page, query, searchAppearance, date, hour (hour requires dataState='hourly_all')",
          ),
        type: searchTypeEnum
          .optional()
          .describe(
            "Search type filter: web, image, video, news, discover, googleNews (default: web)",
          ),
        dimensionFilterGroups: z
          .array(dimensionFilterGroupSchema)
          .optional()
          .describe("Filter groups to apply to the query"),
        aggregationType: z
          .enum(["auto", "byPage", "byProperty", "byNewsShowcasePanel"])
          .optional()
          .describe("How data is aggregated (default: auto)"),
        rowLimit: z
          .number()
          .min(1)
          .max(25000)
          .optional()
          .describe("Maximum number of rows to return (1-25000, default: 1000)"),
        startRow: z
          .number()
          .min(0)
          .optional()
          .describe("Zero-based row offset for pagination"),
        dataState: dataStateEnum
          .optional()
          .describe(
            "'all' includes fresh (possibly incomplete) data, 'final' only finalized data, 'hourly_all' required when using 'hour' dimension",
          ),
      },
      async ({
Behavior2/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 mentions what data is returned but doesn't cover important behavioral aspects like authentication requirements, rate limits, data freshness constraints, pagination behavior, error conditions, or whether this is a read-only operation. The mention of 'flexible filtering and grouping' is vague and doesn't provide concrete behavioral information.

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 perfectly concise with two sentences that efficiently communicate the tool's core functionality. The first sentence establishes purpose and source, while the second specifies the return data and key capabilities. Every word earns its place with zero redundancy.

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

Completeness2/5

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

For a complex tool with 10 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the structure of returned data, error handling, authentication requirements, or practical usage patterns. The mention of 'flexible filtering and grouping' is too vague to compensate for the missing behavioral context needed for effective tool invocation.

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?

The schema description coverage is 100%, providing comprehensive documentation for all 10 parameters. The description adds minimal value beyond the schema, mentioning only 'flexible filtering and grouping' which loosely relates to the dimensions and dimensionFilterGroups parameters. This meets the baseline score 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 specific action ('Query search traffic data'), source ('from Google Search Console'), and output metrics ('Returns clicks, impressions, CTR, and position data'). It distinguishes itself from sibling tools by focusing on analytics querying rather than indexing, sitemaps, or site management operations.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, nor does it mention any prerequisites or contextual constraints. While it mentions 'flexible filtering and grouping', it doesn't specify when this tool is appropriate compared to other analytics or reporting methods.

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/mikusnuz/gsc-mcp'

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