Repository navigation
MCP: confine file access with --automation-read-root and --automation-write-root - #247
Merged
Merged
Conversation
Member
|
Thank you for this contribution, @isaac-levine! It has landed on If you haven't already, please come join us on Discord: https://discord.gg/artcraft |
h-a-n-a-s-h-i
pushed a commit
that referenced
this pull request
Oct 14, 2026
design.browseTheme reads its path with io::read_file, and File › Info sizes the file with io::file_len (which checks the read root), so commands_do_not_touch_the_file_system_themselves passes. spell.rs is allow-listed beside recovery.rs: it touches only the app's own dictionary folders. main's render_slide MCP tool refuses a `path` argument (#371), so the root tests render to a file through call_app ui.render instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks done
uvxszi
added a commit
to uvxszi/deckcraft
that referenced
this pull request
Oct 14, 2026
Morph keeps both a re-cropped picture's crop and a 3-D model's turn. Save as Picture and a model's companion files go through `crate::io`, so the automation roots (storytold#247) confine them; the model tests, which write their own fixture files, are `tests_model3d.rs`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 15, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
deckcraft-cli mcpgives the agent on the other end the same file access as the user running it. VectorCraft already has two flags for this, so this adds the same ones here with the same names and behaviour, and one client config works across the apps. It is the same change as storytold/gridcraft#480 and storytold/wordcraft#798.How it works
The engine only ever opens a user-named file in three places:
file.open, the media read behindinsert.picture,insert.audio,insert.videoandpicture.change, and the writer behindfile.save,file.saveAsandfile.export. Those now go through two small helpers,io::read_fileandio::write_file, and the checks sit there. The newcrates/engine/src/file_access.rsholds the roots and the path logic: make the path absolute, follow symlinks (for a file that doesn't exist yet, resolve its nearest existing ancestor and require the rest to be plain names), then compare with the root by whole path components. On Windows the comparison ignores case, handles\\?\and UNC prefixes, and refuses device names likeCONandNUL. Refusals come back as ordinary tool errors with VectorCraft's wording, for exampleautomation path rejected: outside the read root /work/project: /etc/passwd.A test walks every file under
crates/engine/srcand fails if one other thanio.rs,file_access.rs,recovery.rsand the test files callsstd::fs,File::open,File::createorOpenOptions.Headless::with_automation_rootsin deckcraft-mcp puts the roots in force for every call. The CLI accepts--flag DIRor--flag=DIR, refuses a flag given twice, and refuses a root that is missing or not a folder. A root left out grants none of its access, so--automation-read-rootalone makes the server read-only. The flags only make sense for the in-process server, so combining them with--connectis an error.docs/mcp.mdgets a "Confining file access" section.What is covered
Reads:
open_presentation,file.open, andinsert_picture,insert.picture,picture.change,insert.audioandinsert.videowith apath. Writes:save_presentation,export(every format, and every slide of an image export),file.save,file.saveAs,file.export,render_slidewith apath, plus the.savingtemporary file a save goes through. Calls that return bytes instead of writing a path keep working with only a read root. Pictures, audio and video are copied into the deck when inserted, so playing them at show time reads nothing from disk and needs no check of its own.Not covered:
--sampleis the operator's own choice and is opened before the roots apply. The desktop app (deckcraft --control) doesn't take the flags yet, since VectorCraft's app-side version also has to leave the user's own file dialogs unconfined, which is a bigger change in ui-egui that I'd rather do separately, so the docs say a running app is not confined. Commands that take no path still read and change the open deck. The system font scan and the app's recovery folder are fixed paths set by the host, not agent input, and are not checked. Like VectorCraft, this is check-then-open, so it keeps an agent inside the folders it was given rather than defending against other programs racing it.The
--connecterror says to drop--connectinstead of pointing at app-side flags like VectorCraft's does, since DeckCraft's app has none, matching the GridCraft wording.This does not touch
edit.rsorui-egui, so it should merge independently of #191. It also doesn't depend on #177, but if the GIF export lands first its writer needs to useio::write_file(the guard test will say so).Testing
Unit tests on the path logic (inside/outside,
.., same-prefix sibling, symlinks out via a temp dir, each root left out, both roots the same folder) and on the flag parsing.crates/mcp/tests/automation_roots.rsgoes through the MCP protocol and checks that opening or inserting from outside the read root is refused and nothing from the file reaches the deck, that every saving command is refused outside the write root and no file appears, the one-root configurations, links out being refused, and that no roots means no confinement.apps/deckcraft-cli/tests/cli.rsruns the real binary with both flag spellings and each argument error.All pass.
cargo xtask cipassed all six steps (fmt, clippy, test, assets, layers, wasm) before the last change, which only widened the guard test and edited one docs sentence, after which I reran the commands above. Windows paths weren't exercised, I only have a Mac.