Skip to main content
Glama

detect_document

Read-onlyIdempotent

Detect the dominant document, screen, or whiteboard in an image and output the perspective transform for straightening. Read-only, returns a ready-to-paste quad when correction is needed.

Instructions

Detect the dominant quadrilateral (a sheet of paper, a screen, a whiteboard, a sign) in a revision with a contour-based search, and return it as a ready-to-paste perspective operation. This is to perspective what detect_tilt is to rotate: read-only, it never modifies the image, and a null quad means "do not correct". The quad is in post-EXIF-orientation pixel coordinates, ordered tl, tr, br, bl, and output_size_hint is exactly the size perspective will produce from it. Optional min_area_ratio (0.05..=1.0, default 0.2) is the smallest fraction of the frame a candidate may cover. When quad is null the reason is the first warning: no_quad_found, already_rectified (the page already fills the frame) or low_confidence.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
revision_idYes対象 revision ID("rev_...")。
min_area_ratioNo画像面積に対する候補四角形の最小面積比(0.05..=1.0)。省略時は 0.2。

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
detectionYes検出結果。`quad` が null なら「補正しない」で、理由は `warnings` の先頭に入る。
revision_idYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.2

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, so the safety profile is covered. The description adds valuable behavior beyond that: coordinate ordering (tl, tr, br, bl), post-EXIF-orientation coordinates, output_size_hint semantics, min_area_ratio constraints, and the exact warning reasons when quad is null. This is rich, non-redundant behavioral detail.

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 three sentences, each earning its place: purpose and analogy, coordinate/output semantics, and parameter/warning behavior. It front-loads the core action and keeps supporting details compact, with no filler or repetition.

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?

Given the annotations, full schema coverage, and presence of an output schema, the description covers everything an agent needs: operation type, coordinate system, ordering, output sizing, parameter defaults, and failure/warning semantics. No important calling decision is left unexplained.

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?

Input schema coverage is 100%, so the baseline is 3. The description still adds meaning to min_area_ratio as 'the smallest fraction of the frame a candidate may cover', and clarifies that output_size_hint matches what perspective will produce. It does not add much to revision_id, but that is already well covered by 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?

The description opens with a specific verb and resource: 'Detect the dominant quadrilateral ... in a revision with a contour-based search', and clarifies the return as a 'ready-to-paste perspective operation'. It also distinguishes itself from sibling detect_tilt by drawing the perspective/rotate analogy, so an agent can tell what this tool uniquely does.

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?

The description gives strong context: it is read-only, never modifies the image, and a null quad means 'do not correct'. It also relates the tool to perspective via detect_tilt, which implies when to use it. It does not spell out explicit exclusion cases or name more alternatives, so it stops short of the strongest possible guidance.

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