diff --git a/README.md b/README.md index 9902284..ea12adb 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ # 📦 devbox -### Your working tree, everywhere. Now with built-in Tailscale. 🔒 +### Your working tree, everywhere. Built-in Tailscale. Built-in MCP. 🔒 Continuous file sync for developers: private networking, selective mounts, -conflict copies, snapshot history, and a secret guard that keeps credentials home. +conflict copies, snapshot history, and structured tools for your AI coding agent. **Linux · macOS · Windows · Raspberry Pi** -[Install](#-install) · [Tailscale quick start](#-tailscale-quick-start) · [Commands](#-commands) · [Configuration](#-configuration) · [Build](#-build-and-release) +[Install](#-install) · [Tailscale quick start](#-tailscale-quick-start) · [Agent MCP](#-built-in-mcp-for-agents) · [Commands](#-commands) · [Configuration](#-configuration) · [Build](#-build-and-release) @@ -26,6 +26,10 @@ router port forwarding, or reverse proxy is required for this mode. devbox-hub serve --data ./hub-data --tailscale --tailscale-hostname devbox-hub ``` +![Built-in Tailscale flags captured from the devbox-hub CLI](docs/images/tailscale-help.png) + +*Actual CLI help, rendered for readability. The hub joins the tailnet itself.* + On first launch, open the authentication URL printed in the terminal. Once connected, the hub prints its private endpoint: @@ -44,6 +48,52 @@ uses the private URL through that connection. Embedded client networking is not included in this release. The embedded hub is a separate Tailscale device, even if its host machine already runs Tailscale. +## 🤖 Built-in MCP for agents + +**New in v2.2.0:** connect your coding agent directly to devbox with the built-in +Model Context Protocol server. It ships in the same client binary: + +```bash +codex mcp add devbox -- /absolute/path/to/devbox mcp +``` + +Or configure any agent that accepts `mcpServers` JSON: + +```json +{ + "mcpServers": { + "devbox": { + "command": "/absolute/path/to/devbox", + "args": ["mcp"] + } + } +} +``` + +![Actual MCP tool discovery and selected status fields from a live demo](docs/images/mcp-tools.png) + +*Captured from the built-in stdio server using an isolated enrolled device.* + +Ask your agent to check sync status, diagnose a failing mount, inspect history, +or list conflicts. Default tools inspect the existing enrolled device. +`--allow-writes` enables pause/resume, publish, and mount; +`--allow-writes --allow-destructive` additionally enables restore, deploy, and +unmount. Tools use the CLI's authentication and conflict behavior. + +**Tailscale connects your machines; MCP connects your agent.** The hub embeds +Tailscale, client machines use their regular Tailscale connection, and the MCP +server talks locally over stdio. No extra MCP service or Node runtime is needed. + +```mermaid +flowchart LR + Agent["AI coding agent"] -->|"local stdio"| MCP["devbox mcp"] + MCP --> Client["Enrolled devbox client"] + Client -->|"regular Tailscale app"| Hub["Hub with embedded Tailscale"] +``` + +Read the [MCP setup guide](docs/MCP.md) for tool names, configuration, execution +limits, and errors, or the [implementation plan](docs/MCP-PLAN.md) for scope. + ## ✨ Why devbox? Git records the work you choose to commit. devbox continuously mirrors the @@ -200,6 +250,7 @@ probes the host-network API, so it must be replaced for tailnet-only mode. | Client command | Purpose | |---|---| +| `devbox mcp` | Serve structured agent tools over local stdio | | `devbox setup` | Interactive first-run setup | | `devbox join ` | Enroll this device | | `devbox publish ` | Create a share and push its files | @@ -226,7 +277,10 @@ planned, so use a hub for a trusted group rather than mutually untrusted tenants ## 📊 Built-in dashboard -

devbox live sync dashboard

+

Live devbox dashboard showing three devices and three demo shares

+ +*Live hub dashboard with isolated demo data. The capture uses a local hub; it is +not evidence of production Tailscale enrollment.* ```bash devbox-hub serve --data ./hub-data --tailscale --dashboard @@ -288,7 +342,7 @@ pinned Tailscale dependency. Downloading prebuilt binaries needs no Go toolchain go build ./cmd/devbox ./cmd/devbox-hub go vet ./... go test -race ./... -VERSION=v2.1.0 ./scripts/build-release.sh +VERSION=v2.2.0 ./scripts/build-release.sh ``` The release script cross-compiles both binaries for six platform/architecture diff --git a/docs/MCP.md b/docs/MCP.md new file mode 100644 index 0000000..8fdba09 --- /dev/null +++ b/docs/MCP.md @@ -0,0 +1,135 @@ +# Use devbox from an AI agent + +`devbox mcp` runs a Model Context Protocol server over stdin/stdout, built into +the devbox client binary. It gives local agents structured access to the same +device, mounts, and hub that the CLI uses. No separate MCP package, Node runtime, +or additional network listener is required. + +![MCP tool discovery and selected status fields from an isolated demo](images/mcp-tools.png) + +## Connect your device first + +Enroll with `devbox setup` or `devbox join`, and configure mounts through the +CLI. Start the sync daemon separately with `devbox start`. The MCP process +inherits the launching user's config directory; `XDG_CONFIG_HOME` can select a +different one. It does not ask for a join token through a tool. + +For a Tailscale hub, connect the client machine's regular Tailscale app. Your +hub runs embedded Tailscale with `devbox-hub serve --tailscale`; MCP tools use the +private hub URL already stored by `devbox join`. MCP itself remains local stdio. + +## Add it to an agent + +Use the absolute path to the installed **file-sync devbox executable**. If you +also have a fleet administration command named `devbox`, do not point the agent +at that script. + +### Codex + +```bash +codex mcp add devbox -- /absolute/path/to/devbox mcp +``` + +For a separate devbox configuration: + +```bash +codex mcp add devbox --env XDG_CONFIG_HOME=/absolute/path/to/config-base -- /absolute/path/to/devbox mcp +``` + +Equivalent TOML: + +```toml +[mcp_servers.devbox] +command = "/absolute/path/to/devbox" +args = ["mcp"] +``` + +### Clients using `mcpServers` JSON + +```json +{ + "mcpServers": { + "devbox": { + "command": "/absolute/path/to/devbox", + "args": ["mcp"] + } + } +} +``` + +Use the MCP configuration location supported by your agent. On Windows, select +the absolute path to `devbox.exe`. Restart or reconnect the agent after adding +the server. + +## Available tools + +The default server exposes inspection tools only: + +| Tool | Purpose | +|---|---| +| `devbox_status` | Joined state, hub, configured mounts, and live daemon state when available | +| `devbox_doctor` | Structured configuration, hub, filesystem, and watcher diagnostics | +| `devbox_conflicts` | List conflict copies without deleting them | +| `devbox_history` | Bounded snapshot history for a share | +| `devbox_members` | Membership information for a share | + +To allow sync operations, set `args` to `["mcp", "--allow-writes"]`: + +| Additional tool | Purpose | +|---|---| +| `devbox_pause` | Pause the running sync daemon | +| `devbox_resume` | Resume the running sync daemon | +| `devbox_publish` | Create a share from a local directory and push its files | +| `devbox_mount` | Mount a share or subdirectory, optionally read-only | + +To also allow restore, deployment, and unmounting, use +`["mcp", "--allow-writes", "--allow-destructive"]`: + +| Additional tool | Purpose | +|---|---| +| `devbox_restore` | Restore a snapshot or selected path | +| `devbox_deploy` | Apply a snapshot and pin the local mount | +| `devbox_unmount` | Remove a mount from configuration | + +`devbox_mount` may merge local files, push changes, replace its mount config, +and clear a deployment pin. It is available with `--allow-writes` and advertises +`destructiveHint: true`; set `read_only: true` for a pull-only mount. Publish and +mount require an absolute `local_dir`; shell expansions such as `~` are not +performed. Snapshot IDs must be the full lowercase 64-character value from +history. + +Unavailable tools are omitted from discovery. `--allow-destructive` requires +`--allow-writes`. Tool descriptions and schemas specify the exact parameters. +Use tool discovery rather than guessing arguments. + +## Results and failures + +Tools return structured results with the underlying command's output. A failed +operation is marked as an MCP tool error, including failed doctor checks; an +agent should inspect the diagnostic result before taking another action. + +The command timeout defaults to `2m` and includes time waiting for another tool +call in this server. Set a positive `--command-timeout`, for example +`["mcp", "--command-timeout", "5m"]`, for large transfers. Captured stdout is +limited to 1 MiB and stderr to 64 KiB; `truncated` reports clipping. Results have +`stdout`, `stderr`, `exit_code`, `truncated`, optional parsed `data`, and optional +`error` fields. History accepts `limit` from 1 to 100 (default 20). + +Calls are serialized within one MCP server. Coordinate mount/config changes +across multiple agents or CLI processes. Cancellation stops +the child command. An interrupted write may have completed some work already; +inspect status and history before retrying. Existing lifecycle hooks and +conflict-preservation behavior apply exactly as they do through the CLI. + +MCP stdout contains protocol traffic only. Logs and startup errors go to stderr. +The server does not expose the stored bearer token, device private key, arbitrary +shell commands, or conflict-copy deletion as tools. + +## Useful agent requests + +- “Check whether this device is joined and whether its sync daemon is running.” +- “List conflicts and the latest snapshots for this share; don't change files.” +- “Diagnose why this mount isn't syncing and explain the failing checks.” +- With writes enabled: “Pause sync while I change dependencies, then resume it.” + +See the [implementation plan](MCP-PLAN.md) for the scope and acceptance checks. diff --git a/docs/images/README.md b/docs/images/README.md new file mode 100644 index 0000000..00c98bd --- /dev/null +++ b/docs/images/README.md @@ -0,0 +1,19 @@ +# Documentation screenshots + +These images show released CLI output and a running isolated demo. They do not +show production data, credentials, or production-tailnet enrollment. + +- `tailscale-help.png`: screenshot of an HTML terminal-style presentation of the + actual `devbox-hub serve --help | grep -- --tailscale` output. The presentation + adds a title/caption; the flag descriptions are captured from the binary. +- `mcp-tools.png`: screenshot of a terminal-style presentation of actual MCP + tool discovery and a `devbox_status` result from the built-in stdio server. + The server uses an isolated enrolled demo config. +- `dashboard.png`: browser screenshot of the live dashboard from a local hub + with three demo device identities and shares (`web-app`, `api-service`, and + `shared-tools`). Changes are sent through actual sync daemons. The dashboard + is separate from the API and is not itself published by `--tailscale`. + +The Tailscale client/server distinction remains the same in every capture: +the hub embeds tsnet, client machines use regular Tailscale, and MCP runs over +local stdin/stdout in the client binary. diff --git a/docs/images/dashboard.png b/docs/images/dashboard.png index 410d6a1..eca8b09 100644 Binary files a/docs/images/dashboard.png and b/docs/images/dashboard.png differ diff --git a/docs/images/mcp-tools.png b/docs/images/mcp-tools.png new file mode 100644 index 0000000..329a7ef Binary files /dev/null and b/docs/images/mcp-tools.png differ diff --git a/docs/images/tailscale-help.png b/docs/images/tailscale-help.png new file mode 100644 index 0000000..7a9d3c2 Binary files /dev/null and b/docs/images/tailscale-help.png differ diff --git a/docs/mcp-evaluation.xml b/docs/mcp-evaluation.xml new file mode 100644 index 0000000..1fa5b01 --- /dev/null +++ b/docs/mcp-evaluation.xml @@ -0,0 +1,45 @@ + + + + Discover the tools in default mode, inspect their annotations, and compare them with the guide. How many tools are available? + 5 + + + Discover tools in default mode and with --allow-writes. How many additional tools does the write flag enable? + 4 + + + Compare discovery in all three documented access modes. How many tools are available when both write and destructive flags are enabled? + 12 + + + Inspect the tools available with --allow-writes and the schemas described in the guide. Can an agent restore a snapshot in this mode without the destructive flag? + no + + + Use status on a fresh unjoined configuration, then inspect the setup guide. What CLI command can enroll the device interactively before MCP uses its hub connection? + devbox setup + + + Discover tools and inspect the schema for conflict inspection. Which tool lists conflict copies without deleting them? + devbox_conflicts + + + Compare the restore and deployment tool descriptions without calling either. Which one applies a snapshot and pins the local mount? + devbox_deploy + + + Use status on an enrolled fixture and compare it with the tool-discovery list. Which history tool can inspect the snapshots for one of its mounted shares without changing files? + devbox_history + + + Inspect the agent launch configuration and the Tailscale setup guide. Does devbox mcp require a remote HTTP MCP listener or communicate through local stdio? + local stdio + + + Compare the Tailscale client setup and MCP launch configuration. Which command starts the embedded Tailscale hub rather than the local agent MCP server? + devbox-hub serve --tailscale + + diff --git a/docs/releases/v2.2.0.md b/docs/releases/v2.2.0.md new file mode 100644 index 0000000..9c3d1d8 --- /dev/null +++ b/docs/releases/v2.2.0.md @@ -0,0 +1,59 @@ +# v2.2.0 — Built-in MCP + Tailscale + +Your working tree on every machine. Structured sync tools for your coding agent. + +## Tailscale is built into the hub + +```bash +devbox-hub serve --data ./hub-data --tailscale --tailscale-hostname devbox-hub +``` + +The hub joins your tailnet itself, without a separate Tailscale installation, +root privileges, TUN device, router port forwarding, or reverse proxy. Enroll +using the first-run login URL or a securely supplied `TS_AUTHKEY`; preserve +`/tailscale` across upgrades. Clients use the regular Tailscale app and +the private endpoint printed by the hub. Devbox join tokens remain required. + +![Actual Tailscale CLI options](https://raw.githubusercontent.com/shoemoney/devbox/main/docs/images/tailscale-help.png) + +## MCP is built into the client + +```bash +codex mcp add devbox -- /absolute/path/to/devbox mcp +``` + +The new `devbox mcp` command serves tools over local stdio. Inspect status, +diagnostics, conflicts, history, and memberships by default. Enable pause, +resume, publish, and mount with `--allow-writes`. Restore, deploy, and unmount +also require `--allow-destructive`. The server uses the enrolled device's +existing config and connection, including access to Tailscale hubs. + +![Actual MCP tool discovery and selected status fields](https://raw.githubusercontent.com/shoemoney/devbox/main/docs/images/mcp-tools.png) + +See the [MCP guide](https://github.com/shoemoney/devbox/blob/main/docs/MCP.md) +for configuration examples and tool details. No separate MCP package or Node +runtime is needed. Start the sync daemon separately with `devbox start`. + +## Install + +```bash +curl -fsSL https://git.shoemoney.ai/shoemoney/devbox-dist/releases/download/latest/install.sh | sh +``` + +For the hub too, download the installer and run `sh install.sh --hub --no-service`. +Both binaries ship for Linux amd64/arm64/arm, macOS amd64/arm64, and Windows amd64. +`SHA256SUMS` covers the 12 binaries and both installers. Public downloads are +available on GitHub and Forgejo. Source builds require Go 1.27.4+. + +## Validation + +Passed vet, 189 race tests across 19 packages, and real SDK stdio tests for +initialization, discovery, calls, permissions, authenticated hub operations, +input validation, cancellation, timeouts, and output caps. The embedded Tailscale +regression uses real nodes against an isolated local control/DERP plane; no +production-tailnet enrollment is claimed. + +![Live dashboard with isolated demo data](https://raw.githubusercontent.com/shoemoney/devbox/main/docs/images/dashboard.png) + +The dashboard capture uses a local demo hub and real sync daemons. It is not a +production-tailnet capture.