Skip to content

feat: prefer .md variant when fetching docs.mapbox.com pages#17

Merged
2 commits merged intomainfrom
feat-markdown-url
Mar 31, 2026
Merged

feat: prefer .md variant when fetching docs.mapbox.com pages#17
2 commits merged intomainfrom
feat-markdown-url

Conversation

@mattpodwysocki
Copy link
Copy Markdown
Contributor

@mattpodwysocki mattpodwysocki commented Mar 23, 2026

Summary

  • Adds src/utils/docFetcher.ts with toMarkdownUrl() and fetchDocContent() helpers
  • get_document_tool and batch_get_documents_tool now request the .md variant of docs.mapbox.com pages first, falling back to the original URL if the .md endpoint returns non-2xx
  • Adds MAPBOX_DOCS_HOST_OVERRIDE env var to redirect all docs.mapbox.com fetches to a staging host (e.g. docs.tilestream.net) for testing before production rollout
  • 10 new unit tests covering toMarkdownUrl, fetchDocContent, fallback behavior, and host override

Why

docs.mapbox.com is adding .md suffix support on all pages (already live on staging at docs.tilestream.net). By requesting the markdown variant, LLMs get clean, structured content instead of HTML, improving the quality of responses grounded in Mapbox documentation.

Test plan

  • All 50 tests pass (npm test)
  • Lint and format pass (npm run lint && npm run format)
  • Manual smoke test: set MAPBOX_DOCS_HOST_OVERRIDE=docs.tilestream.net and call get_document_tool with a docs.mapbox.com URL — verify .md content is returned

Get URL

Screenshot 2026-03-26 at 12 02 08

Get URL contents in Markdown

Screenshot 2026-03-26 at 12 02 16

docs.mapbox.com will support a .md suffix on all pages, returning clean
markdown instead of HTML. This makes fetched content significantly easier
for LLMs to parse.

- Add docFetcher.ts with toMarkdownUrl() and fetchDocContent()
- Both get_document_tool and batch_get_documents_tool now try the .md URL
  first and fall back to the original URL if unavailable
- Set MAPBOX_DOCS_HOST_OVERRIDE=docs.tilestream.net to test against
  the staging environment where .md is already live

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner March 23, 2026 14:46
Comment thread src/utils/docFetcher.ts
* https://docs.mapbox.com/accounts/guides → https://docs.mapbox.com/accounts/guides.md
* https://docs.mapbox.com/accounts/guides/ → https://docs.mapbox.com/accounts/guides.md
*
* Example (MAPBOX_DOCS_HOST_OVERRIDE=docs.tilestream.net):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any issue with leaving info about our staging url in a public repo? I assume not, but just calling it out.

Copy link
Copy Markdown

@ctufts ctufts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment on the inclusion of the staging url, if its not a concern it lgtm

@mattpodwysocki mattpodwysocki closed this pull request by merging all changes into main in d69bdce Mar 31, 2026
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