Skip to main content
VulnParse-Pin emblem VulnParse-Pin emblem
VulnParse-Pin
Architecture adr/ADR-0003-mcp-agentic-seam.md
View source on GitHub ↗

ADR-0003: Agentic MCP Server (vpp mcp) & SEP-1865 Workbench Seam

  • Status: Accepted
  • Date: 2026-11-30
  • Deciders: Quashawn Ashley
  • Tags: mcp|agentic|security|ui|remediation|schema

Context

VulnParse-Pin v2.0.x persists deduplicated findings, threat-intelligence snapshots, dual-track score_trace rationales, triage_decisions, and hash-chained ledger_events in .vpp.db (DuckDB), and interactively surfaces them via vpp ui and Decision Defense Dossiers. Engineering and SecOps teams increasingly triage vulnerabilities inside AI-assisted IDEs and agent workflows, where shell-scraping unstable CLI stdout or granting agents raw filesystem/SQL access introduces security and audit risks:

  1. Direct DuckDB write access or unverified deferral mutations bypass DecisionsRegistry assumptions and corrupt tamper-evident audit chains.
  2. Unbounded HTTP transports expose local scan workspaces to Cross-Site WebSocket Hijacking (CSWSH), DNS rebinding, or unauthenticated LAN access.
  3. Heavy runtime dependencies or external CDN assets in agentic UIs violate air-gapped enclave requirements and Apache-2.0 supply-chain hygiene.

A dedicated, fail-closed Model Context Protocol (MCP) seam is required so AI clients and humans can inspect findings, simulate minimum-patch remediations, verify RunManifest digests, and view interactive triage workbenches with zero external network calls.

Decision

Implement a zero-dependency-by-default stdlib JSON-RPC 2.0 MCP server (vpp mcp) in src/vulnparse_pin/mcp/ paired with a self-contained SEP-1865 MCP App UI (ui://vpp/workbench.html) and a turn-key IDE/assistant plugin bundle (plugins/vpp-mcp/):

  1. Read-Only Default (src/vulnparse_pin/mcp/tools.py, src/vulnparse_pin/cli/commands.py):
    • vpp mcp opens .vpp.db with VppDatabase(..., read_only=True) unless --allow-write is explicitly passed.
    • Seven read-only inspection, explanation, simulation, diff, and verification tools are exposed by default:
      • vpp_run_overview: Run KPI counts, priority lane breakdown (P1, P1B, P2, P3, P4), KEV/Pre-KEV counts, shadow asset counts, and top Remediation@1.0 actions.
      • vpp_query_findings: Paged findings query parameterized by run_id, priority, track, in_kev, pre_kev, unmatched_shadow, search, limit, and offset.
      • vpp_explain_finding: Detailed score_trace (including ml_aci attributions and Pre-KEV signals), SSVC decision path, merged scanner evidence, and linked remediation actions.
      • vpp_remediation_plan: Ranked Remediation@1.0 minimum-patch actions (upgrade_package, rebuild_image, remediate_service, fix_code_location).
      • vpp_simulate_remediation: Read-only counterfactual risk-reduction simulator supporting selectors (action_ids, top_n, action_types, target_filter) and goal-seeking presets (goal in clear-kev/clear-p1/clear-3day/clear-pre-kev/risk-pct with target_risk_pct), returning before/after/delta, by_sla, by_priority, by_asset, unresolved_kevs, unresolved_pre_kevs, burn_down_curve, and goal_summary (preserving the exact 7 read-only / 10 write-enabled tool surface).
      • vpp_diff_and_drift: Scan-over-scan comparison and --re-enrich / pre-kev / stale-assumption drift evaluation across DuckDB runs.
      • vpp_verify_manifest: Read-only RunManifest schema, digest, ledger hash-chain, and confined artifact verification.
  2. Opt-In Write Tools (--allow-write):
    • Three mutating tools remain disabled (returning ToolDisabledError / JSON-RPC -32601 / error response if called) unless --allow-write is passed:
      • vpp_scan_and_diff: Offline scan pipeline ingestion into .vpp.db with PermFileHandler path confinement (--workspace-root, --forbid-symlinks-read, --forbid-symlinks-write).
      • vpp_propose_deferral: Enforces non-empty falsifiable assumptions, owner, and future expires_at, updates decisions.yaml / triage_decisions, and appends a hash-chained MCP_DEFERRAL_PROPOSED (DecisionReasonCodes) event to ledger_events.
      • vpp_export_dossier: Exports dossier-md, dossier-html, roadmap-md, roadmap-html, remediation-json, remediation-md, csv, or json confined inside the workspace root.
  3. Hardened Transports (src/vulnparse_pin/mcp/server.py, src/vulnparse_pin/ui/gui_server.py):
    • stdio (default): Pure JSON-RPC 2.0 over stdin/stdout (supporting protocol versions 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05) with 4 MiB (MAX_MESSAGE_BYTES) frame cap, MAX_BATCH_ITEMS=64, MAX_JSON_DEPTH=64, allow_nan=False serialization, sanitized -32603 internal error replies, and strict stdout isolation (all logs, banners, and diagnostics routed to stderr).
    • streamable-http & vpp gui loopback HTTP: vpp mcp --transport streamable-http binds 127.0.0.1:8765 (VppMcpHttpServer) and vpp gui binds 127.0.0.1:8787 (VppGuiHttpServer), both backed by ThreadingHTTPServer, MAX_HTTP_CONCURRENCY=32 (BoundedSemaphore(32) returning 503 when saturated), and HTTP_SOCKET_TIMEOUT=15.0s. validate_http_security() refuses non-loopback --host bindings unless --auth-token-env names a set secret of at least 16 characters, verified per request via constant-time hmac.compare_digest on Bearer Authorization. Per-request HttpSecurityPolicy validates Host and Origin headers to block DNS-rebinding and CSWSH attacks, enforces 415 (Content-Type: application/json), 501 (Transfer-Encoding rejected), 400 on duplicate headers (Host, Origin, Authorization, Content-Type, Content-Length, X-VPP-CSRF), 413 above 4 MiB, and allow_nan=False. vpp gui additionally enforces a per-process 256-bit X-VPP-CSRF token (secrets.token_urlsafe(32) verified via hmac.compare_digest on POST /api/rpc), X-Frame-Options: DENY, and Content-Security-Policy: ... frame-ancestors 'none'.
  4. Unified 3-Mode, 6-Tab Workbench (src/vulnparse_pin/mcp/ui_app.py):
    • render_workbench_html() serves a zero-CDN, DOM-only (createElement/textContent) 7-tab interface (1. Overview, 2. What-If Simulator, 3. Findings & Trace, 4. Assets & Shadow IT, 5. Deferrals & Waivers, 6. Diff & Drift, 7. Exports & Proof) across three modes:
      • mode="mcp": Exposes ui://vpp/workbench.html (WORKBENCH_MIME_TYPE = "text/html;profile=mcp-app") wired via _meta.ui (workbench_entrypoint_meta on vpp_run_overview, workbench_inline_meta on vpp_explain_finding and vpp_remediation_plan, and visibility: ["model", "app"] on vpp_simulate_remediation) with WORKBENCH_RESOURCE_META (connectDomains: [], resourceDomains: []), <meta> CSP connect-src 'none', and initRpcId-gated hostOrigin latching.
      • mode="loopback": Powers vpp gui (src/vulnparse_pin/ui/gui_server.py) with connect-src 'self', X-VPP-CSRF, client-side in-memory exports (zero server disk writes), and write-gated modals (--allow-write) backed by McpToolDispatcher.
      • mode="static-simulator": Powers standalone offline simulator-html exports (vpp export --format simulator-html, vpp simulate --output-html, and vpp gui exports) with <meta> CSP connect-src 'none' and <script id="vpp-sim-snapshot" type="application/json"> escaped via _escape_json_for_script_tag().
  5. Plugin & Packaging (plugins/vpp-mcp/, pyproject.toml):
    • Ships plugins/vpp-mcp/{plugin.json,mcp_config.json,.mcp.json,README.md,skills/vpp-triage/SKILL.md} for instant integration over vpp mcp --transport stdio --db .vpp.db.
    • Declares optional mcp = ["mcp>=1.6.0"] extra in pyproject.toml and defaults container builds (Dockerfile) to EXTRAS="ui,mcp", while keeping runtime operational with stdlib alone when optional extras are absent.

Alternatives Considered

  1. Require official mcp Python SDK (FastMCP) as a mandatory core dependency:
    • Pros: Built-in transport scaffolding.
    • Cons: Increases core install footprint for CI pipelines that only run vpp scan/vpp diff and blocks minimal headless or air-gapped environments lacking optional wheels.
  2. Expose DuckDB SQL queries directly to MCP clients (vpp_sql):
    • Pros: Arbitrary ad-hoc querying.
    • Cons: Weakens read-only guarantees, risks SQL injection or schema coupling across v2.0.x / v2.1 migrations, and bypasses PermFileHandler confinement and RunManifest audit semantics.

Consequences

Positive:

  1. Core headless installs keep zero new mandatory dependencies while vpp mcp works out of the box.
  2. Default read-only posture prevents unapproved agent mutations; opt-in deferrals require falsifiable assumptions and leave hash-chained MCP_DEFERRAL_PROPOSED audit trails.
  3. Air-gapped enclaves and enterprise hosts get deterministic DNS-rebinding protection, constant-time Bearer auth for non-loopback HTTP, and a zero-CDN SEP-1865 HTML workbench.

Negative:

  1. Protocol handler maintenance for JSON-RPC 2.0 stdio and streamable-http lives in first-party code (src/vulnparse_pin/mcp/server.py) alongside unit tests tracking MCP protocol revisions.
  2. Tool schema updates require keeping plugins/vpp-mcp/skills/vpp-triage/SKILL.md and ui_app.py synchronized.

Compatibility & Licensing Impact

  • Classification: additive
  • Affected contracts: New CLI subcommand vpp mcp; new MCP JSON-RPC 2.0 tool/resource seam (ui://vpp/workbench.html); additive MCP_DEFERRAL_PROPOSED ledger reason code; additive DuckDB remediation_actions / remediation_action_findings tables (all read-only MCP queries gracefully inspect information_schema on legacy v2.0.x .vpp.db files).
  • Clean-room Apache-2.0 dependency compliance verified: yes (pure Python stdlib runtime; optional mcp>=1.6.0 is MIT).
  • Migration guidance: Existing v2.0.x .vpp.db workspaces work read-only with vpp mcp without migration; re-running vpp scan populates Remediation@1.0 tables automatically.

Test and Validation Plan

  1. Contract & schema tests: JSON-RPC initialize, tools/list, resources/list, resources/read (ui://vpp/workbench.html), read-only 7-tool vs --allow-write 10-tool filtering, and legacy v2.0.x DB read-only queries (tests/test_mcp_server.py).
  2. Security / adversarial tests: Write tool rejection when --allow-write is off, non-loopback HTTP startup refusal without 16+ char --auth-token-env, Bearer timing check (401/403), Host/Origin DNS-rebinding rejection, PermFileHandler traversal/symlink rejection, 4 MiB oversized payload 413 handling, vpp_propose_deferral rejection of missing assumptions or past expires_at, and zero-CDN CSP assertion (tests/test_mcp_server.py).
  3. Runtime verification: Live vpp mcp --db <demo.db> stdio round-trip (initialize -> tools/call vpp_remediation_plan -> resources/read ui://vpp/workbench.html) ensuring zero stdout contamination.

Rollout and Rollback

  • Rollout: Shipped enabled in v2.1.0 (read_only=True, stdio default); users opt in explicitly to --transport streamable-http and --allow-write.
  • Rollback: Disable MCP integration by not invoking vpp mcp; no core vpp scan, vpp diff, or vpp verify paths depend on the MCP package.

References