Instruction file imported from MadaBurns/bv-mcp (
.github/instructions/tools.instructions.md). Copyright stays with the author.
MCP Tool Implementation
- Validate and normalize all domain input with
validateDomainandsanitizeDomainfromsrc/lib/sanitize.ts. - Build findings and results with
createFindingandbuildCheckResultfromsrc/lib/scoring.ts. - Do not manually construct finding objects.
- Keep public error messages client-safe and prefixed with approved safe prefixes such as
Missing requiredorInvalid. - Preserve Cloudflare Workers compatibility. Avoid Node-only runtime APIs.
- Return responses via
buildToolContent(text, structuredData, format)fromsrc/handlers/tool-formatters.ts. Full-format mode appends structured JSON automatically. - Never hardcode secrets in tool code, tests, fixtures, scripts, or docs. Use env vars/secrets bindings only.
Registration checklist for new tools
- Create
src/tools/check-<name>.ts→ export async fn returningCheckResult - Add Zod schema to
src/schemas/tool-args.ts(or useBaseDomainArgsif domain-only) + add toTOOL_SCHEMA_MAP - Add tool entry to
TOOL_DEFSinsrc/schemas/tool-definitions.ts(name, description, schema, group, tier, scanIncluded) - Add to
TOOL_REGISTRYinsrc/handlers/tools.ts(import + cacheKey + execute) - Add
CheckCategoryto union inpackages/dns-checks/src/scoring/model.ts+CATEGORY_DISPLAY_WEIGHTS - Add to
IMPORTANCE_WEIGHTSinpackages/dns-checks/src/scoring/engine.ts - Add to
DEFAULT_SCORING_CONFIGweights, profileWeights (all 5), baselineFailureRates inscoring-config.ts - Add to all 5
PROFILE_WEIGHTSmaps incontext-profiles.ts - Add to
FREE_TOOL_DAILY_LIMITSinconfig.ts - Add explanation templates in
explain-finding-data.ts - If part of
scan_domain, add to parallel orchestration inscan-domain.ts(static import) - Add
test/check-<name>.spec.tsusingdns-mockhelper pattern - Update README tools table
Note: tool schemas are defined in src/schemas/tool-definitions.ts (TOOL_DEFS); import TOOLS / TOOL_SCHEMA_MAP from there.
Caching and force refresh
- Use
runWithCachefor tool and scan caching consistency. - Respect key patterns:
cache:<domain>cache:<domain>:check:<name>cache:<domain>:profile:<profile>
- Ensure
force_refreshpropagates cache bypass. - Per-tool cache TTL overrides via
cacheTtlSecondsinTOOL_REGISTRY(e.g.,check_lookalikes: 3600).
Reference docs
- Architecture and conventions: CLAUDE.md
- Contributor workflow: CONTRIBUTING.md
- Scoring details: docs/scoring.md
- Client behavior and formats: docs/client-setup.md
Secret handling checklist
- Use Worker secrets/bindings for production auth values.
- Keep local developer secrets in local-only files such as
.dev.vars(gitignored). - If a key is exposed, rotate immediately, update clients, and rerun secret scanning.