Skip to content

Ship the MCP prebuilt + per-call execution context (Phase A) - #30

Open
JeroenSoeters wants to merge 12 commits into
mainfrom
mcp-prebuilt-distribution
Open

Ship the MCP prebuilt + per-call execution context (Phase A)#30
JeroenSoeters wants to merge 12 commits into
mainfrom
mcp-prebuilt-distribution

Conversation

@JeroenSoeters

@JeroenSoeters JeroenSoeters commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What

Phase A of moving the MCP toward a prebuilt, bundle-and-ship distribution and reworking how it locates and versions the formae binary. Classic (self-hosted agent) behavior is unchanged; nothing hosted-specific is added here — this phase lays the structural seams for that later work.

Why

Two problems motivated this:

  1. Compile-on-first-launch. The launch script rebuilt the server from source on the user's machine. It now runs a prebuilt binary, compiling only as a dev fallback (toolchain present and sources newer).
  2. A real ordering bug. apply_forma / destroy_forma evaluated the forma file (shelling out to a bare formae) before resolving the client/profile, so eval and submission could disagree on which binary/endpoint to use. Handlers now resolve one immutable execution context up front and thread it through eval, extract, feature-gates, and submission.

Changes

  • internal/formaebin — mode-aware resolver picking which formae to run (classic: the user's own install → known locations → bundled fallback; the bundled binary is used when none is installed).
  • internal/execctx — an immutable per-call execution context {profile, mode, endpoint, installation, credentialRef, formaeBin} resolved once per call.
  • Handlers resolve that context first and thread it everywhere; the eval-before-client bug is fixed.
  • featuregate version detection is keyed to the resolved binary path (per-binary cache), so a binary swap is observable.
  • All formae exec sites centralized through the resolver — no bare exec.Command("formae", …) remain.
  • Version-skew notice — a non-blocking advisory when the connected agent and local formae versions differ (surfaced on health/apply/extract; never turns a success into an error).
  • Launch script runs the prebuilt binary and exports the bundled-formae path.
  • Plugin renamed formae-mcpformae; added /formae:setup and /formae:upgrade skills + a migration note.

Testing

make test green across all packages (new internal/execctx and internal/formaebin included); go vet ./... clean. New unit tests cover resolver branches, per-binary version detection, the context-binary wiring, and the skew notice both directions.

…esh version cache on binary change

- Add withNotice helper: appends the skew notice as a second content block
  so the primary JSON receipt (apply) or PKL output (extract) in block 0
  remains parseable with no prefix to strip.
- Refactor buildSkewNotice to accept a pre-resolved formaeBin path instead of
  re-running resolveCtx internally; handleCheckHealth now resolves ctx once and
  reuses it for both the health check client and the skew notice.
- Key the featuregate version cache on file identity (path + mtime + size) so
  an in-place binary upgrade (same path, new build) invalidates the stale entry
  instead of returning it for the process lifetime. Stat failures fall back to
  path-only key, keeping TestDetectIsKeyedByBinary green.
- Normalize skill references in README to plugin-namespaced form
  /formae:<skill-dir-name> throughout (table, authoring paragraph, verify step).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant