Skip to content

Commit 4e5f85b

Browse files
[docs] Update CLAUDE and other agent docs
1 parent 67099df commit 4e5f85b

File tree

5 files changed

+315
-265
lines changed

5 files changed

+315
-265
lines changed

.github/copilot-instructions.md

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,61 @@
11
# GitHub Copilot Repository Instructions
22

3-
These instructions help GitHub Copilot and Copilot Chat provide better code suggestions and answers for the Mapbox MCP DevKit Server. For more details, see the [Copilot repository instructions guide](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions).
3+
Instructions for GitHub Copilot working on the Mapbox MCP DevKit Server. See [Copilot repository instructions guide](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions).
44

55
---
66

7-
## Project Overview
7+
## 1. Review Code Before Suggesting Changes
88

9-
- Model Context Protocol (MCP) server for Mapbox developer APIs
10-
- Written in TypeScript (strict mode)
11-
- Provides tools for Mapbox style management, token management, GeoJSON processing, and more
9+
- **Read existing patterns** before proposing solutions
10+
- Check `src/tools/` for tool implementation patterns
11+
- Reference `CLAUDE.md` for architecture decisions
12+
- Verify token scope requirements in `README.md`
1213

13-
## Code Style
14+
## 2. Security & Token Management
1415

15-
- Use TypeScript strict mode
16-
- Prefer ES module syntax (`import`/`export`)
17-
- Destructure imports when possible
18-
- Tool names must be `snake_case_tool`
19-
- Tool schemas live in `*.schema.ts` files
20-
- Use Zod for schema validation
21-
- Run Prettier and ESLint before committing
16+
- **Never hardcode tokens or credentials**
17+
- All Mapbox API calls require `MAPBOX_ACCESS_TOKEN` with specific scopes
18+
- Token scope mismatches are the primary failure mode
19+
- Use `VERBOSE_ERRORS=true` for debugging auth issues
20+
- Reference token scope requirements in `README.md` before implementing
2221

23-
## Development & Build
22+
## 3. Code Quality & Style
2423

25-
- Requires Node.js 22+
26-
- Install dependencies: `npm install`
27-
- Build: `npm run build`
28-
- Run tests: `npm test`
29-
- Lint: `npm run lint`
30-
- Format: `npm run format`
31-
- Create new tool: `npx plop create-tool`
32-
- Create DXT package: `npx @anthropic-ai/dxt pack`
33-
- Build Docker image: `docker build -t mapbox-mcp-devkit .`
24+
- **TypeScript strict mode** - No implicit any, proper typing required
25+
- **Tool naming convention** - Always `snake_case_tool` (e.g., `list_styles_tool`)
26+
- **Tool class naming** - Always `PascalCaseTool` (e.g., `ListStylesTool`)
27+
- **Schema separation** - Schema in `*.schema.ts`, implementation in `*.tool.ts`
28+
- **Use plop generator** - `npx plop create-tool` for new tools
29+
- **Zod validation** - All tool inputs validated with Zod schemas
30+
- ESLint and Prettier handle formatting - run `npm run lint:fix && npm run format:fix`
3431

35-
## Testing
32+
## 4. Testing Requirements
3633

37-
- Run all tests: `npm test`
38-
- Update tool snapshot tests after adding/removing tools:
39-
- `npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot`
40-
- Run a single test file: `npm test -- path/to/testfile.ts`
41-
- Only update snapshots when changes are intentional
34+
- **Run tests before committing** - `npm test`
35+
- **Update snapshots deliberately** - After adding/removing/modifying tools: `npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot`
36+
- Never update snapshots without understanding what changed
37+
- Snapshot tests capture tool metadata (class names, tool names, descriptions)
4238

43-
## PR & Branching
39+
## 5. Collaboration Standards
4440

45-
- Always run `npm run lint` and `npm test` before committing
46-
- Keep PRs focused and well-described
41+
- **Focused commits** - One logical change per commit
42+
- **Build before testing** - Always `npm run build` before running
43+
- **Check CI** - Tests must pass before merge
44+
- Reference issues/PRs in commit messages
4745

48-
## Tool Configuration
46+
## 6. When to Avoid Copilot Suggestions
4947

50-
- Tools can be enabled/disabled at startup (see `TOOL_CONFIGURATION.md`)
51-
- Example: `node dist/esm/index.js --enable-tools list_styles_tool,create_style_tool`
52-
53-
## Security & Tokens
54-
55-
- Each tool requires specific Mapbox token scopes (see `README.md`)
56-
- Using insufficient scopes will result in errors
57-
- Use `VERBOSE_ERRORS=true` for detailed error output
58-
59-
## Additional Resources
60-
61-
- [README.md](../README.md)
62-
- [AGENTS.md](../AGENTS.md)
63-
- [CLAUDE.md](../CLAUDE.md)
64-
- [TOOL_CONFIGURATION.md](../TOOL_CONFIGURATION.md)
65-
- [docs/claude-code-integration.md](../docs/claude-code-integration.md)
48+
- **Don't auto-accept** tool name changes without verifying snake_case_tool convention
49+
- **Don't merge** schema definitions into tool implementation files
50+
- **Don't skip** snapshot updates after adding/removing tools
51+
- **Don't commit** without running linter and tests
6652

6753
---
6854

69-
_Edit this file to keep Copilot up to date on project standards, commands, and best practices._
55+
**Key files:**
56+
57+
- `docs/engineering_standards.md` — Comprehensive contributor guidelines
58+
- `CLAUDE.md` — Architecture and technical patterns
59+
- `AGENTS.md` — AI agent development guide
60+
- `README.md` — Complete tool reference
61+
- `TOOL_CONFIGURATION.md` — Tool configuration

AGENTS.md

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,73 @@
11
# AGENTS.md — Mapbox MCP DevKit Server
22

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`.
44

55
---
66

7-
## Project Overview
7+
## Critical Patterns
88

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:**
1210

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)
1416

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:**
2318

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
2522

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:**
2924

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
3128

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
3930

40-
## Testing Instructions
31+
**Incorrect Tool Naming:**
4132

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`
4735

48-
## Tool Configuration
36+
**Incorrect File Structure:**
4937

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`
5240

53-
## PR Instructions
41+
**Incorrect Class References:**
5442

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`
5945

60-
## Security & Tokens
46+
**Incorrect Token Scope Usage:**
6147

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
6550

66-
## Agent Tips
51+
## Essential Commands
6752

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+
```
7259

73-
## Large Monorepo?
60+
## Development Workflow
7461

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`
7665

7766
---
7867

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

Comments
 (0)