PhotoCraft: An open-source, photo editor written by scratch in pure Rust
docs(mcp): grant scoped file roots in headless registration examples (#1673)
Nigel Ihza Firdausy351736ef6b0d
diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 593db12b8..366a3f1cf 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -248,8 +248,11 @@ lines are visible. The protocol is unencrypted and must remain on loopback; do nit to an untrusted host.Filesystem access fails closed unless launch-time read and/or write roots are granted with-`--automation-read-root` and `--automation-write-root` (or-`PHOTOCRAFT_AUTOMATION_READ_ROOT` / `PHOTOCRAFT_AUTOMATION_WRITE_ROOT`). Request paths must be+`--automation-read-root` and `--automation-write-root`. The environment-variable equivalents+(`PHOTOCRAFT_AUTOMATION_READ_ROOT` / `PHOTOCRAFT_AUTOMATION_WRITE_ROOT`) are supported by+the desktop `photocraft` process, but not by headless `photocraft-cli mcp` or `serve`;+for those CLI modes, supply the flags explicitly. In MCP bridge mode, configure roots on the+desktop process rather than on the bridging CLI. Request paths must benon-empty, forward-slash relative paths beneath the applicable root. Absolute paths, parenttraversal, alternate separators, drive/device/stream prefixes, malformed components, and linkescapes are rejected before file effects. Read and write authority are independent; the parent ofdiff --git a/docs/development.md b/docs/development.mdindex 64bff7768..06bc0fff8 100644--- a/docs/development.md+++ b/docs/development.md@@ -65,8 +65,8 @@ By default PhotoCraft's own crates log at `info` and everything else at `warn`.| `RUST_LOG` | Log levels for standard error and the log file (see [Logs](#logs)) || `PHOTOCRAFT_CONTROL_TOKEN` | 64-hex bearer token for control TCP (avoid on shared systems where environment inspection is possible) || `PHOTOCRAFT_CONTROL_TOKEN_FILE` | Read, or create for a server, the control bearer-token file |-| `PHOTOCRAFT_AUTOMATION_READ_ROOT` | Directory capability for automation reads; requests use relative paths |-| `PHOTOCRAFT_AUTOMATION_WRITE_ROOT` | Separate directory capability for automation writes; requests use relative paths |+| `PHOTOCRAFT_AUTOMATION_READ_ROOT` | Desktop app only: automation read root. Headless CLI modes require the `--automation-read-root` flag |+| `PHOTOCRAFT_AUTOMATION_WRITE_ROOT` | Desktop app only: automation write root. Headless CLI modes require the `--automation-write-root` flag || `PHOTOCRAFT_CPU_CANVAS=1` | Force the CPU canvas path instead of the wgpu shader canvas || `PHOTOCRAFT_NATIVE_WAYLAND=1` | Linux: stay on native Wayland when a pen is attached (by default the window then opens through Xwayland, because Wayland gives the app no pen input; #639) || `WGPU_BACKEND=dx12` | Pick the wgpu backend(s) (`vulkan`, `dx12`, `metal`, `gl`); overrides `performance.gpuBackend` and the startup fallback |@@ -138,6 +138,8 @@ Keep one `PcraftWriter` per open document: re-saving then only compresses and wr- **Headless:** `photocraft-cli mcp --automation-read-root <dir> --automation-write-root <dir>`. It drives an in-process engine session and has no file authority when a root is omitted.- **Live app:** start `photocraft --control 7878 --control-token-file <private-path> --automation-read-root <dir> --automation-write-root <dir>`, then run `photocraft-cli mcp --bridge 127.0.0.1:7878 --control-token-file <private-path>`. The desktop process owns the roots. See `docs/control-protocol.md#mcp-bridge`.+For headless MCP clients, pass absolute paths to deliberately chosen trusted workspace directories in the launch arguments. Desktop `PHOTOCRAFT_AUTOMATION_READ_ROOT` and `PHOTOCRAFT_AUTOMATION_WRITE_ROOT` environment variables do **not** grant headless CLI access. Omitting a root flag deliberately denies that direction of access.+Tools:- `session_list`@@ -153,7 +155,7 @@ Claude Code (`.mcp.json` in the repo root, or `claude mcp add`):"mcpServers": {"photocraft": {"command": "/path/to/photocraft/target/release/photocraft-cli",- "args": ["mcp"]+ "args": ["mcp", "--automation-read-root", "/absolute/path/to/trusted/workspace", "--automation-write-root", "/absolute/path/to/trusted/workspace"]},"photocraft-live": {"command": "/path/to/photocraft/target/release/photocraft-cli",@@ -165,7 +167,10 @@ Claude Code (`.mcp.json` in the repo root, or `claude mcp add`):```shcargo build --release -p photocraft-cli-claude mcp add photocraft -- "$PWD/target/release/photocraft-cli" mcp+mkdir -p "$PWD/photocraft-work"+claude mcp add photocraft -- "$PWD/target/release/photocraft-cli" mcp \+ --automation-read-root "$PWD/photocraft-work" \+ --automation-write-root "$PWD/photocraft-work"````doc_inspect` (and the engine command `document.inspect`) reports the layer tree with kinds,@@ -178,7 +183,7 @@ capability-scoped export, resize/crop, CMYK + native save) driven purely over MCWithout MCP, `photocraft-cli serve [--port N]` keeps a headless session open and answers JSON lines(see `docs/control-protocol.md#headless-server`).-A typical agent loop:+A typical agent loop (place inputs under the configured read root and outputs under the write root):1. `doc_open {path}`2. `command_list {filter:"blur"}`