Skip to main content
Glama

sheet_context

Retrieve a region's classified vector segments, positioned text spans, and hatch patterns in one coordinate frame to reason about drawing structure and match plan fills 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
project_idNoThe project to work on (list_projects names them). Optional for the open-source arguments: the project the last call named (load_plan makes one) is used.
max_segmentsNoSegment cap, applied longest-first (default 4000). The reply's dropped.cap says exactly what a smaller region would recover

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.0.23
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • addedInput schema / properties / project_id
      Added value: +{
      +  "description": "The project to work on (list_projects names them). Optional for the open-source arguments: the project the last call named (load_plan makes one) is used.",
      +  "minLength": 1,
      +  "type": "string"
      +}
    • changedOutput schema / (root)
      Previous value: -{
      -  "$schema": "http://json-schema.org/draft-07/schema#",
      -  "additionalProperties": false,
      -  "properties": {
      -    "has_vector_linework": {
      -      "description": "false = a scan: vectors and hatch are empty because there are none, not because the region is blank",
      -      "type": "boolean"
      -    },
      -    "hatch": {
      -      "additionalProperties": false,
      -      "properties": {
      -        "count": {
      -          "maximum": 9007199254740991,
      -          "minimum": -9007199254740991,
      -          "type": "integer"
      -        },
      -        "families": {
      -          "items": {
      -            "additionalProperties": false,
      -            "properties": {
      -              "angle_deg": {
      -                "description": "Raw mean angle [0, 180) — rides beside the id for tolerance matching at bucket boundaries",
      -                "type": "number"
      -              },
      -              "bbox": {
      -                "description": "The instance's tight bbox [x0, y0, x1, y1], image px",
      -                "items": {
      -                  "type": "number"
      -                },
      -                "maxItems": 4,
      -                "minItems": 4,
      -                "type": "array"
      -              },
      -              "id": {
      -                "description": "Content hash of the quantized (angle, pitch, pen-width) signature — the SAME id for the same pattern spec anywhere on the sheet, so legend↔plan matching is id === id. Identifies a pattern, not a material; the legend maps pattern → material.",
      -                "type": "string"
      -              },
      -              "pen_w_px": {
      -                "description": "Modal device pen width of the members",
      -                "maximum": 9007199254740991,
      -                "minimum": -9007199254740991,
      -                "type": "integer"
      -              },
      -              "pitch_px": {
      -                "description": "Raw median row pitch, image px",
      -                "type": "number"
      -              },
      -              "rows": {
      -                "maximum": 9007199254740991,
      -                "minimum": -9007199254740991,
      -                "type": "integer"
      -              },
      -              "segments": {
      -                "description": "Member segments in the whole instance",
      -                "maximum": 9007199254740991,
      -                "minimum": -9007199254740991,
      -                "type": "integer"
      -              },
      -              "segments_in_region": {
      -                "description": "…of which this many were returned in vectors (post-decimation)",
      -                "maximum": 9007199254740991,
      -                "minimum": -9007199254740991,
      -                "type": "integer"
      -              }
      -            },
      -            "required": [
      -              "id",
      -              "angle_deg",
      -              "pitch_px",
      -              "pen_w_px",
      -              "rows",
      -              "segments",
      -              "segments_in_region",
      -              "bbox"
      -            ],
      -            "type": "object"
      -          },
      -          "type": "array"
      -        }
      -      },
      -      "required": [
      -        "families",
      -        "count"
      -      ],
      -      "type": "object"
      -    },
      -    "page": {
      -      "maximum": 9007199254740991,
      -      "minimum": -9007199254740991,
      -      "type": "integer"
      -    },
      -    "region": {
      -      "description": "The region actually resolved, post-clamp — pass this same rect to view_sheet and the render is in the same frame by construction",
      -      "items": {
      -        "type": "number"
      -      },
      -      "maxItems": 4,
      -      "minItems": 4,
      -      "type": "array"
      -    },
      -    "sheet": {
      -      "type": "string"
      -    },
      -    "sheet_px": {
      -      "items": {
      -        "type": "number"
      -      },
      -      "maxItems": 2,
      -      "minItems": 2,
      -      "type": "array"
      -    },
      -    "text": {
      -      "additionalProperties": false,
      -      "properties": {
      -        "count": {
      -          "maximum": 9007199254740991,
      -          "minimum": -9007199254740991,
      -          "type": "integer"
      -        },
      -        "spans": {
      -          "description": "Text with bboxes, image px, same frame as the vectors",
      -          "items": {
      -            "additionalProperties": false,
      -            "properties": {
      -              "rot": {
      -                "description": "Run direction in degrees, clockwise, y down — present only when rotated (90/270 = a quarter-turn, e.g. rotated schedule headers)",
      -                "type": "number"
      -              },
      -              "str": {
      -                "type": "string"
      -              },
      -              "x0": {
      -                "type": "number"
      -              },
      -              "x1": {
      -                "type": "number"
      -              },
      -              "y0": {
      -                "type": "number"
      -              },
      -              "y1": {
      -                "type": "number"
      -              }
      -            },
      -            "required": [
      -              "str",
      -              "x0",
      -              "y0",
      -              "x1",
      -              "y1"
      -            ],
      -            "type": "object"
      -          },
      -          "type": "array"
      -        }
      -      },
      -      "required": [
      -        "spans",
      -        "count"
      -      ],
      -      "type": "object"
      -    },
      -    "vectors": {
      -      "additionalProperties": false,
      -      "properties": {
      -        "dropped": {
      -          "additionalProperties": false,
      -          "properties": {
      -            "cap": {
      -              "description": "Over max_segments — the SHORTEST went first, so walls survive",
      -              "maximum": 9007199254740991,
      -              "minimum": -9007199254740991,
      -              "type": "integer"
      -            },
      -            "short": {
      -              "description": "Below min_len_px (invisible ink)",
      -              "maximum": 9007199254740991,
      -              "minimum": -9007199254740991,
      -              "type": "integer"
      -            }
      -          },
      -          "required": [
      -            "short",
      -            "cap"
      -          ],
      -          "type": "object"
      -        },
      -        "family": {
      -          "description": "Aligned with segments: the hatch-family id this segment belongs to, or null for structural linework",
      -          "items": {
      -            "type": [
      -              "string",
      -              "null"
      -            ]
      -          },
      -          "type": "array"
      -        },
      -        "kept": {
      -          "maximum": 9007199254740991,
      -          "minimum": -9007199254740991,
      -          "type": "integer"
      -        },
      -        "meta": {
      -          "description": "One byte per segment, aligned with segments: bit 1 = curve chord, bit 2 = clip-only, bit 4 = filled-not-stroked; high nibble = device pen width",
      -          "items": {
      -            "maximum": 9007199254740991,
      -            "minimum": -9007199254740991,
      -            "type": "integer"
      -          },
      -          "type": "array"
      -        },
      -        "note": {
      -          "type": "string"
      -        },
      -        "segments": {
      -          "description": "[x0, y0, x1, y1] per segment, image px, endpoints exactly as drawn — clipped by KEEPING whole intersecting segments, never by rewriting them",
      -          "items": {
      -            "items": {
      -              "type": "number"
      -            },
      -            "maxItems": 4,
      -            "minItems": 4,
      -            "type": "array"
      -          },
      -          "type": "array"
      -        },
      -        "total_in_region": {
      -          "description": "Segments intersecting the region before any decimation — kept + dropped always reconciles to this",
      -          "maximum": 9007199254740991,
      -          "minimum": -9007199254740991,
      -          "type": "integer"
      -        },
      -        "truncated": {
      -          "type": "boolean"
      -        }
      -      },
      -      "required": [
      -        "segments",
      -        "meta",
      -        "family",
      -        "kept",
      -        "total_in_region",
      -        "truncated",
      -        "dropped"
      -      ],
      -      "type": "object"
      -    }
      -  },
      -  "required": [
      -    "sheet",
      -    "page",
      -    "sheet_px",
      -    "region",
      -    "has_vector_linework",
      -    "vectors",
      -    "text",
      -    "hatch"
      -  ],
      -  "type": "object"
      -}New value: +null
  2. 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
  3. 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"
      +}
  4. Addedv0.1.6

TDQS

A4.1/5.0
Behavior3/5

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

Annotations carry only a title, so the description bears the full disclosure burden and it does unusually well: the decimation order (min_len_px first, then a longest-first cap), the invariant that kept + dropped reconciles to total_in_region, the promise that segments are never simplified or merged, the has_vector_linework:false semantics for scans, and the render-scale coordinate convention. These are real behavioral traits an agent could not derive from the schema.

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 is front-loaded in the first clause, and most sentences earn their place (decimation rules, hatch-id matching, coordinate space). Diction leans rhetorical — 'the join is the point', 'exposed as data instead of pixels' — and the density borders on over-stuffed for a five-parameter read tool, but nothing is redundant enough to penalize heavily.

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?

With no output schema, the description steps in and names the reply's key fields and invariants: has_vector_linework, kept/dropped/total_in_region reconciliation, dropped.cap, the echoed region, and px/pt dimensions. For a nested-object read tool with a data-joining behavior, an agent has enough to call it and interpret the result correctly.

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 80%, yet the description still adds meaning: the region rect is echoed post-clamp so the same rect reproduces a view_sheet render by construction, dropped.cap is explained as 'what a smaller region would recover', and the longest-first cap rationale (walls survive, hatch strokes go) is restated in context. The coordinate-space note (image px at render scale 2.0, PDF pt × 2, origin top-left, y down) plus the payload carrying both px and pt dimensions goes beyond the schema wording.

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

Purpose4/5

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

The opening sentence names a concrete resource bundle — classified vector segments, positioned text spans, and hatch-family instances for a region — plus a specific framing ('structure ... as data instead of pixels'). It also draws a bright line against view_sheet ('passing that same rect to view_sheet gives you the matching render'), so an agent can separate 'reason about' from 'look at'. It does not explicitly distinguish itself from the per-modality siblings (e.g. get_sheet_vectors, read_sheet_text), leaving 'in one call' as the only implied differentiator.

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?

States the selection rule outright — 'Use it when you need to REASON about a region rather than look at it' — and supplies a concrete workflow: read the legend region, read the room region, match content-derived hatch ids, cite both bboxes as evidence. The 'rather than look at it' clause functions as an explicit when-not, routing visual inspection to view_sheet.

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

Deploy Server

Other Tools