61 lines
3.2 KiB
Markdown
61 lines
3.2 KiB
Markdown
# Built-in MCP for devbox
|
|
|
|
## Goal
|
|
|
|
Ship `devbox mcp`: an MCP server over stdin/stdout, inside the existing client
|
|
binary. Agents can inspect an enrolled device and opt into sync operations.
|
|
The existing hub, authentication, Tailscale networking, and conflict handling
|
|
remain the source of behavior. No additional network listener is needed.
|
|
|
|
## Tool surface
|
|
|
|
| Access | Tools | CLI behavior reused |
|
|
|---|---|---|
|
|
| Default | `devbox_status`, `devbox_doctor`, `devbox_conflicts`, `devbox_history`, `devbox_members` | status, doctor, conflicts, log, members |
|
|
| `--allow-writes` | `devbox_pause`, `devbox_resume`, `devbox_publish`, `devbox_mount` | pause, resume, publish, mount |
|
|
| `--allow-writes --allow-destructive` | `devbox_restore`, `devbox_deploy`, `devbox_unmount` | restore, deploy, unmount |
|
|
|
|
Default operation is inspection only. Tool annotations describe read-only,
|
|
destructive, idempotent, and open-world behavior accurately. Tools unavailable
|
|
in the selected mode are not advertised and cannot be invoked.
|
|
|
|
## Implementation
|
|
|
|
Use the official Go MCP SDK with its stdio transport. Reuse the existing CLI
|
|
commands through the current executable with explicit argument arrays, never a
|
|
shell or an arbitrary command tool. This shares behavior and avoids coupling MCP
|
|
handlers to private command implementations. Pass user arguments after an
|
|
explicit option terminator where appropriate; validate inputs before execution.
|
|
|
|
Only MCP protocol messages go to stdout. Tool results contain structured data
|
|
where existing commands provide JSON, plus a readable representation. Command
|
|
errors remain tool errors and preserve useful diagnostic data. Never return the
|
|
stored bearer token, device private key, or full config files.
|
|
|
|
Bound command duration and captured output. History responses support a limit.
|
|
Cancellation terminates the child operation. Side effects already completed by
|
|
a cancelled command are not automatically retried.
|
|
|
|
## Agent configuration
|
|
|
|
Document a portable `mcpServers.devbox` entry using an absolute executable path
|
|
and `args: ["mcp"]`, plus opt-in write and destructive configurations. The MCP
|
|
process uses the same user/config directory as `devbox setup` or `devbox join`.
|
|
Start the sync daemon separately with `devbox start`.
|
|
|
|
## Acceptance
|
|
|
|
1. A real SDK client initializes the server, lists tools, and calls status over
|
|
stdio. Stdout stays valid MCP traffic, including on errors.
|
|
2. Inspection works with an empty/unjoined isolated config and reports that
|
|
state without fabricating a connection.
|
|
3. Default mode excludes mutating tools; explicit flags expose the documented
|
|
sets. Invalid arguments cannot inject options or shell commands.
|
|
4. An isolated actual hub verifies history and authenticated operations through
|
|
MCP. Failed diagnostics return structured details and an error signal.
|
|
5. Command cancellation and output bounds are exercised with meaningful tests.
|
|
6. Vet, the race suite, platform builds, and packaged-binary MCP smoke checks pass
|
|
on a build worker. Public installation from the new release works.
|
|
7. README and release notes lead with built-in Tailscale and MCP, include real
|
|
screenshots, explain hub/client scope, and distinguish demo captures from
|
|
production enrollment evidence.
|