Skip to content

feat: factory MCP wiring — --mcp-server on mecatequi/mecak8s + compact summary - #347

Merged
JAORMX merged 1 commit into
mainfrom
factory-mcp-wiring
Aug 3, 2026
Merged

JAORMX merged 1 commit into
mainfrom
factory-mcp-wiring

Conversation

@JAORMX

@JAORMX JAORMX commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #341.

What:

  • Extracts mecated's --mcp-server name=URL parsing + MCP_<NAME>_TOKEN bearer resolution into internal/cliconfig/mcpserver.go and registers it on mecatequi and mecak8s (threaded onto app.Config.MCPServers); mecated switches to the shared helper with byte-identical help.
  • mecatequi --out-summary=-: emits the Summary as a single compact JSON line as the final stdout line, so a scheduler tailing logs can parse it (the indented default cannot be last-line-parsed). Default unchanged.
  • New ADR 0082 records the decision, including that --run-id/--task-ref are deliberately not accepted (schedulers correlate via their launch identity + Summary.session_id); factory invocation profile documented in docs/usage/mecatequi-ci.md (--posture auto, --untrusted-prompt, --timeout, token env, compact summary).

Security review (secure-code-reviewer pass, findings applied):

  • Server names validated ^[A-Za-z0-9_]+$ + case-insensitive env-name collision rejection (CWE-178) — deliberately tightens mecated too.
  • A token-bearing URL must be https or loopback, via the existing mcp.ValidateClientURL (CWE-319).
  • ADR caveat: mecak8s reads the token once at startup, process-wide — per-run identity framing is mecatequi-only; per-session credential source is MCP client: credential-source seam for refreshing short-lived bearer tokens #342.
  • Docs: the final-line guarantee is stdout-only; merged pod-log consumers take the last line that parses as the Summary.

Verified clean by the review: no token leak via String()/help/errors/Summary/event-log; envscrub already denies *_TOKEN to agent shells; SSRF/redirect posture unchanged; json escaping makes final_text unable to break single-line framing.

Gates: task build / test / lint / api:check / docs all green; engine module untouched (no api:update). All new tests watched red first.

🤖 Generated with Claude Code

…t summary (#341)

Register the repeatable --mcp-server name=URL flag and the MCP_<NAME>_TOKEN
bearer convention on mecatequi and mecak8s via a shared cliconfig.MCPServerList
helper (extracted from mecated, which now uses it too), so a scheduler
(titlani) can inject a short-lived per-run identity the run presents to vmcp /
tequitl MCP endpoints. An EXPLICIT --out-summary=- on mecatequi now selects a
stdout-compact mode: the Summary is emitted as a single compact JSON line as the
FINAL stdout line (the unset default keeps indented JSON). --run-id/--task-ref
are deliberately NOT accepted — schedulers correlate via their own launch
identity plus Summary.session_id.

Security-review hardenings (deliberately tightening mecated too):
- CWE-178: server names must match [A-Za-z0-9_]+ and be case-insensitively
  unique (vmcp/VMCP/vMcp all derive MCP_VMCP_TOKEN; my-svc would derive an
  unsettable env var and silently connect unauthenticated).
- CWE-319: a token-bearing URL must be https, or http to loopback (reuses
  mcp.ValidateClientURL), so an injected bearer never travels cleartext
  off-host. Tokenless URLs are not gated.
Docs note that on mecak8s the token is read once at startup and shared
process-wide (per-run identity is mecatequi-only; per-session credentials are
mecatl#342), and that the compact-summary last-line guarantee is stdout-only —
a merged pod log consumer must take the last line that PARSES as the Summary.

Recorded as ADR 0082 (pairs with titlani's run-contract ADR 0010); factory
invocation profile documented in docs/usage/mecatequi-ci.md. cmd/internal layer
only — the engine module and its API surface are untouched.

Co-Authored-By: Claude Fable 5 <[email protected]>
@JAORMX JAORMX added the e2e-live Run the live e2e suite on this PR label Aug 3, 2026
@JAORMX
JAORMX merged commit d9642d5 into main Aug 3, 2026
18 of 19 checks passed
@JAORMX
JAORMX deleted the factory-mcp-wiring branch August 3, 2026 16:55
JAORMX added a commit that referenced this pull request Aug 4, 2026
…independent (#360)

* feat(cliconfig): per-server --mcp-server-insecure-http opt-in, order-independent (#358)

MCPServerList.Set no longer runs the token-bearing scheme gate inline:
entries are collected during parse and the CWE-319 gate runs in a new
post-parse Finalize step the three mains (mecated, mecatequi, mecak8s)
call right after flag.Parse — so the new repeatable
--mcp-server-insecure-http <name> relaxation composes with --mcp-server
regardless of argv order (the titlani#40 contract addition).

The relaxation applies ONLY to the named server (same ^[A-Za-z0-9_]+$
name grammar as #347), ONLY to the http scheme; an unknown name, or a
name whose URL is https/loopback/non-http, is a loud error (a stale
acknowledgment is never silently inert). Default posture unchanged: a
token-bearing http non-loopback URL without the relaxation still fails.
Servers() panics fail-closed before a successful Finalize.

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs: ADR 0090 + operator docs for --mcp-server-insecure-http (#358)

New ADR 0090 records the per-server plain-http opt-in decision, the
rejected proxy-sidecar alternative (satisfies the gate without changing
wire security), the rejected global escape hatch, and the
order-independence requirement from titlani#40. Factory invocation
profile (docs/usage/mecatequi-ci.md), the mecated/mecak8s flag tables,
and the user-docs MCP pages state the acknowledgment plainly: cleartext
on the network path; network-layer controls + short-lived tokens are
the operator's mitigations. llms.txt regenerated.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-live Run the live e2e suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mecatequi/mecak8s: register --mcp-server and per-server bearer-token env (factory mode)

1 participant