Skip to content

feat(tools): resolve and inject bundle tools (MCP/API) into a run#88

Closed
chenhunghan wants to merge 5 commits into
feat/registry-login-policy-artifactsfrom
feat/tool-injection
Closed

feat(tools): resolve and inject bundle tools (MCP/API) into a run#88
chenhunghan wants to merge 5 commits into
feat/registry-login-policy-artifactsfrom
feat/tool-injection

Conversation

@chenhunghan

@chenhunghan chenhunghan commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #61 (feat/registry-login-policy-artifacts). Teaches lns run <bundle> to actually use the bundle's tool components instead of skipping them — meeting the tool schema the lns-registry already defines.

What it does

  • lns-policy — typed ToolArtifact mirroring the registry tool schema (kind: mcp|api, transport stdio|sse|http, requiredIntegrations) with a from_config_blob validator, plus the agent's spec.mcp injection point (configPath + format, default mcpServers).
  • lns-cli resolve — pulls each tool component; folds remote (http/sse/api) tools' hosts into the run policy as allow-routes and their requiredIntegrations into the policy integrations; renders the de-facto mcpServers config targeted at spec.mcp.configPath. Partial policies still round-trip byte-for-byte when nothing is added.
  • lns-ipcMcpConfig { target, content } carried on RunImageArgs / RunConfig.
  • lns-service — receives the McpConfig on the run request; the guest-rootfs write is the deferred hop (below).

Design

Lens-sandbox is a tool-config materializer, not an MCP host: tools run in-guest under the existing policy/credential machinery; the agent's own MCP client spawns/dials them from a config we write. Full rationale, the kind/transport split, and the open decisions are in the design doc (shared separately).

Scope / what's deliberately deferred

  • The guest-write hop is not yet wired. The McpConfig reaches the daemon but is not yet written into the running microVM at configPath — that step is Linux-microVM/Vz-only and can't be built or tested from a macOS host. The host-side spine (resolve → fold policy → render → carry to the daemon) is fully tested; the guest write is the remaining hop.
  • Tools shipping their own image (so a stdio binary need not pre-exist in the agent image) needs an image/layers field on the registry tool schema + guest rootfs overlay — a companion change in lns-registry, out of scope here.
  • Registry-side: the agent schema should gain spec.mcp (and the pending resources/ports/volumes drift fix) — follow-up in lns-registry.

Tests / gate

make lint + make complexity green. New Layer-3 coverage: tool artifact parse/validate (every kind/transport + error paths), remote-tool policy folding (synthesized + augmented), mcpServers rendering (stdio command/args and remote url), the missing-spec.mcp warning, and the IPC McpConfig round-trip. Full make coverage not run locally.

Mirror the registry tool schema (kind mcp|api, transport stdio|sse|http,
requiredIntegrations) as a typed, validated artifact, and let the agent
artifact declare where its MCP client config is written (spec.mcp).
Pull each tool component, fold remote (http/sse/api) tools' hosts into
the run policy as allow routes and their requiredIntegrations into the
policy integrations, and stop skipping tools. The policy blob is left
byte-identical when no tool needs egress, and synthesized or augmented
as tolerant JSON when one does, so partial policies still round-trip.
…e daemon

Render the resolved tools as the de-facto mcpServers shape, targeted at
the agent-declared spec.mcp.configPath, and thread it through RunImageArgs
/ RunConfig to the daemon. The terminal guest-write hop is staged in the
platform-only run orchestrator (Vz/Linux, coverage-exempt) and marked as
the injection seam; everything up to it is host-tested.
The McpInjection/McpTransport/McpConfig doc comments restated their own
names, and the orchestrator comment referenced a doc that would rot; the
field names and the log line carry the meaning.
The field is carried through the run request; the guest-rootfs write is
the deferred platform hop, so the orchestrator no longer narrates it.
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