Note: If you're using Claude Code specifically, see CLAUDE.md instead. This file is for general AI coding assistants.
This is an MCP (Model Context Protocol) server that provides AI applications with geospatial intelligence capabilities through Mapbox APIs. It enables AI agents to understand locations, navigate the physical world, and access spatial data including geocoding, search, routing, travel time analysis, and map visualization.
- Runtime: Node.js 22+ LTS
- Language: TypeScript (strict mode)
- Testing: Vitest
- Package Manager: npm
src/
├── index.ts # Main MCP server entry point
├── config/toolConfig.ts # Tool configuration parser
├── tools/ # MCP tool implementations
│ ├── MapboxApiBasedTool.ts # Base class for Mapbox API tools
│ ├── toolRegistry.ts # Tool registration system
│ └── */Tool.ts # Individual tool implementations
├── resources/ # MCP resources (static data)
│ └── resourceRegistry.ts
└── utils/
├── httpPipeline.ts # HTTP policy pipeline system
└── tracing.ts # OpenTelemetry instrumentation
test/ # Mirrors src/ structure
- Never patch global.fetch - use
HttpPipelinewith dependency injection - All HTTP requests flow through the pipeline system (src/utils/httpPipeline.ts:21)
- Tools receive
httpRequestvia constructor (src/tools/toolRegistry.ts:22-29)
- Extend
MapboxApiBasedToolbase class (src/tools/MapboxApiBasedTool.ts:16) - Accept
httpRequestparameter in constructor for testability - Register in
ALL_TOOLSarray (src/tools/toolRegistry.ts:18) - Use
npx plop create-toolfor scaffolding new tools
- Use Vitest exclusively
- Mock external APIs - no real network calls in tests
- Use dependency injection to inject mock fetch functions
- Tests mirror
src/directory structure
npm install # Install dependencies
npm test # Run tests
npm run build # Compile TypeScript
npm run lint # Check code quality (auto-fixed by pre-commit hooks)
npm run inspect:build # Test with MCP inspector
npx plop create-tool # Scaffold a new tool- Don't patch globals - especially
global.fetch - Don't make real network calls in tests - use mocks
- Don't commit without tests - new features need test coverage
- Don't hardcode secrets - use environment variables
- Don't ignore type errors - strict TypeScript is enforced
- CLAUDE.md - Detailed standards and patterns for Claude Code users
- docs/engineering_standards.md - Complete engineering guidelines
- docs/tracing.md - OpenTelemetry setup
- README.md - User-facing documentation and integration guides
When analyzing or modifying this codebase:
- The HTTP pipeline class is
HttpPipeline, notPolicyPipeline - The HTTP pipeline file is
src/utils/httpPipeline.ts, notfetchRequest.ts - Base tool class uses
httpRequestparameter, notfetch
For detailed code quality standards, testing requirements, and collaboration guidelines, see docs/engineering_standards.md.