Skip to content

M59 (TASK-116-FREE): Collapse Default verity serve MCP Surface to 3 Core Tools & Omit Unlicensed Pro Actions

1. Purpose & Architectural Decisions

  • Problem: exposing 9 tools (4 unified + 5 legacy + DB guard/oracle) in verity serve bloats every LLM turn's context window and produces mid-session PRO_FEATURE_REQUIRED traps when an agent selects an unlicensed action.
  • Decision (P0.4): collapse the default tools/list surface to 3 read-only core tools plus 1–2 lightweight MCP prompts, omit unlicensed Pro tools/actions from discovery at startup, default the transport to stdio, and harden the opt-in HTTP/SSE transport.
  • Deterministic truth invariant: tools/list and prompts/list are a pure function of (installed edition,--legacy-tools, module profile); a direct tools/call to a tool absent from tools/list returns a deterministic UNAVAILABLE_IN_COMMUNITY_EDITION envelope with retryable: false, never a partial execution.
  • Free/Pro boundary: Free ships the 3 read-only tools, preview-only remediation (unified diff + patch_sha256), and both prompts. Licensed verity_remediate_apply (destructive) and the DB tool profile require verity-pro / verity-lite.

Default surface contract

  1. verity_scan (readOnlyHint: true, destructiveHint: false)
  2. verity_policy_check (readOnlyHint: true, destructiveHint: false)
  3. verity_remediate_preview (readOnlyHint: true, destructiveHint: false) — returns a unified diff + patch_sha256 + an escalation hint requiring explicit user confirmation via verity fix --apply or a licensed verity_remediate_apply.
  4. (appended ONLY when a verity-pro / verity-lite license is active) verity_remediate_apply (readOnlyHint: false, destructiveHint: true, requires patch_sha256 and user_confirmed: true).

prompts/list / prompts/get expose audit_workspace_security and audit_mcp_configs. Legacy tools hide behind --legacy-tools; verity_database_guard / verity_database_oracle hide behind --profile db or verity.toml [mcp.modules] database = true.

2. Target Files & Technical Deliverables

File Deliverable
src/verity/mcp_server/schemas.py 3 core unified tool schemas, conditional verity_remediate_apply, prompt definitions, and read-only/destructive annotations.
src/verity/mcp_server/tools.py Dispatcher resolves the active surface from edition + flags; returns UNAVAILABLE_IN_COMMUNITY_EDITION with retryable: false and free_alternative for unlicensed calls.
src/verity/mcp_server/server.py tools/list / prompts/list / prompts/get honor the collapsed surface; stdio remains default.
src/verity/mcp_server/handlers/remediation.py verity_remediate_preview builds diff + patch_sha256 without disk mutation; verity_remediate_apply gated.
src/verity/mcp_server/handlers/security_scan.py Back verity_scan / verity_policy_check actions against the collapsed schemas.
src/verity/cli.py --legacy-tools, --profile db, default stdio; --transport http binds 127.0.0.1:8765 with Origin validation and a per-session bearer token.
tests/unit/mcp_server/test_collapsed_mcp_surface.py New ATDD suite (below).

3. ATDD Traceability Matrix

AC ID Acceptance Criterion Paired Benign / Negative Control Verification Tier Test Target
AC-59.1 Default verity serve tools/list returns strictly [verity_scan, verity_policy_check, verity_remediate_preview] (all readOnlyHint: true, destructiveHint: false), and prompts/list returns audit_workspace_security and audit_mcp_configs. A fourth default tool (legacy or Pro) appearing without a flag fails the assertion. unit tests/unit/mcp_server/test_collapsed_mcp_surface.py::test_default_tools_list_and_prompts
AC-59.2 --legacy-tools and --profile db (or [mcp.modules] database = true) expose legacy/DB tools only when explicitly requested. Default invocation without either flag never leaks legacy or DB tools. unit tests/unit/mcp_server/test_collapsed_mcp_surface.py::test_legacy_and_db_opt_in_profiles
AC-59.3 Without verity-pro, verity_remediate_apply and Pro actions are omitted from tools/list; a direct tools/call returns retryable: False, error_code: "UNAVAILABLE_IN_COMMUNITY_EDITION", and a non-empty free_alternative. Benign control: verity_remediate_preview returns a unified diff + patch_sha256 without mutating disk. unit tests/unit/mcp_server/test_collapsed_mcp_surface.py::test_unlicensed_pro_actions_omitted_and_gated
AC-59.4 verity serve defaults to stdio; --transport http rejects an invalid Origin and unauthenticated requests lacking the per-session bearer token. Authenticated request from an allowed Origin succeeds. unit tests/unit/mcp_server/test_collapsed_mcp_surface.py::test_stdio_default_and_http_hardening
AC-59.5 Lint and the full unit suite pass. Clean workspace yields zero lint errors. ruff uv run ruff check src tests scripts && uv run pytest tests/

4. Verification Commands

uv run pytest tests/unit/mcp_server/test_collapsed_mcp_surface.py
uv run pytest tests/
uv run ruff check src tests scripts

5. Execution Checklist

  • [ ] AC-59.1 verified green
  • [ ] AC-59.2 verified green
  • [ ] AC-59.3 verified green
  • [ ] AC-59.4 verified green
  • [ ] AC-59.5 verified green
  • [ ] Board #5 item PVTI_lAHOD-xmQM4Br351zhOMDLg synced & status updated