Add Accept header for documentation fetching #58
Merged
+7
−1
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
Improves HTTP semantics by explicitly requesting
text/markdownformat when fetching Mapbox documentation fromdocs.mapbox.com/llms.txt.Why This Matters
While the current implementation works (the LLM correctly interprets markdown content served as
text/plain), adding an explicitAcceptheader provides several benefits:Changes
Modified Files:
src/tools/get-mapbox-doc-source-tool/GetMapboxDocSourceTool.ts- Added Accept header with preference orderingtest/tools/get-mapbox-doc-source-tool/GetMapboxDocSourceTool.test.ts- Updated test to verify headerAccept Header Format:
This says:
text/markdown(what we expect)text/plain(current server response, slightly lower priority)Technical Details
Current State:
Content-Type: text/plain#headings,-lists,>blockquotesWhat We Changed:
Acceptheader when fetchingtext/plain)type: 'text'(correct - no native markdown type in MCP)Testing
Manual Verification in MCP Inspector
Tested the implementation in MCP Inspector to confirm the Accept header is working correctly:
Test Steps:
npm run inspect:buildget_latest_mapbox_docs_toolwith empty inputResults:
✅ Tool executes successfully with "Tool Result: Success"
✅ Returns properly formatted markdown content starting with
# Mapbox Documentation✅ Includes all expected sections (Maps client libraries & SDKs, Data loading & access APIs, etc.)
✅ No errors or issues with the Accept header implementation
Screenshots showing the successful execution are available at:
get_reference_toolget_latest_mapbox_docs_toolBenefits
Professional API Citizenship - Shows we follow HTTP best practices
Self-Documenting Code - Accept header explicitly documents our intent
Protects Against Future Changes - If server adds multi-format support, we're ready
No Breaking Changes - Purely additive improvement