Skip to main content
Glama

sheet_context

Extract a region's classified vector segments, positioned text spans, and hatch-family IDs in one call to reason about drawing structure, classify boundaries, and match fill patterns to legend swatches.

Instructions

The sheet's STRUCTURE in one call and one frame: the classified vector segments, the positioned text spans, and the hatch-family instances of a region — everything the engine itself floods against, exposed as data instead of pixels. Use it when you need to REASON about a region rather than look at it: which lines bound this space and at what pen weight, what the region says, and which periodic fill pattern covers it. The join is the point — all three arrive in image px with no reconciliation left to do, and the reply echoes the post-clamp region so passing that same rect to view_sheet gives you the matching render by construction. Hatch families carry a content-derived id (same pattern spec ⇒ same id, anywhere on the sheet), so matching a plan region to a legend swatch is comparing two ids, not guessing from a render — read the legend region, read the room region, match ids, and cite both bboxes as evidence. Decimation is declared, ordered, and counted on every reply: segments shorter than min_len_px drop first (invisible ink), then a max_segments cap applies LONGEST-FIRST so walls survive and hatch strokes go; kept + dropped always reconciles to total_in_region, and whole segments drop with their meta intact — nothing is ever simplified or merged, because these are classified segments and a merge would rewrite the classification. A scan returns has_vector_linework: false with empty vectors — absence of linework, never a claim the region is blank. Coordinates are image px at render scale 2.0: PDF pt × 2, origin top-left, y down (the browser canvas's native space). Sheet payloads carry dims in both px and pt.

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": {
      "sheet": "<sheet>"
    },
    "name": "sheet_context"
  }
}

Input Schema

NameRequiredDescriptionDefault
sheetYes
regionNoRect in image px (origin top-left, y down); omit for the full sheet
min_len_pxNoDrop segments shorter than this (default 2 — one PDF point at render scale 2.0, below any pen width). 0 keeps everything
max_segmentsNoSegment cap, applied longest-first (default 4000). The reply's dropped.cap says exactly what a smaller region would recover

Output Schema

NameRequiredDescriptionDefault
pageYes
textYes
hatchYes
sheetYes
regionYesThe region actually resolved, post-clamp — pass this same rect to view_sheet and the render is in the same frame by construction
vectorsYes
sheet_pxYes
has_vector_lineworkYesfalse = a scan: vectors and hatch are empty because there are none, not because the region is blank

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed26 schema fields changedv0.1.31
    • removedInput schema / additionalProperties
      Removed value: -false
    • removedInput schema / properties / region / additionalProperties
      Removed value: -false
    • addedOutput schema / properties / hatch / properties / count / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / hatch / properties / count / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / pen_w_px / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / pen_w_px / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / rows / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / rows / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / segments / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / segments / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / segments_in_region / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / hatch / properties / families / items / properties / segments_in_region / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / page / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / page / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / text / properties / count / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / text / properties / count / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / vectors / properties / dropped / properties / cap / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / vectors / properties / dropped / properties / cap / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / vectors / properties / dropped / properties / short / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / vectors / properties / dropped / properties / short / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / vectors / properties / kept / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / vectors / properties / kept / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / vectors / properties / meta / items / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / vectors / properties / meta / items / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / vectors / properties / total_in_region / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / vectors / properties / total_in_region / minimum
      Added value: +-9007199254740991
  2. Changed1 schema field changedv0.1.12
    • addedOutput schema / properties / text / properties / spans / items / properties / rot
      Added value: +{
      +  "description": "Run direction in degrees, clockwise, y down — present only when rotated (90/270 = a quarter-turn, e.g. rotated schedule headers)",
      +  "type": "number"
      +}
  3. Addedv0.1.6

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: decimation order (min_len_px first, then max_segments longest-first), the kept+dropped=total_in_region invariant, whole-segment dropping with meta intact and no merging, and the meaning of has_vector_linework:false as absence-of-linework rather than blankness. It even documents the coordinate system (image px, PDF pt × 2, origin top-left, y down) — substantially beyond structured fields.

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?

Purpose and the three-part payload are front-loaded, and nearly every sentence carries operational detail. It is dense and occasionally rhetorical ('the join is the point', 'not guessing from a render'), costing a point on economy, but no paragraph is filler.

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 complex, multi-part extraction tool with nested region params and an output schema, the description covers decimation behavior, invariants, empty-result semantics, coordinate space, and cross-tool reconciliation. Nothing an agent needs to call it correctly or interpret its reply is missing.

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 75%, and the description still adds real meaning: min_len_px drops 'invisible ink' before the cap applies, max_segments is enforced longest-first so walls survive, and dropped.cap tells you what a smaller region would recover. It also explains that the post-clamp region is echoed so the same rect can be passed to view_sheet, which is a semantic contract the schema never states.

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 names a concrete composite resource — classified vector segments, positioned text spans, and hatch-family instances for a region — and frames it against the sibling it is not ('exposed as data instead of pixels'). An agent can immediately tell this is the reasoning-grade counterpart to view_sheet without opening either schema.

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?

It gives explicit when-to-use guidance ('when you need to REASON about a region rather than look at it') and a concrete workflow for hatch matching (read legend region, read room region, match ids, cite bboxes). It does not explicitly route against get_sheet_vectors or state when-not conditions, so it falls short of a 5.

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