Skip to main content
Glama

within_distance

Finds layer features within a specified metre distance of a coordinate or another layer's features, returning nearest matches first with geodesic distances.

Instructions

Features of layer within distance_m METRES of a reference: a lon/lat point OR feature(s) from another layer. Distances are geodesic/metric regardless of the layer's SRID. Results include distance_m, nearest first. If the user did not say what to measure from, or the reference matches several features, ASK the user.

Input Schema

NameRequiredDescriptionDefault
latNoLatitude (WGS84, north-south, -90..90).
lonNoLongitude (WGS84, east-west, -180..180).
layerYes
limitNoMax rows to return (default 100; server-side cap applies).
columnsNoAttribute columns to return (default: all non-geometry).
filtersNoAttribute filters on the layer, combined with AND.
geometryNo'auto' (default): full geometry if small, else representative points; 'full'; 'centroid'; 'none' (attributes only). The complete geometry is always kept server-side under result_id for render_map.auto
distance_mYesRadius in metres.
reference_layerNoMeasure from the geometry of feature(s) in this layer instead of a lon/lat point.
use_all_matchesNoIf the reference matches several features, use all of them (union) instead of asking.
reference_filtersNoFilters that pick the reference feature(s) in reference_layer (e.g. name = 'X').

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full burden and does a fair job: it states units (metres), that distances are geodesic/metric regardless of layer SRID, that results include distance_m sorted nearest-first, and that ambiguous references should trigger a clarifying question. It omits anything about read-only semantics or result caps, though the limit parameter's schema already covers the cap.

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?

Three sentences, front-loaded with the core operation, then the distance semantics, then the fallback rule for ambiguity. No filler, no restatement of the tool name, and the ambiguity rule is placed last where it is easy to retain.

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

Completeness4/5

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

For an 11-parameter spatial tool with no annotations and no output schema, the description covers the essentials an agent needs: what is measured, in what units, from what, and how results are ordered. The remaining gaps (geometry mode, limits, filters) are handled by well-described schema fields, so the description is close to complete.

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

Parameters3/5

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

Schema description coverage is 91%, so the schema already documents nearly every parameter including reference_layer and use_all_matches. The description's added value is modest but real: it clarifies the dual reference model (point vs. other layer) and SRID-independent metric distance. Baseline 3 is appropriate given how little the description needs to compensate for.

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 description opens with a specific verb+resource+scope: features of `layer` within `distance_m` METRES of a reference, and clarifies the reference can be a lon/lat point or features from another layer. An agent can picture the operation immediately. It never names a sibling (nearest, buffer, spatial_filter) that would let it be distinguished from neighbouring tools, so it falls short of a 5.

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

Usage Guidelines3/5

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

Usage is implied by the radius-search framing, and there is an explicit procedural rule for ambiguity ('If the user did not say what to measure from, or the reference matches several features, ASK the user'). However, there is no guidance on when to prefer this over nearest, buffer, or spatial_filter, which is the real selection problem an agent faces with this sibling set.

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