|
1 | 1 | # AGENTS.md — Mapbox MCP DevKit Server |
2 | 2 |
|
3 | | -This file provides coding agents with the context, commands, and conventions needed to work effectively with the Mapbox MCP DevKit Server. For human-focused docs, see `README.md`. |
| 3 | +Instructions for AI agents working with the Mapbox MCP DevKit Server. For project overview and user documentation, see `README.md` and `CLAUDE.md`. |
4 | 4 |
|
5 | 5 | --- |
6 | 6 |
|
7 | | -## Project Overview |
| 7 | +## Critical Patterns |
8 | 8 |
|
9 | | -- Model Context Protocol (MCP) server for Mapbox developer APIs |
10 | | -- Exposes tools for style management, token management, GeoJSON processing, and more |
11 | | -- Written in TypeScript, strict mode enabled |
| 9 | +**Tool Architecture:** |
12 | 10 |
|
13 | | -## Setup Commands |
| 11 | +- Tool class names: `PascalCaseTool` (e.g., `ListStylesTool`) |
| 12 | +- Tool names: `snake_case_tool` (e.g., `list_styles_tool`) |
| 13 | +- Schema files: Always separate `*.schema.ts` from `*.tool.ts` |
| 14 | +- Schema validation: Use Zod, export both schema and inferred type |
| 15 | +- Tool location: `src/tools/tool-name-tool/` with all three files (schema, implementation, tests) |
14 | 16 |
|
15 | | -- Install dependencies: `npm install` |
16 | | -- Build the project: `npm run build` |
17 | | -- Run tests: `npm test` |
18 | | -- Lint code: `npm run lint` |
19 | | -- Format code: `npm run format` |
20 | | -- Create a new tool: `npx plop create-tool` |
21 | | -- Create DXT package: `npx @anthropic-ai/dxt pack` |
22 | | -- Build Docker image: `docker build -t mapbox-mcp-devkit .` |
| 17 | +**Testing:** |
23 | 18 |
|
24 | | -## Environment |
| 19 | +- After adding/removing tools: `npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot` |
| 20 | +- Never update snapshots without verifying changes |
| 21 | +- Tool snapshots capture class names, tool names, descriptions |
25 | 22 |
|
26 | | -- Requires Node.js 22+ |
27 | | -- Set `MAPBOX_ACCESS_TOKEN` in your environment (see `manifest.json`) |
28 | | -- For Claude Code integration, see `docs/claude-code-integration.md` |
| 23 | +**Token Management:** |
29 | 24 |
|
30 | | -## Code Style |
| 25 | +- All Mapbox API tools require `MAPBOX_ACCESS_TOKEN` with specific scopes |
| 26 | +- Token scope errors are the #1 issue - check `README.md` for required scopes |
| 27 | +- Use `VERBOSE_ERRORS=true` for debugging authentication failures |
31 | 28 |
|
32 | | -- TypeScript strict mode |
33 | | -- Use ES module syntax (`import`/`export`) |
34 | | -- Destructure imports when possible |
35 | | -- Tool names must be `snake_case_tool` |
36 | | -- Tool schemas live in `*.schema.ts` files |
37 | | -- Use Zod for schema validation |
38 | | -- Run Prettier and ESLint before committing |
| 29 | +## Factual Errors to Watch For |
39 | 30 |
|
40 | | -## Testing Instructions |
| 31 | +**Incorrect Tool Naming:** |
41 | 32 |
|
42 | | -- Run all tests: `npm test` |
43 | | -- Update tool snapshot tests after adding/removing tools: |
44 | | - - `npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot` |
45 | | -- Run a single test file: `npm test -- path/to/testfile.ts` |
46 | | -- Only update snapshots when changes are intentional |
| 33 | +- ❌ `list_styles` → ✅ `list_styles_tool` |
| 34 | +- ❌ `ListStyles` → ✅ `ListStylesTool` |
47 | 35 |
|
48 | | -## Tool Configuration |
| 36 | +**Incorrect File Structure:** |
49 | 37 |
|
50 | | -- Enable/disable tools at startup (see `TOOL_CONFIGURATION.md`) |
51 | | -- Example: `node dist/esm/index.js --enable-tools list_styles_tool,create_style_tool` |
| 38 | +- ❌ Schema defined in `*.tool.ts` → ✅ Schema in separate `*.schema.ts` |
| 39 | +- ❌ Tool in `src/tools/ListStylesTool.ts` → ✅ Tool in `src/tools/list-styles-tool/ListStylesTool.ts` |
52 | 40 |
|
53 | | -## PR Instructions |
| 41 | +**Incorrect Class References:** |
54 | 42 |
|
55 | | -- Branch naming: use `feature/`, `fix/`, or `chore/` prefixes |
56 | | -- PR title format: `[mcp-devkit-server] <Title>` |
57 | | -- Always run `npm run lint` and `npm test` before committing |
58 | | -- Keep PRs focused and well-described |
| 43 | +- ❌ `ToolRegistry.registerTool()` → ✅ Tools auto-registered via `src/tools/index.ts` exports |
| 44 | +- ❌ Manual tool instantiation → ✅ Use plop generator: `npx plop create-tool` |
59 | 45 |
|
60 | | -## Security & Tokens |
| 46 | +**Incorrect Token Scope Usage:** |
61 | 47 |
|
62 | | -- Each tool requires specific Mapbox token scopes (see `README.md`) |
63 | | -- Using insufficient scopes will result in errors |
64 | | -- Use `VERBOSE_ERRORS=true` for detailed error output |
| 48 | +- ❌ Using default token for all operations → ✅ Check required scopes per tool in `README.md` |
| 49 | +- ❌ `styles:read` for creating styles → ✅ `styles:write` required |
65 | 50 |
|
66 | | -## Agent Tips |
| 51 | +## Essential Commands |
67 | 52 |
|
68 | | -- Mention files/folders explicitly for agents to read or edit |
69 | | -- Use `/clear` to reset context between tasks (Claude Code) |
70 | | -- Use checklists in Markdown for large refactors or multi-step tasks |
71 | | -- Prefer running single tests for performance |
| 53 | +```bash |
| 54 | +npm run build # Always build before running |
| 55 | +npm test # Run all tests |
| 56 | +npx plop create-tool # Generate new tool scaffold |
| 57 | +npm run lint:fix && npm run format:fix # Fix code style |
| 58 | +``` |
72 | 59 |
|
73 | | -## Large Monorepo? |
| 60 | +## Development Workflow |
74 | 61 |
|
75 | | -- Place additional AGENTS.md files in subprojects if needed; the closest file to the code being edited takes precedence |
| 62 | +1. **Adding a tool:** `npx plop create-tool` → Implement schema/logic → Update snapshots |
| 63 | +2. **Modifying a tool:** Edit → Build → Test → Update snapshots if metadata changed |
| 64 | +3. **Testing:** Use MCP Inspector: `npx @modelcontextprotocol/inspector node dist/esm/index.js` |
76 | 65 |
|
77 | 66 | --- |
78 | 67 |
|
79 | | -_Edit this file to keep coding agents up to date on project standards, commands, and best practices._ |
| 68 | +**See also:** |
| 69 | + |
| 70 | +- `docs/engineering_standards.md` — Comprehensive contributor guidelines |
| 71 | +- `CLAUDE.md` — Architecture and technical patterns |
| 72 | +- `README.md` — Complete tool reference and token scopes |
| 73 | +- `TOOL_CONFIGURATION.md` — Tool enable/disable configuration |
0 commit comments