Files
pad/cmd
xarmian 73208bf9d3 feat(mcp): expose AgentBootstrap via three MCP surfaces (TASK-1380) (#519)
* feat(mcp): expose AgentBootstrap via three MCP surfaces (TASK-1380)

PLAN-1377 T3: Expose the bootstrap blob (from TASK-1379) via the three
MCP surfaces the agent specs name. One canonical builder
(Server.BuildAgentBootstrap), three discovery paths.

Surfaces

1. Resource: pad://workspace/{ws}/bootstrap. Hosts that prefetch
   resources at session start (Claude Desktop, Cursor) get full
   context cheap. readBootstrap shells out to `pad bootstrap`.
2. Tool action: pad_meta.action=bootstrap. Mid-session refresh for
   agents that didn't get the resource prefetch or want a fresh
   snapshot after lots of mutations. Pass-through to `pad bootstrap`
   via env.Dispatch — same source of truth.
3. pad_set_workspace response embed: when a BootstrapFetcher is wired
   in (production has one via ExecBootstrapFetcher), the response
   payload extends from {workspace, status} to {workspace, status,
   bootstrap}. One call hands the agent full session context the
   moment they switch workspaces. Purely additive — older clients
   that ignore unknown keys keep working.

Plumbing

- New BootstrapFetcher interface + ExecBootstrapFetcher impl that
  shells out to `pad bootstrap --workspace <ws> --format json` with
  RootArgs (e.g. --url) preserved.
- RegistryOptions.BootstrapFetcher (optional) — cmd/pad/mcp.go wires
  ExecBootstrapFetcher; tests pass nil and get legacy shape.
- pad_meta.Schema.Workspace flipped to true so the workspace param is
  available to the bootstrap action. server-info / version /
  tool-surface ignore it as before.
- ToolSurfaceVersion bumped 0.2 → 0.3 with detailed changelog in the
  const doc-comment. Bumps are additive but rename pad_set_workspace's
  response shape, which is a breaking contract change for any client
  that asserts the exact key set.

Tests

- TestSetWorkspaceTool_EmbedsBootstrap, _BootstrapErrorFallsThrough,
  _EmptyWorkspaceSkipsBootstrap.
- TestPadMetaTool_NoWorkspaceInSchema rewritten as
  TestPadMetaTool_WorkspaceInSchema with reasoning.
- TestCatalogWorkspaceParamAdvertisedOnAllWorkspaceTools updated:
  pad_meta is no longer on the intentionallyServerWide list.

Parent: PLAN-1377.

* fix(mcp): wire bootstrap route into HTTP dispatcher (TASK-1380)

Codex round 1: pad_meta.action=bootstrap dispatched cmdPath
['bootstrap'] but the HTTP MCP dispatcher's routeTable had no entry,
so pad-cloud and other HTTP-transport clients hit the 'not yet
implemented over HTTP transport' fallback. Add a route mapping that
GETs /api/v1/workspaces/{workspace}/agent/bootstrap — the canonical
endpoint Server.handleGetBootstrap exposes. Local stdio MCP is
unaffected (it dispatches via ExecDispatcher, which shells out to
`pad bootstrap`).

Parent: PLAN-1377.
2026-05-12 18:09:11 -04:00
..