Repository navigation
fix: directions_tool geojson always returns coordinates, any trip length - #255
Open
mattpodwysocki wants to merge 3 commits into
Open
mattpodwysocki wants to merge 3 commits into
mattpodwysocki wants to merge 3 commits into
Conversation
An agent asking for raw coordinates (geometries="geojson") got them
directly in the response for a short trip, but for a long one (reported:
London to a point in Scotland) the response exceeded 50KB and the tool
silently swapped to a completely different contract -- geometry and legs
stripped out, replaced by a mapbox://temp/... resource URI that isn't
even a fetchable HTTP URL. There was no way for a caller to know in
advance which contract it would get, since the split was driven by trip
length rather than anything the caller controlled.
Root cause: the tool always requested overview=full (maximum-precision
geometry) regardless of trip length. New optional `overview` input
("full" | "simplified") now defaults to "simplified" whenever
geometries="geojson" (matching the parameter optimization_tool already
exposes, and already defaults to). Confirmed live against the real
Directions API: a real London->Edinburgh route (~420 miles) drops from
10,057 coordinate pairs / ~700KB down to 46 pairs / ~4.7KB under
simplified overview -- comfortably inside the response limit, and still a
fully accurate, drawable line. overview="full" stays available as an
explicit opt-in for callers who need maximum precision, accepting the
same large-response fallback as before.
Tradeoff: the Directions API rejects the congestion annotation unless
overview=full (422, confirmed live) -- distance/speed annotations have no
such restriction. congestion_information is now correctly omitted (not
reported as a misleading all-zero breakdown, which the code did
previously whenever congestion was unavailable for any reason) when it
wasn't requested. render_map_tool's live map preview is unaffected either
way, since it already always fetches its own full-detail geometry
client-side, independent of directions_tool's own response.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mattpodwysocki
force-pushed
the
feat/directions-geometry-design
branch
from
October 1, 2026 14:16
69f6e03 to
5b60e42
Compare
…try-design # Conflicts: # src/tools/directions-tool/DirectionsTool.input.schema.ts # src/tools/directions-tool/DirectionsTool.ts
ctufts
reviewed
Oct 27, 2026
| 'Use geometries="none" (default) for compact text/data responses (distance, duration, ' + | ||
| 'turn-by-turn instructions). Use geometries="geojson" only when you need the raw route ' + | ||
| 'coordinates in the response yourself - render_map_tool works either way.'; | ||
| 'turn-by-turn instructions, congestion). Use geometries="geojson" when you need the raw route ' + |
Contributor
There was a problem hiding this comment.
What happens if I don't want to use the render_map_tool and require the full geometry? Maybe I call this tool and render my own map, would this degrade my mapping experience?
Contributor
Author
There was a problem hiding this comment.
Good question. The default simplified geometry keeps the route's shape when zoomed out but cuts corners up close, so if you render your own map and let people zoom in on the route, pass overview="full" and you get every vertex. Made that explicit in the tool description and the overview parameter (d384970) so the model knows to ask for it.
The simplified default cuts corners up close, so a caller drawing its own zoomable map should pass overview="full". From review on #255. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Someone building an app with the MCP server couldn't get a drawable route for a long trip (London to a point in Scotland).
Cause:
geometries="geojson"always asked the Directions API foroverview=full, every vertex of every road. Fine for a short trip, but a long one is tens of thousands of coordinate pairs, past the tool's 50 KB response limit. Past that limit the tool returns a summary and a ref instead of the geometry, so an agent that asked for coordinates got a different response shape depending on trip length, with no way to know in advance.Fix: a new optional
overviewinput ("full"or"simplified"):"simplified"whengeometries="geojson". Live, London to Edinburgh (about 420 miles) goes from 10,057 coordinate pairs (about 700 KB) to 46 (about 4.7 KB), and the line still draws accurately."full"whengeometries="none", as before, since no geometry comes back either way.overview="full"stays available as an explicit opt-in. On a long trip it still goes past the limit and returns the summary plus amapbox://response/ref (fix: large directions/isochrone responses return a short ref that works on the hosted server #257), now a deliberate choice instead of a surprise.overviewparameteroptimization_toolalready has, also defaulting to"simplified".Tradeoff: the Directions API rejects the
congestionannotation unlessoverview=full(422: Overview option must be full for congestion, checked live). Socongestion_informationonly comes back when the effective overview is"full".distanceandspeedannotations work at any level. Along the way: the tool used to report an all-zero congestion breakdown when congestion wasn't requested, which reads as "no traffic" rather than "not checked". It's now left out instead.Unaffected:
render_map_tool's map fetches its own full-detail route in the browser, whateverdirections_toolreturned.Updated after #257, #276 and #296 merged
overviewdocs now describe themapbox://response/ref from fix: large directions/isochrone responses return a short ref that works on the hosted server #257 instead of the oldmapbox://temp/resource, and keep main'srender_map_toolwording from the tool-selection work (fix: rewrite tool descriptions flagged by Claude connector directory review #273).directionsRequestFromRef(the feat(utils): export directionsRequestFromRef for routes by reference #276 export for apps that draw routes from a ref) now always asks foroverview=full. Without that, a ref from a geojson call would have rebuilt the simplified request and apps drawing from it would get a coarser line. That matches the map's own fetch. There's a test and a docs note.Testing
buildDirectionsRequestUrl.test.ts,cleanResponseData.test.ts,DirectionsTool.test.tsanddirectionsRef.test.ts: short and long route fixtures, theoverviewdefaults, congestion only with full overview, and the ref asking for full geometry.geometries="none"still had congestion; explicitoverview="full"on a long route fell back as documented.🤖 Generated with Claude Code