Skip to main content
Glama

cluster

Group stops into balanced geographic clusters, so a day too large for one optimisation can be optimised one cluster at a time. This is the front half of the recipe for a thousand-stop day: cluster here, then call optimise_routes per cluster, where the routing engine's own matrix decides the visiting order. IMPORTANT — this is STRAIGHT-LINE clustering. Distances are measured between coordinates, not along the road network: no road, river, motorway junction or one-way system is consulted, and two stops either side of an estuary look adjacent. That makes it the right tool for deciding which stops belong TOGETHER and the wrong one for deciding what ORDER to visit them in. The answer carries a basis sentence saying exactly this; show it, so a centroid is never read as a plan. Provide locations ([{id, lat, lon, load?}], ids unique, at most 5,000) and EXACTLY ONE of clusters (how many groups, balanced by stop count), max_cluster_locations or max_cluster_load (a per-cluster ceiling the count is derived from). Optional territories keep a cluster from straddling a round: each is clustered on its own, and so are the stops inside none of them. Optional seed (default 42) drives the seeding — the same request with the same seed always returns the same clusters, on every deployment, so a re-run is a re-run. Returns each cluster's member ids, count, summed load, centroid and territory, plus a balance block naming the constraint applied and whether it had to be relaxed to place every stop: a load ceiling with lumpy loads is a bin-packing problem and may have no solution at the derived count. Requires the MapMap gateway.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
seedNoSeed for the k-means++ seeding (default 42). The same request with the same seed always returns the same clusters, on every deployment.
clustersNoHow many clusters to produce, balanced by stop count. Give exactly one of `clusters`, `max_cluster_locations` or `max_cluster_load`.
locationsYesThe stops to group. Ids must be unique; at most 5,000.
territoriesNoOptional territories. Given, no cluster straddles one: each territory is clustered on its own, and so are the stops inside none of them.
max_cluster_loadNoAt most this much summed `load` per cluster; the cluster count is derived from it. A load ceiling with lumpy loads is a bin-packing problem and may have no solution at the derived count — the response says so rather than pretending.
max_cluster_locationsNoAt most this many stops per cluster; the cluster count is derived from it.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
basisYesThe method statement: this is STRAIGHT-LINE clustering. Distances are between coordinates, not along roads — two stops either side of an estuary look adjacent. Show it. It is the sentence that stops a centroid being read as a plan.
balanceYesThe constraint applied, the largest cluster produced, and whether the ceiling had to be relaxed to place every stop.
clustersYesThe clusters: each with its `id`, member `locations` (your ids), `count`, summed `load`, `centroid` and the `territory` it belongs to.
parametersYesThe seed, the cluster count, the locations seen, how many territories were used, the iterations run and whether it converged.

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Added

TDQS

A4.7/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 burden, and it delivers richly. It discloses the key behavioral trait: 'STRAIGHT-LINE clustering' with no road, river, or one-way system consulted, including the estuary example. It also discloses determinism across deployments, the bin-packing relaxation behavior, the `basis` output caveat, and the MapMap gateway requirement.

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?

Although the description is long, every sentence earns its place: purpose, recipe, critical caveat, parameter rules, determinism promise, balance-block explanation, and gateway dependency. It is front-loaded with the use case and the key straight-line warning, and uses bold markers to guide attention. There is no filler or redundancy.

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?

The description is complete for a 6-parameter tool with an output schema. It covers the recipe's place in the workflow, the clustering distance model, the exact-one parameter selection, determinism, how territories interact, the bin-packing relaxation possibility, and the required gateway. Since an output schema exists, the description's brief summary of the response shape is adequate.

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 100%, so the baseline is 3 and the schema already documents every parameter thoroughly. The description adds emphasis (e.g., 'EXACTLY ONE of') and restates the derived-count logic, but it does not add materially new meaning beyond the schema's own parameter descriptions. A score of 3 reflects that the schema does the heavy lifting.

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 names a specific verb and resource: 'Group stops into balanced geographic clusters,' and immediately explains the purpose with the one-cluster-at-a-time use case. It distinguishes itself from siblings by explicitly saying it is the 'front half of the recipe' and the 'right tool for deciding which stops belong TOGETHER and the wrong one for deciding what ORDER to visit them in,' contrasting with optimise_routes and order_stops.

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?

Usage is fully explicit: use cluster when a day is 'too large for one optimisation,' then 'call `optimise_routes` per cluster.' It gives an exclusion rule — straight-line clustering makes it wrong for ordering — and names the specific alternative to use for order. It also states the exact-one-of constraint among `clusters`, `max_cluster_locations`, and `max_cluster_load`.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A4/5.0
Disambiguation4/5

Most tools target a distinct action and resource pair, and descriptions are explicit about which tool fits which scenario. The closest overlaps—plan_ev_route vs cheapest_charging_along_route, and route vs plan_day vs order_stops vs optimise_routes—are mitigated by clear guidance, so an agent can usually pick correctly.

Naming Consistency4/5

Tool names overwhelmingly follow a verb_noun snake_case pattern (plan_ev_route, set_palette, list_style_layers) with a consistent geo_ prefix for geometry helpers. Minor deviations like elevation, route, and matrix are short and readable but break the strict verb_noun convention.

Tool Count2/5

At 39 tools, this surface is well past the 25+ threshold and feels heavy even for a broad mapping platform. The set spans routing, geocoding, places, styles, EV/fuel, telematics, usage, and feedback, which would be easier for an agent to navigate if split into smaller domain-focused servers.

Completeness4/5

For the stated breadth, coverage is strong: routing, multi-stop planning, VRP, EV/fuel detours, geocoding, places, geometry, style lifecycle, and telematics all have workable primary paths. Minor gaps like no style deletion, no route alternatives, and no batch geocoding are present but do not create dead ends for core workflows.

Resources