Skip to main content
Glama
books-as-data
by kintopp

sgbr_facet_breakdown

sgbr_facet_breakdown
Read-onlyIdempotent

Cross-tabulate two dimensions into an exact grid of record counts, auto-discovering top values per axis to compare facets such as language by genre without approximate bucket estimates.

Instructions

Cross-tabulate two dimensions into one exact grid of record counts. E.g. language × genre, or library × availability. Auto-discovers the top values of each dimension, then prices every cell exactly with batched stats calls — not a facet-bucket approximation. Each axis is a top-N grid, not a complete enumeration: only the top size/breakdown_size values appear, and row_axis/col_axis report distinct_values/others_count/truncated so an absent value is not read as absent from the corpus (raise the sizes, or use sgbr_facet_values for the full list of one dimension). year and object_type are not supported as axes; use sgbr_facet_values or sgbr_search filters for those.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "facet": "<facet>",
      "breakdown": "<breakdown>"
    },
    "name": "sgbr_facet_breakdown"
  }
}

Input Schema

NameRequiredDescriptionDefault
sizeNoMax number of row values, the most frequent first (max 25).
facetYesRow dimension. One of: library (holding library), language (language), resource_type (type of the original resource), genre (genre), publication_place (place of publication), subject_heading (catalogued subject heading; OR the German and English forms, which barely overlap (only the German carry a GND id)), subject_area (rule-based subject classification derived from the call number (enrichment)), topic (broad subject auto-derived from the call number (enrichment)), availability (type of data available in the portal (full text / metadata-only / external scans / single foldout page)), scan_source (platform or institution providing the scans (a record may list several)), object_type (object type: monograph (work/Werk), multivolume work (multivolume/Mehrbändig), volume (Band), or single foldout page (foldout/Einzelseite)), foldout_type (foldout content category — ~50 German terms (Karten, Tabellen, …) adapted from the Library of Congress Thesaurus for Graphic Materials (AI enrichment)), genre_ai (genre predicted by the ZB-Lab AI model (18 labels, high-confidence predictions only); ~4x the coverage of the catalogued `genre` (enrichment)), content_flags (~15 pipeline flags (IMAGE_ON_PAGE, CHAPTER_START, …) plus thousands of German volume-designation strings — not a controlled vocabulary (enrichment)), volume_info (volume designation within a multivolume work), parent_record (id of the parent record, gathering one work's volumes; filter the facet's BARE digits, never the id991… form), author (author), year (publication year). Must differ from `breakdown`; "year" and "object_type" are not supported as axes (see sgbr_facet_values / sgbr_search instead).
queryNoFree-text query the grid is computed over (same symbolic-Lucene rules as sgbr_search; empty = whole corpus).
scopeNoRestrict the query to one field group (same as sgbr_search).all
excludeNoDrop records carrying ANY of these values, per dimension (same keys and exact values as `filters`). Unlike a filter it keeps records with no value for that dimension, e.g. the untyped records filters.object_type can never reach. A misspelled value silently excludes nothing — take values from sgbr_facet_values.
filtersNoNarrow the population the grid counts over, by dimension (same keys/values as sgbr_search). Values within one dimension are OR-ed; different dimensions AND. Dimension values are exact facet values — discover them with sgbr_facet_values facet=<dim> — except object_type, whose enum lists friendly keys. Note: subject_area, topic, foldout_type, genre_ai, content_flags are machine-derived enrichments, not catalogued data.
year_toNoOnly records published in or before this year (inclusive publication-date range).
breakdownYesColumn dimension. Same set as `facet` (and the same "year"/"object_type" exclusion); must differ from `facet`.
pages_maxNoOnly records with at most this many page images (see pages_min).
pages_minNoOnly records with at least this many page images (a multivolume work counts all its volumes'); records without scans are excluded.
year_fromNoOnly records published in or after this year (inclusive publication-date range).
breakdown_sizeNoMax number of column values, the most frequent first (max 25).
full_text_onlyNoIf true, count only digitised items that have machine-readable full text.
ocr_quality_minNoOnly records whose OCR quality score (0–100, mostly 90–95) is at least this; records without their own scan (multivolume parent works, metadata-only records) are excluded.

Output Schema

NameRequiredDescriptionDefault
rowsYes
facetYes
queryYes
scopeYes
col_axisYes
row_axisYes
warningsNo
breakdownYes
full_text_onlyYes
applied_filtersNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.30.2

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, but the description adds real behavioral context beyond them: counts are priced exactly via batched `stats` calls rather than approximated, each axis is top-N only, and `row_axis`/`col_axis` expose `distinct_values`/`others_count`/`truncated` so an absent value is not mistaken for corpus absence. That is precisely the failure mode an agent would otherwise hit.

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

Conciseness4/5

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

Front-loaded with the core action, then caveats, then exclusions — good ordering. Slight redundancy: the "year/object_type not supported" exclusion appears in both the description and the facet/breakdown schema entries, and the exactness claim is stated twice ("exactly", "not a facet-bucket approximation").

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

Completeness5/5

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

For a 14-parameter nested tool with an output schema, the description covers the interpretive risks that the schema cannot: truncation semantics, unsupported axes, and where to go for full enumerations. Return values need not be explained since an output schema exists.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3; the description earns above that by explaining what `size`/`breakdown_size` truncation actually means for interpretation and by flagging the parent_record bare-digit convention. It still leaves the filters/exclude distinction and the range parameters (year_from, pages_min, ocr_quality_min) to the schema.

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?

States a specific verb and resource: "Cross-tabulate two dimensions into one exact grid of record counts," with concrete examples (language × genre, library × availability). It also distinguishes itself from the sibling by naming the contrast ("not a facet-bucket approximation") and by directing single-dimension enumeration to sgbr_facet_values.

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

Usage Guidelines5/5

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

Explicitly covers when to use and when not to: it names sgbr_facet_values for full enumeration of one dimension, sgbr_search for filtering, and states the hard exclusion that `year` and `object_type` are not supported as axes. The remedy for truncation ("raise the sizes") is also given.

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