AI & MCP Protocol Contract (v1.7 Baseline → 2.0 Spec)

English summary & setup: mcp.md · Architecture: ../ARCHITECTURE.md · Constitution: ../AGENTS.md

OpenHull treats Agent Experience (AX) as a first-class design constraint. Rather than embedding a brittle custom multi-turn agent harness, OpenHull exposes deterministic, unit-checked, self-explaining tools for external AI harnesses (Claude Code, Antigravity, Codex, Cursor, ZCode, local LLMs) via MCP (openhull-mcp) and Skills (skills/openhull/).


Part I · Implemented MCP Surface (v1.7.0–v1.11.0)

Currently implemented in src/openhull/mcp_server.py as a lazy-optional openhull[mcp] stdio server wrapping python -m openhull.cli in isolated UTF-8 subprocesses:

  • Active Tools:
  • openhull_version: returns package/Python/MCP SDK versions and optional extras availability (seakeeping, mcp).
  • openhull_check: validates YAML taskbook fields and §6 applicability guard bands in seconds.
  • openhull_run: executes the full preliminary-design chain (dimensions → weight/balance → hydrostatics → intact stability → freeboard → resistance/propulsion → propeller → seakeeping → charts/DXF/report).
  • openhull_optimize: runs parametric (L/B, B/T, Cb) design-space scans with per-stage refusal tracking and Pareto outputs.
  • openhull_rao: computes zero-speed rigid-body RAOs when openhull[seakeeping] (capytaine) is installed.
  • Active Resource: openhull://taskbook-template (anchored taskbook template with [NMRI] / [DERIV] / [ASSUMED] provenance tags).
  • Current Response Envelope: json { "ok": true, "exit_code": 0, "command": ["check", "taskbook.yaml", "--json"], "result": {}, "stderr_tail": "", "artifacts": {"design_report.md": "/abs/path/to/design_report.md"}, "error": null }

Part II · OpenHull 2.0 AI-First Target Contract (Stage 1–4)

All new MCP tools introduced across Stage 1–4 follow four binding contracts defined in AGENTS.md §7–§8 and ARCHITECTURE.md:

1. Handle-Based Workspace State (hull_id) — No Context Flooding

Raw 3D control nets, NURBS knot vectors, and dense triangulated hull meshes must never be serialized verbatim into routine MCP responses.

  • Geometry creation, import, or modification returns a lightweight workspace handle (hull_id) plus compact geometric metadata: bounding box (Lpp/Loa, B, D), patch count, symmetry mode, feature curve names, and optional preview URI (http://127.0.0.1:<port>/view/<hull_id>).
  • Downstream tools (slice_hull, deform_ffd, calc_attitude, export_cad, build_calcbook) accept hull_id (and optional case_id / loading_id).
  • Any workspace mutation broadcasts a lightweight event so an attached openhull gui instance refreshes its 3D/2D canvas immediately (Live Canvas).

2. Dual-Mode Response Profile (mode: "teaching" | "engineering")

Every modeling or physics tool accepts mode (defaulting to workspace/profile setting, engineering for headless batch compatibility):

  • engineering mode:
  • Compact numerical JSON, unit-explicit fields, guard pass/refusal flags, KPI tables, and file paths in artifacts.
  • Designed for batch runs, optimization loops, and token efficiency.
  • teaching mode:
  • Includes standardized AuditTrace entries (formula_id, whitelist_ref, formula_latex, inputs, intermediates, guard_status, teaching_note) plus optional highlight_targets (matching 2D curve IDs ↔ 3D spatial curves for openhull gui).
  • Allows the external AI harness to act as an accurate, zero-hallucination naval-architecture tutor or shipyard mentor without inventing formulas or intermediate steps.

3. Self-Correcting Validation & Guard Errors

Invalid inputs or §6 applicability violations never fail silently or extrapolate. Errors return structured diagnostics designed for both human learning and automated AI self-correction:

{
  "ok": false,
  "error_type": "SpecValidationError | ApplicabilityGuardRefusal",
  "field": "cb",
  "value": 1.15,
  "allowed": "0 < Cb <= 1.0",
  "why": "Block coefficient is displacement volume divided by Lpp * B * T; a hull cannot displace more water than its bounding box.",
  "guard_id": "spec.cb_physical_bound",
  "suggested_actions": [
    "Set Cb within the vessel type's physical/formula applicability band (e.g. 0.75-0.88 for bulk carriers)."
  ]
}

4. Planned 2.0 Tool Groups (Incremental Rollout)

Group Planned MCP Tools Target Stage
Workspace & GUI workspace_status, workspace_list_hulls, gui_focus_view (focus 3D camera, highlight station/waterline/feature curve, switch mode) Stage 1
Geometry & Import hull_create_from_template (6 types), hull_import (CSV/JSON/TXT/chines/multi-patch IGES), hull_fit_offsets, hull_deform_ffd, hull_lackenby Stage 2
Slicing & CAD Export hull_slice_planes (stations/waterlines/buttocks/diagonals/oblique), hull_fairness_report, export_lines_dxf, export_iges, export_cfd_stl, unfold_plates Stage 1–3
Hydrostatics & Stability calc_hydrostatics, calc_attitude (arbitrary trim/heel), solve_equilibrium, calc_gz_cross_curves, check_stability_criteria Stage 1 & 3
Compartments & Strength define_compartments, calc_tank_sounding, solve_loading_condition, calc_damage_stability, calc_longitudinal_strength Stage 3
Hydrodynamics & Calcbook predict_resistance (multi-type + Savitsky), match_propulsion, estimate_maneuvering, generate_calcbook (MD/HTML/LaTeX) Stage 3–4

5. Harness Responsibility Boundary

  • External AI Harness owns: intent understanding, pedagogical pacing for complete beginners, multi-step parameter search orchestration, file organization outside OpenHull artifacts, and multi-turn conversation memory.
  • OpenHull MCP Server owns: deterministic geometry and physics execution, §5 whitelist traceability, §6 applicability refusals, workspace handle integrity, CAD/report artifact generation, and live synchronization to openhull gui.