Skip to content

Conversation

@mattpodwysocki
Copy link
Contributor

Summary

Adds resource://mapbox-documentation as a proper MCP resource with text/markdown MIME type, while keeping the existing get_latest_mapbox_docs_tool for broad compatibility.

Why This Matters

Following up on PR #58 which added the Accept header, this PR provides the full solution for clients that properly support MCP resources:

Tool (get_latest_mapbox_docs_tool):

  • Returns type: 'text' (no MIME type)
  • Works everywhere
  • Easy to discover and call

Resource (resource://mapbox-documentation):

  • Returns mimeType: 'text/markdown' (properly typed)
  • For clients that support resources well
  • Follows same pattern as our other reference resources

Changes

New Files:

  • src/resources/mapbox-documentation-resource/MapboxDocumentationResource.ts - Resource implementation
  • test/resources/mapbox-documentation-resource/MapboxDocumentationResource.test.ts - Comprehensive tests

Modified Files:

  • src/resources/resourceRegistry.ts - Register new resource
  • src/tools/get-mapbox-doc-source-tool/GetMapboxDocSourceTool.ts - Updated description to mention resource
  • src/tools/get-reference-tool/GetReferenceTool.ts - Fixed TypeScript type assertion
  • test/tools/__snapshots__/tool-naming-convention.test.ts.snap - Updated snapshot

Implementation Details

The MapboxDocumentationResource:

  • Fetches from https://docs.mapbox.com/llms.txt
  • Uses Accept header from PR Add Accept header for documentation fetching #58 (text/markdown, text/plain;q=0.9, */*;q=0.8)
  • Returns with proper mimeType: 'text/markdown'
  • Handles errors consistently with other resources

Testing

  • ✅ All 520 tests pass (5 new tests added)
  • ✅ Build succeeds with no TypeScript errors
  • ✅ Tool description updated to guide users to resource when appropriate
  • ✅ Follows same pattern as existing resources

User Experience

Users now have two ways to access documentation:

  1. Call the tool (works everywhere):

    get_latest_mapbox_docs_tool({})
  2. Read the resource (better typing):

    // Client reads resource://mapbox-documentation

The tool description mentions the resource for clients that support it:

"For clients that support resources, use resource://mapbox-documentation for proper text/markdown MIME type support."

Consistency

This follows the same pattern we use with:

  • resource://mapbox-style-layers
  • resource://mapbox-streets-v8-fields
  • resource://mapbox-token-scopes
  • resource://mapbox-layer-type-mapping

The key difference is that this resource fetches from an external URL (docs.mapbox.com) rather than returning static content, making it always up-to-date.

- Create MapboxDocumentationResource that fetches docs from docs.mapbox.com/llms.txt
- Returns content with mimeType: text/markdown for proper typing
- Update GetMapboxDocSourceTool description to mention the resource
- Add comprehensive tests for the new resource
- Fix TypeScript error in GetReferenceTool (text type assertion)

Provides proper MIME type support for clients that handle resources well,
while keeping the tool for broad compatibility.
@mattpodwysocki mattpodwysocki requested a review from a team January 15, 2026 18:25
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner January 15, 2026 18:25
@mattpodwysocki
Copy link
Contributor Author

mattpodwysocki commented Jan 15, 2026

Manual Testing in MCP Inspector

Verified the implementation works correctly in MCP Inspector:

✅ Resource appears in Resources list as "Mapbox Documentation"
✅ Returns content with proper mimeType: "text/markdown"
✅ Successfully fetches documentation from docs.mapbox.com/llms.txt
✅ Content displays correctly with full markdown formatting

Screenshot shows the resource returning structured data with:

  • uri: "resource://mapbox-documentation"
  • mimeType: "text/markdown" (properly typed!)
  • text: "# Mapbox Documentation..." (full content)

This confirms that clients supporting resources will get proper MIME type information, while the tool continues to work for all clients.

Screenshot 2026-01-15 at 13 28 13

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