Skip to content

EdgeComet MCP query guide ​

The query tool reads EdgeComet data through a JSON relation tree called an ir. You, or your agent, describe which source to read and how to filter, group and join it, and EdgeComet runs it.

The authoritative version for your site comes from get_schema. It lists your exact field names, custom extraction fields, segments and the grammar your site adds, and with grammar: true it returns the complete grammar even when a client cuts tool descriptions short. Agents call it before they write a query.

The envelope ​

Every call takes a websiteId, a time window (days, or from + to), an optional segmentId, and for crawl data, the crawl to read (crawl, vs, window: "crawl"). See Shared arguments.

query adds its own paging arguments: limit, cursor and count_only. export takes the same ir and writes it to a CSV.

A query that reads crawl data together with bot requests or Search Console has to state its span: window: "crawl" for the crawl's own span, days, or from + to. Without one, the query is refused with a message that names the three options.

The grains ​

A grain is the row shape a source produces.

DataGrainOne row is
Bot requestsevents_eventA single request: bot, URL, status, how it was served, timing and the page tags parsed from it
Bot requestsevents_pageA URL, with the SEO digest from its latest bot fetches and its visit counts per bot family
Page change logpage_changeOne change of one tracked field on one page, with the old and new value
Search Consolegsc_pageA URL's totals for the window
Search Consolegsc_queryA date + URL + search query row
Search Consolegsc_page_trendA URL's current-window against prior-window deltas
Search Consolegsc_generalA day for the whole property, with the desktop and mobile split, and no URL
Evergreen Crawlcrawl_pageA URL as the selected crawl saw it
Evergreen Crawlcrawl_linkA directed link between two URLs
Evergreen Crawlcrawl_redirectA URL that answered with a 3xx
Evergreen Crawlcrawl_page_trendA URL in the selected crawl, its baseline, or both
Evergreen Crawlcrawl_link_trendA source and target link pair in the selected crawl, its baseline, or both
Evergreen Crawlcrawl_issue_pageA URL carrying at least one crawl issue, with the issue IDs
Sitemapsitemap_urlA URL your XML sitemap lists, with its lastmod

The crawl grains read one Evergreen Crawl, chosen by crawl. The two trend grains compare it with its baseline crawl, or with the crawl named in vs, and most of their fields come as _curr and _prev pairs.

movement says added, removed or stable. On crawl_link_trend it can also say source_new or source_unseen: the source page was not seen in one of the two crawls, which leaves the link unknown. crawl_link has no single URL: a join or membership over it names src_url_hash or tgt_url_hash with on.

A fifteenth grain, events_page_trend, compares two windows of the bot log. A plain query refuses it. For what a page looks like now, use events_page.

Grains that read differently than their names suggest ​

  • gsc_query is a lower bound. Google withholds the text of rare queries, which makes summed clicks and impressions come out below gsc_page for the same window. Compare query-grain numbers with each other.
  • Position and CTR are weighted. avg of position or ctr at gsc_query returns the impression-weighted average, the number Search Console itself reports.
  • gsc_general is Google's property report, not gsc_page summed: a results page showing several of your URLs counts once here and once per URL there. It has no URL, joins to nothing and cannot be scoped to a segment.
  • Page tags on raw events. At events_event, the page content columns (title, meta_description, h1 and the rest) are filled only on render, precache and bypass rows. Cache-served rows replay a stored response and leave them blank. events_page handles this for you.
  • Pre-cache is not a bot. precache rows are EdgeComet warming its own cache and carry no bot. Exclude them when you count crawl volume.
  • Sitemap URLs are normalized lightly. An anti-join from sitemap_url against crawl or event data can under-match. Check a short result against the URL text before reporting a page as missing.
  • Link rows are never segment-scoped. A segmentId does not narrow crawl_link or crawl_link_trend. Filter src_url or tgt_url instead, such as contains "/blog/", or test an end with {"segment": <id>, "on": "src_url"}.

The page change log ​

page_change holds one row per change of one tracked field on one page, the rows the Changes report counts:

  • field names what changed: status_code, redirect_to, index_status, meta_robots, canonical_url, title, meta_description, h1, structured_data_types, hreflang, page_minhash (the body content), or ext:id<N> for a custom extraction rule with change tracking on.
  • kind says how it changed (filled, emptied, rewritten, changed, added, removed, replaced), and old_value and new_value hold both sides.
  • outcomes lists the report outcomes the change meets, such as became_blocked or became_error. Lost indexability is has_any of became_blocked and became_non_canonical.
  • cross_source eq 0 and edge_seo neq 1 keep the changes the site made itself and leave out changes caused by how EdgeComet served the page or by an Edge SEO rule.

count() counts changes. The report counts pages: use count_distinct of url_hash. One edit is one row per cache dimension.

Nodes ​

Every node has a "node" key, and the child relation sits under "from":

json
{"node": "source", "grain": "events_page"}
{"node": "filter", "from": R, "where": P}
{"node": "aggregate", "from": R, "group_by": ["url"],
 "metrics": [{"fn": "sum", "field": "clicks"}],
 "having": {"metric": "sum_clicks", "op": "gt", "value": 9}}
{"node": "select", "from": R, "fields": ["url", "title"]}
{"node": "join", "kind": "left", "left": R, "right": R2, "bring": ["clicks"]}
{"node": "compute", "from": R, "as": "folder",
 "expr": {"fn": "path_level", "args": [{"field": "url"}, {"lit": 1}]}}
{"node": "reduce", "from": R, "to": "url_hash"}
{"node": "union", "of": [R, R2]}
{"node": "order", "from": R, "by": "sum_clicks", "dir": "desc"}
{"node": "limit", "from": R, "n": 50}

order and limit are their own nodes wrapped around the tree, never keys on aggregate or select, and by names exactly one field.

Metrics ​

aggregate metrics take fn + field: count, count_distinct, sum, avg, min, max, median, quantile, stddev, arg_max and arg_min. quantile also takes a level between 0 and 1, and arg_max and arg_min take by, the column the row is chosen by.

The alias is derived, and it is the name having and order reference: count stays count, count_distinct on f becomes cd_f, a quantile at 0.9 becomes p90_f, arg_max on f by b becomes argmax_f_by_b, and everything else becomes fn_field, such as sum_clicks.

A metric with a where predicate counts only the rows that match it, which puts several populations side by side in one rollup. A conditional metric names its alias with as.

"group_by": [] returns one row of totals over the whole set. A metric over no rows is null rather than zero: it fails every having comparison and sorts last.

Joins ​

join attaches columns from the right relation to each row of the left one, matched on url_hash (on link rows, the end named with on). Name the columns to copy in bring. They must not repeat a left field.

KindKeeps
innerLeft rows that have a match
leftEvery left row. Brought columns are absent where nothing matched
semiLeft rows that have a match, with no bring
antiLeft rows with no match, with no bring
metricLike inner, for a right side that only carries numbers

An absent brought column is not 0. Tell them apart with the missing and present operators.

To rank by a brought column, aggregate the join by url and wrap that in order. A plain select of a join stays in URL-hash order.

events_event and page_change rows have no single row per URL. They cannot be the right side of a join, or the left side of one that brings columns. Connect them to pages with a membership predicate instead.

Derived columns ​

compute adds one column, which you then filter, group or order by its as name. Available functions: length, word_count, lower, upper, ratio, abs, round, bucket, xxHash64, normalize, first, element, domain, path, query_string, query_param, cut_query, path_depth and path_level. An argument is {"field": "<name>"} or {"lit": <value>}.

element reads one item of a list by position, and a negative position counts from the end. {"fn": "element", "args": [{"field": "breadcrumb_urls"}, {"lit": -1}]} is the page's own category page, as its breadcrumb states it.

Named groups ​

A case expression puts each row in a named group, which you then group by:

json
{"node": "compute", "from": R, "as": "section",
 "expr": {"fn": "case",
          "when": [{"if": {"segment": 203}},
                   {"if": {"field": "url", "op": "contains", "value": "/docs/"}, "then": "Docs"}],
          "else": "Everything else"}}

Each row takes the name of the first branch it matches, otherwise else. A branch whose if is a saved segment can leave out then and takes the segment's name. A case holds 1 to 20 branches.

Reduce and union ​

reduce builds the per-URL digest from a filtered slice of events_event. Every events_page field above it, such as visit counts, first and last seen, and page fields, then covers only the matching requests. Use it to scope a per-URL question to a date range or one bot family.

union merges two or more relations of the same grain into one row per URL. For "A or B" over one relation, use an or predicate instead.

Raw events ​

A top-level select over events_event returns individual requests, newest first unless you wrap it in order, capped at 50 rows with no cursor. Narrow the filter or the window instead of paging.

Requests from fake bots are excluded from every read. To ask about them, set "include_fake_bots": true on the events_event source, then filter or group by ip_validated (0 unverifiable, 1 verified, 2 fake, 3 error).

allocation (wasted, questionable or valuable) is your site's own crawl budget class for each request, the same rules the Crawl Efficiency report uses. It works in filters only: for the full split, run one rollup per class.

Predicates ​

Comparisons use field / op / value (value2 for between). Valueless operators leave out value:

json
{"field": "bot_type", "op": "in", "value": ["ai_bot"]}
{"field": "meta_description", "op": "empty"}

Operators are tokens, never symbols, and depend on the field type:

TypeOperators
stringeq, neq, contains, not_contains, starts_with, ends_with, regex, not_regex, in, not_in, empty, not_empty
int, floateq, neq, gt, gte, lt, lte, between, in, not_in
enumeq, neq, in, not_in
date, datetimeeq, gt, gte, lt, lte, between
string[]has, not_has, has_any, has_all, any_contains, none_contains, is_empty, not_empty, len_eq, len_gt, len_lt

missing and present test whether a value is absent: on optional fields, on custom extraction fields, and on columns a left join brought across.

Combine predicates with {"and": [...]}, {"or": [...]} and {"not": ...}.

A value of {"field": "<name>"} compares two columns, with eq, neq, gt, gte, lt or lte:

json
{"field": "canonical_url", "op": "neq", "value": {"field": "url"}}

{"segment": <id>} is true for rows whose URL matches that saved segment's current rules. Add "on" to test another URL field, such as src_url or tgt_url on link rows. Only segments built from URL rules work in a query.

A membership predicate tests a field against another relation, a select of exactly one field. This is how a query crosses grains without a join:

json
{"field": "url_hash", "op": "in", "rel": {"node": "select", "fields": ["url_hash"], "from": R}}

Query classes ​

Two shapes in Search Console data are named, and you ask for them as having leaves rather than rebuilding them from word counts:

  • {"query_class": "fan_out"}: long queries that drew impressions but no clicks, the pattern AI-driven query expansion leaves. The word threshold is at least eight and set per site from its own Search Console data, and get_schema states yours.
  • {"query_class": "trash"}: rank-tracker artifacts shaped like "12 : some keyword".

They combine with and, or and not, and work only on a gsc_query aggregate whose group_by includes query.

Paging ​

  • A top-level select returns rows in URL-hash order, paged by the limit + cursor call arguments, up to 50 rows a page. order and limit nodes are rejected there, except over events_event. total comes on the first page only.
  • A top-level aggregate returns group rows ranked by an order wrap (default: the leading metric, descending) as a bounded top-N of up to 200 groups, with no cursor. If the result is truncated, raise the limit, tighten having or filter earlier.
  • count_only: true returns only the total, the cheap way to size a question before reading rows.

Worked examples ​

Every example ran on a live EdgeComet site.

Top search queries by clicks ​

Rank-tracker noise excluded.

json
{"node": "limit", "n": 20, "from":
  {"node": "order", "by": "sum_clicks", "dir": "desc", "from":
    {"node": "aggregate",
     "from": {"node": "source", "grain": "gsc_query"},
     "group_by": ["query"],
     "metrics": [{"fn": "sum", "field": "clicks"},
                 {"fn": "sum", "field": "impressions"}],
     "having": {"not": {"query_class": "trash"}}}}}

Keywords with two or more competing URLs ​

The cannibalization shape.

json
{"node": "aggregate",
 "from": {"node": "source", "grain": "gsc_query"},
 "group_by": ["query"],
 "metrics": [{"fn": "count_distinct", "field": "url"}],
 "having": {"metric": "cd_url", "op": "gte", "value": 2}}

Recent AI bot fetches ​

json
{"node": "select", "fields": ["url", "bot", "event_date_time"], "from":
  {"node": "filter",
   "from": {"node": "source", "grain": "events_event"},
   "where": {"field": "bot_type", "op": "in", "value": ["ai_bot"]}}}

Requests, errors and slow responses per bot family ​

Conditional metrics and a quantile in one rollup, with pre-cache excluded.

json
{"node": "aggregate",
 "from": {"node": "filter",
          "from": {"node": "source", "grain": "events_event"},
          "where": {"field": "event_type", "op": "neq", "value": "precache"}},
 "group_by": ["bot_type"],
 "metrics": [{"fn": "count"},
             {"fn": "count", "as": "error_events",
              "where": {"field": "status_code", "op": "gte", "value": 400}},
             {"fn": "quantile", "field": "serve_time", "level": 0.9}]}

Wasted crawl and how much Googlebot spends on it ​

Pages bots fetched that your crawl budget rules class as wasted, with their Googlebot visits. Run it again with questionable and valuable for the full split.

json
{"node": "aggregate",
 "from": {"node": "reduce", "to": "url_hash",
          "from": {"node": "filter",
                   "from": {"node": "source", "grain": "events_event"},
                   "where": {"field": "allocation", "op": "eq", "value": "wasted"}}},
 "group_by": [],
 "metrics": [{"fn": "count_distinct", "field": "url_hash"},
             {"fn": "sum", "field": "googlebot_visits"}]}

Pages without a meta description, with their clicks ​

A left join keeps pages Search Console never saw, with clicks absent.

json
{"node": "select", "fields": ["url", "title", "clicks", "position"], "from":
  {"node": "join", "kind": "left", "bring": ["clicks", "position"],
   "left": {"node": "filter",
            "from": {"node": "source", "grain": "events_page"},
            "where": {"and": [
              {"field": "has_seo", "op": "eq", "value": 1},
              {"field": "status_code", "op": "eq", "value": 200},
              {"field": "meta_description", "op": "empty"}]}},
   "right": {"node": "source", "grain": "gsc_page"}}}

Bot visits per top-level folder ​

No grain has a folder column, which makes compute derive one from the URL.

json
{"node": "aggregate",
 "from": {"node": "compute", "as": "folder",
          "expr": {"fn": "path_level", "args": [{"field": "url"}, {"lit": 1}]},
          "from": {"node": "filter",
                   "from": {"node": "source", "grain": "events_page"},
                   "where": {"and": [
                     {"field": "has_seo", "op": "eq", "value": 1},
                     {"field": "status_code", "op": "eq", "value": 200}]}}},
 "group_by": ["folder"],
 "metrics": [{"fn": "count"},
             {"fn": "sum", "field": "googlebot_visits"},
             {"fn": "sum", "field": "ai_user_visits"}]}

Googlebot and AI demand by saved segment ​

Named groups from three saved segments, with everything else in one group. Replace the segment IDs with yours from get_schema.

json
{"node": "aggregate",
 "from": {"node": "compute", "as": "section",
          "expr": {"fn": "case",
                   "when": [{"if": {"segment": 203}},
                            {"if": {"segment": 202}},
                            {"if": {"segment": 200}}],
                   "else": "Everything else"},
          "from": {"node": "filter",
                   "from": {"node": "source", "grain": "events_page"},
                   "where": {"and": [
                     {"field": "has_seo", "op": "eq", "value": 1},
                     {"field": "status_code", "op": "eq", "value": 200}]}}},
 "group_by": ["section"],
 "metrics": [{"fn": "count"},
             {"fn": "sum", "field": "googlebot_visits"},
             {"fn": "sum", "field": "ai_bot_visits"},
             {"fn": "sum", "field": "ai_user_visits"}]}

Search engine coverage in a date range ​

reduce rebuilds the per-URL digest from search engine requests between two dates only.

json
{"node": "aggregate",
 "from": {"node": "reduce", "to": "url_hash",
          "from": {"node": "filter",
                   "from": {"node": "source", "grain": "events_event"},
                   "where": {"and": [
                     {"field": "bot_type", "op": "eq", "value": "search_engine"},
                     {"field": "event_date", "op": "between",
                      "value": "2026-09-01", "value2": "2026-09-15"}]}}},
 "group_by": [],
 "metrics": [{"fn": "count_distinct", "field": "url_hash"},
             {"fn": "min", "field": "first_seen"},
             {"fn": "max", "field": "last_seen"}]}

Changed pages by Changes report family ​

Changes the site made itself in the window, counted as pages and as changes per family. Run it with days: 30.

json
{"node": "aggregate",
 "from": {"node": "filter",
          "from": {"node": "source", "grain": "page_change"},
          "where": {"and": [
            {"field": "cross_source", "op": "eq", "value": 0},
            {"field": "edge_seo", "op": "neq", "value": 1}]}},
 "group_by": ["family"],
 "metrics": [{"fn": "count_distinct", "field": "url_hash"},
             {"fn": "count"}]}

To list the pages that lost indexability, filter on {"field": "outcomes", "op": "has_any", "value": ["became_blocked", "became_non_canonical"]} and group by page_type.

Crawled URLs that answer with an error ​

json
{"node": "aggregate",
 "from": {"node": "filter",
          "from": {"node": "source", "grain": "crawl_page"},
          "where": {"field": "status_code", "op": "gte", "value": 400}},
 "group_by": ["status_code"],
 "metrics": [{"fn": "count"}]}

Striking-distance pages with their internal links ​

Crawl data joined with Search Console. Run it with window: "crawl".

json
{"node": "select",
 "fields": ["url", "impressions", "position", "unique_linking_pages", "inlinks_contextual"],
 "from": {"node": "join", "kind": "inner", "bring": ["impressions", "position"],
          "left": {"node": "filter",
                   "from": {"node": "source", "grain": "crawl_page"},
                   "where": {"field": "disposition", "op": "eq", "value": "indexable"}},
          "right": {"node": "filter",
                    "from": {"node": "source", "grain": "gsc_page"},
                    "where": {"and": [
                      {"field": "position", "op": "between", "value": 4, "value2": 20},
                      {"field": "impressions", "op": "gte", "value": 20}]}}}}

Pages that changed their title and lost clicks between crawls ​

Each side of crawl_page_trend carries the clicks from its own crawl window. Run it with vs: "previous".

json
{"node": "select",
 "fields": ["url", "title_prev", "title_curr", "clicks_prev", "clicks_curr"],
 "from": {"node": "filter",
          "from": {"node": "source", "grain": "crawl_page_trend"},
          "where": {"and": [
            {"field": "movement", "op": "eq", "value": "stable"},
            {"field": "title_curr", "op": "neq", "value": {"field": "title_prev"}},
            {"field": "clicks_curr", "op": "lt", "value": {"field": "clicks_prev"}}]}}}

Link pairs that existed in the baseline crawl and are gone now, counted per target. Run it with vs: "previous".

json
{"node": "order", "by": "count", "dir": "desc", "from":
  {"node": "aggregate",
   "from": {"node": "filter",
            "from": {"node": "source", "grain": "crawl_link_trend"},
            "where": {"and": [
              {"field": "movement", "op": "eq", "value": "removed"},
              {"field": "is_internal", "op": "eq", "value": 1},
              {"field": "src_url", "op": "contains", "value": "/blog/"}]}},
   "group_by": ["tgt_url"],
   "metrics": [{"fn": "count"}]}}

Targets ranked by how many indexable pages link to them.

json
{"node": "order", "by": "cd_src_url_hash", "dir": "desc", "from":
  {"node": "aggregate",
   "from": {"node": "filter",
            "from": {"node": "source", "grain": "crawl_link"},
            "where": {"and": [
              {"field": "is_internal", "op": "eq", "value": 1},
              {"field": "tgt_status_code", "op": "gte", "value": 300},
              {"field": "src_index_status", "op": "eq", "value": 1}]}},
   "group_by": ["tgt_url", "tgt_status_code"],
   "metrics": [{"fn": "count_distinct", "field": "src_url_hash"}]}}

Sitemap URLs Googlebot has not requested ​

A negated membership over the bot log. Run it with days: 30.

json
{"node": "select", "fields": ["url", "lastmod"], "from":
  {"node": "filter",
   "from": {"node": "source", "grain": "sitemap_url"},
   "where": {"not": {"field": "url_hash", "op": "in", "rel":
     {"node": "select", "fields": ["url_hash"], "from":
       {"node": "filter",
        "from": {"node": "source", "grain": "events_page"},
        "where": {"field": "googlebot_visits", "op": "gt", "value": 0}}}}}}}

Bots being spoofed ​

The source declares include_fake_bots to see the excluded rows.

json
{"node": "aggregate",
 "from": {"node": "filter",
          "from": {"node": "source", "grain": "events_event", "include_fake_bots": true},
          "where": {"field": "ip_validated", "op": "eq", "value": 2}},
 "group_by": ["bot"],
 "metrics": [{"fn": "count"}]}

When a query is refused ​

The server checks a query before it runs it and says what to change:

  • An unknown field: the error names the grain and lists every field it has, with types. For example, there is no is_noindex: noindex lives in meta_robots.
  • A missing span: a crawl grain joined with bot or Search Console data needs window: "crawl", days or from + to.
  • A fake-bot field without the declaration: naming ip_validated without include_fake_bots on that source is refused, because the rows it asks about were already left out.

Field names are exact per grain and per site. get_schema lists them all up front.

Next ​