# Development

To develop or contribute to the Docs MCP Server:

-   Fork the repository and create a feature branch.
-   Follow the code conventions in [ARCHITECTURE.md](ARCHITECTURE.md).
-   Write clear commit messages (see Git guidelines below).
-   Open a pull request with a clear description of your changes.

For questions or suggestions, open an issue.

### Architecture

For details on the project's architecture and design principles, please see [ARCHITECTURE.md](ARCHITECTURE.md).

_Notably, the vast majority of this project's code was generated by the AI assistant Cline, leveraging the capabilities of this very MCP server._

## Development Workflow

### Key Commands

Use Node.js v22 for local development (for example, `nvm use 22`). If you switch Node versions after installing dependencies, run `npm rebuild` to recompile native modules.

| Task | Command | Description |
|------|---------|-------------|
| **Setup** | `npm install` | Install dependencies |
| **Build** | `npm run build` | Build both server and web assets |
| **Lint** | `npm run lint` | Check code issues with Biome |
| **Fix** | `npm run lint:fix` | Auto-fix lint issues (add `-- --unsafe` if needed) |
| **Typecheck** | `npm run typecheck` | Run TypeScript compiler checks |
| **Format** | `npm run format` | Format code with Biome |
| **Test All** | `npm test` | Run all tests with Vitest |
| **Test Single** | `npx vitest run <path>` | Run a specific test file (e.g., `src/utils/foo.test.ts`) |

### Git Workflow

- **Branching**: `<type>/<issue>-<desc>` (e.g., `feat/123-add-cache`)
- **Pre-commit**: Husky runs lint, typecheck, and tests. **Never** bypass.
- **Security**: **NEVER** commit secrets, credentials, or sensitive data (e.g., `.env`).

### Commit Messages

Strictly enforced by `commitlint`. Commits will fail if format is incorrect.

- **Format**: `<type>(<scope>): <subject>` (Scope is optional but recommended)
- **Types**: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
- **Subject Rules**:
  - Must be **lower case**
  - Must **NOT** end with a period
  - Keep header under 100 characters
- **Body/Footer**:
  - Separate from header with a blank line
  - No line length limit (configured in `commitlint.config.js`)
