# Repository Guidelines
This guide helps contributors work efficiently on the Entrez MCP Server (Cloudflare Workers + TypeScript).
## Project Structure & Module Organization
- `src/`: TypeScript source.
- `src/tools/`: MCP tools (Entrez, PubChem, PMC, BYOK, etc.).
- `src/lib/`: shared utilities (parsers, formatters, engines, types).
- Entry: `src/index.ts`; auth/crypto helpers in `src/accessAuth.ts`, `src/crypto.ts`.
- `dist/`: build output (generated by Wrangler).
- Tests/scripts at repo root: `test-*.js`, `quick-start.js`, `generate-kms-key.js`.
- Config: `wrangler.jsonc`, `tsconfig.json`, `biome.json`.
## Build, Test, and Development Commands
- `npm start` / `npm run dev`: run locally via Wrangler at `http://localhost:8787`.
- `npm run build`: production build.
- `npm run deploy`: deploy to Cloudflare Workers.
- `npm test` / `npm run test-api-key`: run API key rate-limit test.
- `npm run test-mcp`: test MCP transports.
- `npm run test-all`: run both test suites.
- `npm run format`: auto-format with Biome.
- `npm run lint:fix`: lint and fix with Biome.
- `npm run type-check`: TypeScript type checking.
- `npm run cf-typegen`: generate Cloudflare Worker types.
## Coding Style & Naming Conventions
- Language: TypeScript, 2-space indent, semicolons optional per Biome.
- Naming: `PascalCase` for classes/types (e.g., `ChunkingEngine.ts`), `camelCase` for functions/vars, `kebab-case` for tool file names when multiword.
- Use Biome for formatting/linting; keep diffs clean: `npm run format && npm run lint:fix`.
## Testing Guidelines
- Tests are node scripts in the repo root (no Jest):
- `node test-rate-limits.js`, `node test-mcp-transports.js`, `node test-uservault.js`.
- Add lightweight script-style tests near related code or root; name `test-<feature>.js`.
- Aim for clear console output; prefer deterministic fixtures.
## Commit & Pull Request Guidelines
- Commits: imperative present (“Add…, Refactor…, Fix…”); keep subject concise; include scope when helpful.
- PRs: include summary, rationale, linked issues, and testing notes; add screenshots/logs for UX/behavior changes; mention rate-limit or DO schema impacts.
## Security & Config Tips
- Never commit secrets. Use BYOK tools or env vars: `NCBI_API_KEY`, `KMS_KEY` (see `API_KEY_SETUP.md`).
- Validate locally before deploy: `npm run type-check && npm run test-all`.
- For Worker bindings/DO changes, update `wrangler.jsonc` and note migrations in the PR.