Skip to content

feat: Add API endpoint explorer tool#75

Open
mattpodwysocki wants to merge 1 commit intomainfrom
feature/api-endpoint-explorer
Open

feat: Add API endpoint explorer tool#75
mattpodwysocki wants to merge 1 commit intomainfrom
feature/api-endpoint-explorer

Conversation

@mattpodwysocki
Copy link
Contributor

Summary

Implements explore_mapbox_api_tool to provide structured, queryable information about Mapbox API endpoints, operations, parameters, and authentication requirements. Resolves #71.

Features

  • List all APIs: Shows 7 Mapbox APIs with descriptions and operation counts
  • View operations: Lists all operations for a specific API with HTTP methods and endpoints
  • Get endpoint details: Complete information including:
    • HTTP method and endpoint URL
    • Path, query, and body parameters with types and descriptions
    • Required token scopes
    • Rate limits
    • Example requests/responses (with details: true)

API Coverage

Documented 7 APIs with 24 total operations:

  • Geocoding (2 ops) - Forward/reverse geocoding
  • Styles (5 ops) - CRUD operations for map styles
  • Tokens (5 ops) - Token management
  • Static Images (2 ops) - Static map generation
  • Directions (1 op) - Route calculation
  • Tilequery (1 op) - Vector tile queries
  • Feedback (2 ops) - User feedback events

Implementation Details

  • Created /src/constants/mapboxApiEndpoints.ts with curated API definitions
  • Implemented tool extending BaseTool with proper input/output schemas
  • Returns both markdown content (human-readable) and structured content (machine-readable)
  • Proper MCP structured content support with separated text and data
  • No API access required - works with static curated data

Testing

  • ✅ 21 comprehensive test cases covering all functionality
  • ✅ All 574 project tests pass
  • ✅ Tool snapshot updated
  • ✅ Build successful
  • ✅ Tested in MCP Inspector - structured content validates correctly
  • ✅ Tested in Claude Desktop - natural language queries work perfectly

Documentation

  • Updated README.md with tool description and usage examples
  • Updated CHANGELOG.md with feature entry
  • Complements existing get_latest_mapbox_docs_tool by providing structured API reference data

Screenshots

Successfully tested in both MCP Inspector (structured content validation) and Claude Desktop (natural language queries).

🤖 Generated with Claude Code

Add explore_mapbox_api_tool to provide structured, queryable information
about Mapbox API endpoints, operations, parameters, and authentication.

Features:
- List all available Mapbox APIs (7 APIs with 24 operations total)
- View operations for specific APIs
- Get detailed endpoint information with parameters, scopes, rate limits
- Optional detailed mode includes example requests/responses
- Proper MCP structured content support with separate text and data

Coverage:
- Geocoding API (forward/reverse geocoding)
- Styles API (CRUD operations)
- Tokens API (token management)
- Static Images API (map image generation)
- Directions API (route calculation)
- Tilequery API (vector tile queries)
- Feedback API (user feedback events)

Implementation:
- Created mapboxApiEndpoints.ts with curated API definitions
- Implemented BaseTool with input/output schemas
- Returns both markdown content and structured data
- 21 comprehensive test cases, all passing
- Updated tool registry and documentation

Complements get_latest_mapbox_docs_tool by providing structured API
reference data instead of prose documentation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner February 12, 2026 06:25
mattpodwysocki added a commit that referenced this pull request Feb 12, 2026
Add validate_api_request_tool to validate Mapbox API requests against
endpoint definitions before sending them to the API.

Features:
- Validates required parameters are present
- Checks parameter types (string, number, boolean, array, object)
- Validates enum constraints for parameters with allowed values
- Verifies token has required scopes for operations
- Detects extra/unknown parameters with warnings
- Returns detailed validation results with specific error messages
- Helps prevent failed API calls by catching issues early

Validation coverage:
- Path, query, and body parameters
- Type checking with clear error messages
- Enum validation (e.g., routing profiles, geocoding modes)
- Token scope verification
- Case-insensitive API and operation names

Implementation:
- Uses endpoint definitions from mapboxApiEndpoints.ts (from PR #75)
- Implements comprehensive validation logic
- 19 test cases covering all validation scenarios
- Proper MCP structured content with separated text and data
- Updated tool registry and documentation

This tool builds on top of explore_mapbox_api_tool by using the same
endpoint definitions to provide validation capabilities.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@@ -0,0 +1,1278 @@
/**
* Mapbox API endpoint definitions for the explore_mapbox_api_tool.
Copy link

Choose a reason for hiding this comment

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

What is the plan to scale this and/or keep it up to date? Might it be worth talking to the docs team about keeping generated Open API specs( or an equivalent) in https://github.com/mapbox/help as the source of truth, then consume them downstream here to prevent manual updates from being necessary?

@mattpodwysocki
Copy link
Contributor Author

Great question about scalability! This is definitely something we should address.

Current Approach (MVP)

This PR uses a manually curated list as an MVP to:

  • ✅ Prove the concept and gather feedback
  • ✅ Cover the most commonly used APIs (Geocoding, Styles, Directions, etc.)
  • ✅ Provide immediate value without infrastructure dependencies

Scaling Strategy

You're absolutely right that manual maintenance doesn't scale. Here's the path forward:

Short-term (This PR)

  • Ship the MVP with core APIs covered
  • Gather feedback on the structure and usefulness
  • Document which APIs are included

Medium-term (Follow-up)

Option 1: OpenAPI Spec Generation

  • Collaborate with docs team to maintain OpenAPI specs in mapbox/help
  • Build a generator script that converts OpenAPI → TypeScript definitions
  • Automate updates via CI/CD when specs change

Option 2: Fetch from Documentation

  • Parse structured data from docs.mapbox.com programmatically
  • Cache locally, update periodically
  • Requires stable documentation structure

Long-term

  • Ideally, OpenAPI specs become the single source of truth
  • This tool (and others) consume from that canonical source
  • Updates happen automatically as APIs evolve

Action Items

  1. Merge this PR as the foundational structure
  2. Create follow-up issue to discuss OpenAPI spec generation with docs team
  3. Design generator script that transforms OpenAPI → our TypeScript interface
  4. Automate updates once we have a stable spec source

Questions for Discussion

  • Does the docs team already maintain OpenAPI specs we could consume?
  • If not, what's the effort to create and maintain them?
  • Could we pilot this with 1-2 APIs first to validate the approach?

Would love to sync with the docs team on this! The manual approach gets us started, but automated spec generation is definitely the right long-term solution.

What do you think about this phased approach?

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.

Add API Endpoint Explorer tool for structured API information

2 participants