Skip to main content
Glama

nearest

Finds the k closest features in a layer to a coordinate point or another layer's features, returning distances in metres and supporting an optional maximum distance.

Instructions

The k nearest features of layer to a reference (lon/lat point or feature(s) of another layer), with distance_m in metres. Optional max_distance_m. If the user did not say what 'nearest' is relative to, ASK.

Input Schema

NameRequiredDescriptionDefault
kNoNumber of neighbours (1-100).
latNoLatitude (WGS84, north-south, -90..90).
lonNoLongitude (WGS84, east-west, -180..180).
layerYes
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
max_distance_mNoIgnore features farther than this (metres).
reference_layerNoMeasure from the geometry of feature(s) in this layer instead of a lon/lat point.
use_all_matchesNo
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
Behavior3/5

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

With no annotations, the description carries the full behavioral burden. It discloses the distance unit (metres) and that max_distance_m prunes results, but says nothing about result ordering, permissions, or what a call returns beyond distance. The geometry parameter's server-side result_id note lives in the schema, not the description.

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 short sentences, front-loaded with the core behavior, then the optional bound, then the clarification rule. No filler and nothing repeated from structured fields.

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 tool with no annotations and no output schema, the description covers the essential decision (what the reference is) and the distance semantics. Gaps remain around filters/columns/geometry handling and the undocumented use_all_matches flag, so it is not fully self-sufficient.

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 coverage is 82%, so the schema already documents most parameters well. The description adds unit and semantics for the reference (lon/lat point vs another layer) and max_distance_m, but leaves several parameters entirely unaddressed, notably use_all_matches which has no description in either place.

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?

States a specific verb and resource: the k nearest features of `layer` relative to a reference, with distances in metres. It distinguishes the point-reference and layer-reference modes, though it does not name the closest sibling (within_distance), which is the main thing left to inference.

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?

Gives an actionable usage rule: if the reference for 'nearest' is unspecified, ask the user rather than guessing. It also implicitly frames the two reference modes. It does not explain when to prefer this over within_distance or find_features, so alternatives remain unaddressed.

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