Repository navigation
Add generic mcp.mode:config declarative MCP injection (#202) - #212
Conversation
BYO agents Phase 3: wire a data-only agent whose harness only reads a
config file to the in-VM MCP proxy declaratively, without a per-agent Go
MCPInjector.
- Domain: add MCPInjectConfig (config) and agent.MCPInjectEntry (resolved)
types plus the Agent.MCPInject / VMConfig.MCPInject fields. Accept
mcp.mode: config in IsValidMCPMode and map inject entries in
AgentFromOverride.
- Validation: replace the "not supported" rejection with per-entry checks
(safe relative guest_path, known format, non-empty merge); require
mode:config when inject is set, and at least one entry when it is.
Extend the "standard profile needs egress_hosts" exception to config
mode (the proxy is the agent's egress path).
- Infra: generic MCPConfigInjector in internal/infra/settings reusing the
existing parse/serialize/deepMerge/containment helpers (YAML added to
the shared format switch), with ${BBOX_*}-scoped env substitution.
- Runtime: the VM runner builds the declarative injector from
VMConfig.MCPInject when no bespoke plugin injector is set and the proxy
is available; sandbox drops the plugin injector for env/config modes and
enables the proxy for config mode.
- Security: workspace-local .broodbox.yaml can never introduce or widen
mcp.inject (sourced from trusted global config only).
- Surface an inject count in the agents receipt; update CLAUDE.md.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
The manual strings.Index scan paired the first "${" with the nearest
following "}", so an earlier malformed "${" span could swallow a
legitimate later "${BBOX_MCP_URL}" token and leave it unsubstituted
with no error. Switch to a compiled regexp matching well-formed
"${IDENTIFIER}" tokens independently.
Review summaryReviewed with Fixed in a follow-up commit:
Everything else checked out clean — no security findings, no layer violations, injector-selection logic in Noted but deferred (same call as on #210): the "is this mode proxy-only (env or config)?" predicate is hand-inlined in 3 places ( All changes verified via |
jhrozek
left a comment
There was a problem hiding this comment.
Reviewed and fixed the issue found (see comment above). LGTM.
Closes #202.
BYO agents Phase 3. Follow-up to #191 (epic) / #200 (Phase 1
mcp.mode: env). Adds the second generic mode,mcp.mode: config, so a custom/BYO agent whose harness only reads a config file can be wired to the in-VM MCP proxy declaratively — without a per-agent GoMCPInjector.What it does
Declaratively patch a JSON/JSONC/TOML/YAML config file in the guest home:
At VM start the file is created (or merged onto existing content),
${BBOX_*}references are substituted from the universal env (from #200), and the result is written back in the declared format.Layering
config.MCPInjectConfig(YAML) →agent.MCPInjectEntry(resolved), mapped inconfig.AgentFromOverride. New fieldsAgent.MCPInjectandVMConfig.MCPInject.internal/infra: a newsettings.MCPConfigInjectorreuses the existingparseConfig/serializeConfig/deepMerge/containment helpers used by settings injection (YAML added to that one shared format switch — no duplicate parser). JSONC support is the samestripJSONCalready ininternal/infra/settings.${BBOX_*}substitution is scoped to theBBOX_prefix so forwarded host secrets can't be expanded into a guest file; unknown/absent tokens are left literal.config.MCPEndpointPath(/mcp) remains the single source of truth.VMConfig.MCPInjectwhen no bespoke plugin injector is set and the proxy is actually available. Built-ins keep their bespokePlugin.MCPConfig().Validation & safety
ValidateCustomAgentnow acceptsmcp.mode: config(was rejected as "not supported") and validates eachinjectentry: safe relativeguest_path, knownformat, non-emptymerge.injectwithoutmode: configis rejected;mode: configwith noinjectis rejected.egress_hosts" gate is relaxed forconfigmode as it already is forenv(the proxy is the agent's egress path);egress.Resolveremains the authoritative runtime check..broodbox.yamlcan never introduce or widenmcp.inject— it is sourced from the trusted global config only (mergeAgentOverride). Locked in by a test.Tests
AgentFromOverride; accept/reject cases inValidateCustomAgent; local-configmcp.injectignored.mergesubtree).mcp.mode:configdrops the plugin injector and forwardsMCPInject, proxy still enabled viaBBOX_MCP_URL.task verify(fmt + lint + test) is green.🤖 Generated with Claude Code