This document establishes comprehensive guidelines for contributors to the Mapbox MCP DevKit server project.
Code Quality Requirements:
All code must be written in TypeScript. No JavaScript files in src/ or test/. Contributors must ensure their work passes both ESLint and Prettier checks before committing:
npm run lint:fix
npm run format:fixKey requirements:
- Maintain strict typing conventions (
strict: truein tsconfig.json) - Avoid
anytypes; add explanatory comments if unavoidable - Never patch global objects (e.g.,
global.fetch) - Follow tool naming conventions: Tool names (MCP identifiers) must be
snake_case_tool(e.g.,list_styles_tool). TypeScript class names followPascalCaseToolconvention (e.g.,ListStylesTool) - Separate schema definitions (
*.schema.ts) from implementation (*.tool.ts)
Testing Expectations:
New features require unit tests with coverage goals targeting critical logic paths. The project uses Vitest as its testing framework, with tests colocated alongside source files in tool directories.
Critical testing rules:
- Mock external services and APIs; do not make real network calls in tests
- After adding/removing tools, update snapshots:
npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot - Never update snapshots without understanding what changed
- Test files follow the pattern:
*.test.tsalongside*.tool.tsand*.schema.ts
Documentation Standards:
All public interfaces require JSDoc comments. User-facing modifications must be documented:
- Update
README.mdfor new tools or setup changes - Update
TOOL_CONFIGURATION.mdfor configuration changes - Reference
CLAUDE.mdfor architectural decisions - Maintain changelog entries for significant changes
Tool Architecture:
All tools must extend BaseTool<InputSchema, OutputSchema> from src/tools/BaseTool.ts. Tools auto-validate inputs using Zod schemas.
Tool creation workflow:
- Run
npx plop create-tool(provide name without "Tool" suffix) - Implement Zod schema in
*.schema.ts - Implement tool logic in
*.tool.ts - Add unit tests in
*.test.ts - Export from
src/tools/index.tsfor auto-registration
HTTP Request Handling:
Use the HttpPipeline abstraction for all HTTP operations. Never patch global.fetch. Apply policies (User-Agent, Retry) through the pipeline:
import { HttpPipeline } from '../utils/httpPipeline.js';
const pipeline = new HttpPipeline();
const response = await pipeline.execute(url, options);This approach supports dependency injection and maintains testability. See src/utils/httpPipeline.ts:20 for implementation details.
Token Management:
All Mapbox API tools require MAPBOX_ACCESS_TOKEN with specific scopes:
- Tools receive tokens via
extra.authInfo.tokenorprocess.env.MAPBOX_ACCESS_TOKEN - Document required scopes in
README.mdfor each tool - Token scope mismatches are the primary failure mode
- Use
VERBOSE_ERRORS=truefor debugging authentication issues
Resource System:
Static reference data should be exposed as MCP resources using URI pattern resource://mapbox-*. Resources provide:
- Style layer specifications
- Streets v8 field definitions
- Token scope documentation
- Layer type mappings
See src/resources/ for examples.
Collaboration Workflow:
Changes flow through pull requests requiring approval from core maintainers:
- Keep PRs focused on a single logical change
- Reference issues in PR descriptions
- Run tests and linting before pushing:
npm test && npm run lint - Build must succeed:
npm run build
Environment Variables:
Keep secrets out of repositories. Use environment variables for sensitive data:
MAPBOX_ACCESS_TOKEN- Required for all Mapbox API operationsVERBOSE_ERRORS- Set totruefor detailed error messagesENABLE_MCP_UI- Controls MCP-UI support (default:true)OTEL_EXPORTER_OTLP_ENDPOINT- OpenTelemetry endpoint (optional)OTEL_SERVICE_NAME- Override service name for tracing (optional)
OpenTelemetry Configuration:
Observability is opt-in via OpenTelemetry. Enable only when debugging:
- Tracing is disabled by default
- Set
OTEL_EXPORTER_OTLP_ENDPOINTto enable - Use Jaeger for local development:
npm run tracing:jaeger:start - See
docs/tracing.mdfor detailed configuration
Docker:
The project includes Docker support for containerized deployment:
docker build -t mapbox-mcp-devkit .
docker run -e MAPBOX_ACCESS_TOKEN="..." mapbox-mcp-devkitSetup and development workflow:
# Install dependencies
npm install
# Run tests
npm test
# Build project
npm run build
# Lint and format
npm run lint:fix
npm run format:fix
# Generate new tool
npx plop create-tool
# Interactive testing
npm run inspect:build
# Create DXT package
npx @anthropic-ai/dxt packAvoid these mistakes:
- ❌ Using
anytype without comments - ❌ Patching
global.fetchinstead of usingHttpPipeline - ❌ Making real network calls in tests
- ❌ Forgetting to update snapshots after tool changes
- ❌ Tool names not following
snake_case_toolconvention (e.g., usinglistStylesinstead oflist_styles_tool) - ❌ Schema and implementation in same file
- ❌ Hardcoding tokens or credentials
- ❌ Missing required token scopes in documentation
- ❌ Committing without running linter and tests
- ❌ Auto-updating snapshots without reviewing changes
CLAUDE.md- Architecture and technical patternsAGENTS.md- AI agent development guideREADME.md- Complete tool reference and token scopesTOOL_CONFIGURATION.md- Tool enable/disable configurationdocs/tracing.md- OpenTelemetry setup and configuration