Skip to content

feat: ground_location_tool MCP sampling + grounding strategy fixes#187

Open
mattpodwysocki wants to merge 10 commits into
mainfrom
feat/ground-location-tool
Open

feat: ground_location_tool MCP sampling + grounding strategy fixes#187
mattpodwysocki wants to merge 10 commits into
mainfrom
feat/ground-location-tool

Conversation

@mattpodwysocki
Copy link
Copy Markdown
Contributor

Summary

Brings the follow-up improvements to ground_location_tool (originally merged in #166) forward to main. The bulk of the work landed as #173, but it was merged into the feature branch — this PR gets it to main along with several smaller fixes that accumulated on the same branch.

What's included

  • MCP sampling–driven grounding strategy (feat: use MCP sampling to classify grounding strategy #173): The tool now uses MCP sampling to classify each query into one of four strategies (routing / neighborhood / poi / region) and shapes the downstream Geocoding, Search, and Isochrone calls accordingly. Falls back to neighborhood when the client doesn't support sampling, so behavior is unchanged for clients without sampling capability.
  • Isochrone profile fix: Use mapbox/ prefix consistently and add driving-traffic support.
  • Reverse geocode types: Default now returns neighborhood/locality/place rather than street address, with strategy-specific overrides (e.g. routing returns address,poi).
  • Tool description: Strengthened to prefer ground_location_tool over reverse_geocode_tool for location-context queries, and to pass the user's query as a parameter rather than calling other tools in parallel.

Test plan

  • All 713 tests pass (npm test)
  • 7 GroundLocationTool tests pass (npx vitest run test/tools/ground-location-tool/)
  • Build succeeds (npm run build)
  • CHANGELOG updated under Unreleased

🤖 Generated with Claude Code

mattpodwysocki and others added 10 commits March 27, 2026 13:01
Composes reverse geocoding, category search, and isochrone into a
single tool that grounds AI responses in live Mapbox data rather
than training data. Returns place name, nearby POIs, and travel-time
reachability with explicit citations.

Closes #165

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ual tools

Use directive language ("Use this as the FIRST tool", "Prefer this over calling
reverse_geocode_tool + category_search_tool + isochrone_tool separately") so the
model selects this composite tool instead of individual tools for location context
questions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add "FIRST and ONLY", explicit "do NOT also call reverse_geocode_tool or search
the web for places", and explain the query parameter usage inline so the model
passes the place category (restaurant, coffee, etc.) through our tool instead
of making a separate web/Google Places search.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…xt queries

When the user needs neighborhood context or nearby places, reverse_geocode_tool
description now explicitly redirects to ground_location_tool, which already
includes reverse geocoding. Prevents redundant tool calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…name

Add types=neighborhood,locality,place to the reverse geocode call so
ground_location_tool returns "The Loop" rather than "2454 Oakton St" for
the place name — matching what the user expects for neighborhood context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Addresses reviewer feedback — profile enum values must match the Mapbox
Isochrone API format (mapbox/walking, mapbox/driving, etc.) and
mapbox/driving-traffic was missing as an option.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ion_tool (#173)

When the client supports sampling, ground_location_tool asks the LLM to
classify the query intent into one of four strategies before making any
Mapbox API calls:

- neighborhood: reverse geocode at neighborhood/locality level + isochrone
- routing: reverse geocode at address/poi level for precise routable coords
- poi: category search with boosted limit (min 15), no isochrone
- region: reverse geocode at region/district level + isochrone

Falls back gracefully to 'neighborhood' if sampling is not supported,
returns an unexpected classification, or throws an error — so existing
clients are unaffected.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…tool

# Conflicts:
#	src/tools/ground-location-tool/GroundLocationTool.ts
#	src/tools/index.ts
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner May 22, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants