Developer GuideEvolution

Extending Existing Tools

Rules for evolving existing MCP tools without breaking connected AI clients: additive Zod schemas, preview/apply parity, human approval rules, and audit summaries.

Backward-compatible Zod schema changes

AI clients cache tool JSON Schemas for the lifetime of an MCP session. Extending an existing tool must remain non-breaking for callers using previously discovered input shapes.

  • Additive optional fields only:: Introduce new parameters with .optional() or explicit .default(...) values. Never add a new required top-level field or remove/rename an existing enum value in a minor release.
  • Preserve existing field semantics:: When adding a granular override (for example, per-panel language settings), ensure omitting the field retains the existing guild-level behavior.
  • Strict schema boundaries:: Keep .strict() on nested sub-objects so typos or injected fields fail cleanly with VALIDATION_ERROR instead of silently dropping data.

Maintaining preview/apply parity and human approval gates

Every newly added configuration option must be evaluated identically in both preview and apply paths. Preview mode must validate channels, roles, regex safety, RBAC, and subscription tiers so callers never see a clean preview followed by an unexpected apply failure.

Escalating an operation to human browser approval

If a new sub-action deletes persisted panels, commands, or custom items, or creates/modifies Discord channels, roles, or permission overwrites, you MUST require mcp:destructive and route it through McpSetupPreview with requiresHumanApproval: true so the server manager approves it at /oauth/approve-action.

Updating field-level RBAC projections and audit summaries

  • Review field sensitivity:: Confirm whether the new field belongs to Real Discord Admin, Anti-Nuke Owner/Trusted, Manage Guild, or a delegated role, and update both write guards and get_server_configuration DTO projections accordingly.
  • Write specific changesSummary strings:: Record concise, human-readable summaries in appendAuditLog (for example, "Updated verification minimum account age to 7 days") while never interpolating secret tokens, webhook URLs, or full raw user payloads.
  • Sync manifest and tests:: Run npm --prefix mcp run build:docs-manifest after every schema edit and add regression coverage in mcp/tests/.

Related documentation