Skip to content

feat!: migrate place_details_tool to the Places API - #243

Open
mattpodwysocki wants to merge 1 commit into
mainfrom
feat/places-api-details-migration
Open

feat!: migrate place_details_tool to the Places API#243
mattpodwysocki wants to merge 1 commit into
mainfrom
feat/places-api-details-migration

Conversation

@mattpodwysocki

Copy link
Copy Markdown
Contributor

What changed

Swaps place_details_tool from the older Details API (search/details/v1/retrieve, docs.mapbox.com/api/search/details/) to the Places API's Details endpoint (places/v1/details/retrieve, docs.mapbox.com/api/search/places/). These are two separate, currently-coexisting Mapbox products, not two versions of the same one. We're not supporting both, since the server isn't at 1.0 yet.

This is a breaking change to place_details_tool's input and output:

  • Input: attribute_sets, language, and worldview are gone. The Places API's Details endpoint only takes mapbox_id, no equivalent parameters exist.
  • Output: no longer a GeoJSON Feature. The new response is a flat object (name, full_address, phone, website, categories, opening_hours as a plain OSM-format string instead of the old periods/weekday_text structure, coordinates: { latitude, longitude }, score: { popularity, reality, closed }, address, attributes, photos, building). See PlaceDetailsTool.output.schema.ts.
  • Lost fields: the old API's rating/review_count/price have no equivalent in the new API. score.popularity/score.reality are data-quality confidence signals, not user ratings — preserved in the formatted text as "Popularity: N%", but reviews/price/rating lines are gone since there's no data to show.

Why the output schema is so permissive

The Places API is Public Preview: 1,000 records/month per account, 100/sec rate limit, and the docs explicitly say the response contract may change without notice. Live testing during development showed real variance in which optional fields are present (building and opening_hours only show up on some places; photos/telemetry never appeared in any live response tested despite being documented). The new output schema uses .passthrough() throughout and makes nearly everything but mapbox_id/name optional, specifically to avoid a repeat of the output-validation failure fixed for the old API in 0.14.0 (#240).

Verification

  • Live-tested against the real API multiple times during development: fetched real mapbox_ids via search_and_geocode_tool for several different POIs (Eiffel Tower, Golden Gate Bridge, Empire State Building, Central Park, a hotel, a media company) and called the new endpoint directly via curl and through the built server via a real MCP stdio client, to ground the schema in actual observed responses rather than just the doc summary.
  • npx tsc --noEmit, npx eslint: clean.
  • Full suite passes (910/911 — the one failure is the pre-existing, unrelated urlSafety.test.ts issue already on main).
  • Rewrote PlaceDetailsTool.test.ts fixtures to match the real response shape (verified against live data, not just the docs).

🤖 Generated with Claude Code

Switches from the older Details API (search/details/v1/retrieve) to
the newer Places API's Details endpoint (places/v1/details/retrieve).
Not a compatible swap: the new endpoint takes only mapbox_id (no
attribute_sets/language/worldview), and returns a flat object instead
of a GeoJSON Feature, so both the input and output schemas changed.
Not supporting both APIs since we're not at 1.0 yet.

The Places API is Public Preview (1,000 records/month per account,
100/sec, contract may change without notice), so the output schema
is deliberately permissive rather than risk another output-validation
failure like the one fixed in 0.14.0.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki requested a review from a team as a code owner July 31, 2026 17:27
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.

1 participant