Instructions for AI agents working with the Mapbox MCP DevKit Server. For project overview and user documentation, see README.md and CLAUDE.md.
Tool Architecture:
- Tool naming: Tool names (MCP identifiers) must be
snake_case_tool(e.g.,list_styles_tool). TypeScript class names followPascalCaseToolconvention (e.g.,ListStylesTool) - Schema files: Always separate
*.schema.tsfrom*.tool.ts - Schema validation: Use Zod, export both schema and inferred type
- Tool location:
src/tools/tool-name-tool/with all three files (schema, implementation, tests)
Testing:
- After adding/removing tools:
npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot - Never update snapshots without verifying changes
- Tool snapshots capture class names (TypeScript
PascalCaseTool), tool names (MCPsnake_case_tool), and descriptions
Token Management:
- All Mapbox API tools require
MAPBOX_ACCESS_TOKENwith specific scopes - Token scope errors are the #1 issue - check
README.mdfor required scopes - Use
VERBOSE_ERRORS=truefor debugging authentication failures
Incorrect Tool Naming:
- ❌
list_styles→ ✅list_styles_tool - ❌
ListStyles→ ✅ListStylesTool
Incorrect File Structure:
- ❌ Schema defined in
*.tool.ts→ ✅ Schema in separate*.schema.ts - ❌ Tool in
src/tools/ListStylesTool.ts→ ✅ Tool insrc/tools/list-styles-tool/ListStylesTool.ts
Incorrect Class References:
- ❌
ToolRegistry.registerTool()→ ✅ Tools auto-registered viasrc/tools/index.tsexports - ❌ Manual tool instantiation → ✅ Use plop generator:
npx plop create-tool
Incorrect Token Scope Usage:
- ❌ Using default token for all operations → ✅ Check required scopes per tool in
README.md - ❌
styles:readfor creating styles → ✅styles:writerequired
npm run build # Always build before running
npm test # Run all tests
npx plop create-tool # Generate new tool scaffold
npm run lint:fix && npm run format:fix # Fix code style- Adding a tool:
npx plop create-tool→ Implement schema/logic → Update snapshots - Modifying a tool: Edit → Build → Test → Update snapshots if metadata changed
- Testing: Use MCP Inspector:
npx @modelcontextprotocol/inspector node dist/esm/index.js
See also:
docs/engineering_standards.md— Comprehensive contributor guidelinesCLAUDE.md— Architecture and technical patternsREADME.md— Complete tool reference and token scopesTOOL_CONFIGURATION.md— Tool enable/disable configuration