Developer GuideVitest
Testing
Automated Vitest suites covering OAuth 2.1 security, RBAC isolation, 18-surface tier enforcement, destructive approval governance, and docs parity.
Automated test suites in mcp/tests/
Taicket MCP maintains five dedicated Vitest suites in mcp/tests/ alongside TypeScript strict compilation and full bundle verification. Every security hardening, tier gate, and documentation contract is tested automatically.
| Suite File | Verification Scope |
|---|---|
| mcp/tests/oauth.test.ts | 401 RFC 9728 challenges, RFC 8414 metadata, PKCE S256 constant-time verification, RFC 8707 resource validation, pinned-IP CIMD SSRF rejection, DCR redirect validation, atomic refresh rotation & replay family revocation, AES-256-GCM encryption, and SHA-256 token hashing. |
| mcp/tests/security.test.ts | Server-derived ctx.userId anti-spoofing, allowedGuildIds isolation, BotBlacklist blocking, field-level RBAC parity (Temp Admin, regular Admin, Interviewer, Anti-Nuke), dashboard-only rejections, cross-guild channel validation, isRoleSafeForDelegation, ReDoS guard, trusted-proxy IP extraction, HMAC hash-chained audit logs, and sanitizeMcpError zero-leakage. |
| mcp/tests/premium.test.ts | Exact 1:1 Free, Pro, and Enterprise tier enforcement across all 18 audited gated surfaces plus read-only billing invariants (zero write path to GuildSubscription, SubscriptionSlot, or PromoCode). |
| mcp/tests/governance.test.ts | preview_setup -> human browser approval (/oauth/approve-action) -> apply_setup flow, payloadHash mismatch rejection, expired plan rejection, single-use confirmationToken enforcement, mcp:destructive gating, and idempotent retries. |
| mcp/tests/docs-quality.test.ts | 100% tool-to-doc parity against mcp/src/tools/registry.ts (all 31 tools), zero em dashes in source code, zero banned AI-slop phrases, valid JSON.parse() on every JSON code block, and zero broken internal links. |
Running tests, typechecks, and full builds
Standard verification commands from repository rootbash
# Run all 5 Vitest suites
npm --prefix mcp test
# Run a single targeted test file
npx --prefix mcp vitest run tests/security.test.ts
# Strict TypeScript type checking (server + docs-site)
npm --prefix mcp run typecheck
npm --prefix mcp/docs-site run typecheck
# Full build: server dist + tools-manifest.json + static Next.js docs bundle
npm --prefix mcp run build:allTesting conventions for security regressions
- Assert negative authorization paths first:: Every new tool or option must include tests verifying failure when the caller lacks the required scope, lacks live Discord permissions, targets an unlisted guild in allowedGuildIds, or belongs to a lower subscription tier.
- Test error redaction explicitly:: Feed synthetic exceptions containing fake mongodb+srv:// strings, stack frames, and collection names into sanitizeMcpError and assert none of those substrings appear in the returned payload.
- Verify JSON and link integrity:: Whenever adding examples to mcp/docs-site/src/content/, run docs-quality.test.ts so malformed JSON or stale internal routes fail before commit.