Skip to main content
Glama

spatial_relations

Measure contact, overlap, gap, and containment between named objects in an image. Get pixel distances, embed depth, and shape profiles to verify physical relationships beyond bounding boxes.

Instructions

Measure how named objects in an image sit relative to one another.

Locates each object, segments it, and reports measurements that are hard to judge by eye: whether two things actually touch, how many pixels apart they are, how much of one lies inside the other and how deeply, plus each object's own elongation, straightness and end-to-end width profile.

This reports geometry, not verdicts — it does not decide what is wrong. Interpret the numbers against what the scene ought to look like: a hand and the grip it holds that come back separate with a large gap are not in contact; a hand overlapping a shield with a_inside_b near 1.0 and a large embed_depth is buried in the shield face rather than gripping its rim; an elongated object whose end_symmetry is near 1.0 is equally wide at both ends, unlike a blade that tapers to a point at one end only.

Useful for checking whether a generated or edited image holds together physically, for verifying that an object is where it should be relative to another, and for any question of contact, containment or clearance that a bounding box cannot answer — boxes overlap whenever one object is simply in front of another.

Takes the single best-scoring match per name, so this assumes one instance of each named object. Asked for 'red circle'/'blue circle'/'green circle' on a scene with one of each, the detector returned the same three boxes for every query — color alone doesn't reliably discriminate same-shaped objects — but the correctly-matching box scored highest every time, which is what this relies on. For several instances of one kind of thing, give them distinguishing names, or use count_objects for a tally instead.

A maximally vague name in objects ("object", "thing", "item", ...) is guarded the same way detect_objects/count_objects are: a near-full-frame box from a name with nothing distinctive to point to is dropped rather than treated as a located match, so it doesn't get reported here as the "best-scoring" box for that name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
srcYesLocal file path or http(s) URL of the image to process. PDFs are also accepted and are rendered one image per page, so tools that return a list return one entry per page.
objectsYesNames of the objects to locate and compare, e.g. ['hand', 'sword', 'shield'].

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.8.2

TDQS

A4.8/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 behavioral burden, and it does so richly: it states the tool locates and segments objects, does not render judgments, assumes one best-scoring match per name, and has a guard for maximally vague names. It even discloses the color-discrimination limitation observed with same-shaped objects, which is precisely the kind of behavioral nuance an agent needs.

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?

The description is long but logically organized: purpose, interpretation guidance, use cases, assumptions, and caveats. It is not wasteful, though the red/blue/green circle example is more detailed than strictly necessary. Still, every section earns its place by preventing misinvocation.

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 two-parameter tool with a full output schema, the description is complete: it covers what the tool measures, what it deliberately does not decide, when to prefer alternatives, the one-instance assumption, and failure modes around vague names. The presence of an output schema means return-value details need not be restated here.

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, but the description adds real value for the objects parameter: it explains the one-instance assumption, gives naming guidance for multiple instances, and warns about vague names being dropped. It does not add anything specific to src, but the schema already fully describes it.

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: 'Measure how named objects in an image sit relative to one another.' It then enumerates concrete measurements (touch, pixel distance, containment, elongation) and explicitly positions this as geometry rather than verdicts. This distinguishes it from siblings like detect_objects and count_objects, which only locate or tally.

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?

The description gives explicit when-to-use contexts: checking physical coherence, verifying placement, and answering contact/containment/clearance questions that bounding boxes cannot resolve. It also gives an explicit alternative for multiple instances ('use count_objects for a tally instead') and warns against vague object names, so an agent can route to the correct tool.

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