MCP save: a folder the agent opened or saved a design in stays in scope (#7181) (#7216)

* claim: #7181

* MCP save: a folder the agent opened or saved a design in stays in scope (#7181)

The agent's default folders held the open design's folder only while that
design stayed open there, so after a new design, an opened STEP file or a
save-as elsewhere a save beside the earlier design was refused, while the
same save through the control port worked.

The MCP server now keeps, for the rest of its run, the folder of every
design file a call opened or saved (open, save, and doc.open, file.save,
file.save_as through execute or batch, path given in full) and, headless,
of every design open in its session. Such a call only succeeded because the
folder was already in scope, so naming a path adds nothing. The folders get
the open design folder's terms (inside home or temp, not hidden, hidden
entries unreachable), at most 16. Bridged, they go to the app as
design_folders, which it judges the same way.

The save tool description and docs/mcp.md say how to add a folder with
--allow-path.

* MCP scope: a design's folder is the folder its file resolves to (#7181)

A link in another folder to a design inside the agent's folders passes the
scope check, which follows it, but its own folder was what got remembered
(and, for the open design, what counted while it was open). Take the folder
of the file as the check resolves it.

* Control test: a hidden file the export format accepts (#7181)

---------

Co-authored-by: MateuszSychXpl <151755914+MateuszSychXpl@users.noreply.github.com>
This commit is contained in:
Mateusz SychandMateuszSychXpl authored and GitHub committed 2026-10-28 12:22:20 +00:00
1 parent 387e86729c
commit e181015fd1
10 files changed
+286 -25

No files matched your search

+1 -1
View File
@@ -653,7 +653,7 @@ fn cmd_mcp(args: &[String]) -> Result<(), String> {
if let Some(s) = &scope {
let roots: Vec<String> = s.roots().iter().map(|r| r.display().to_string()).collect();
eprintln!(
"solidcraft mcp: files limited to {} and the open design's folder (--allow-path DIR adds one, --allow-any-path lifts the limit)",
"solidcraft mcp: files limited to {} and the folders of designs opened or saved here (--allow-path DIR adds one, --allow-any-path lifts the limit)",
roots.join(", ")
);
let design_dir = flag(args, "--in")
+71 -11
View File
@@ -141,15 +141,18 @@ pub use imp::*;
/// refuses paths outside it; without one (the user's own file dialogs, the CLI) nothing changes.
///
/// Two kinds of folder: those named on purpose (`--allow-path`, the app's own recovery folder),
/// where everything is reachable, and the open design's folder, which counts only when
/// [`design_folder_refusal`] has nothing against it and never reaches hidden files or folders
/// (`.env`, `.git`) inside it.
/// where everything is reachable, and design folders (the open design's, and those an agent
/// opened or saved a design in, #7181), which count only when [`design_folder_refusal`] has
/// nothing against them and never reach hidden files or folders (`.env`, `.git`) inside them.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct PathScope {
roots: Vec<std::path::PathBuf>,
design_roots: Vec<std::path::PathBuf>,
}
/// At most this many design folders in a scope; the oldest gives way.
pub const MAX_DESIGN_FOLDERS: usize = 16;
thread_local! {
static SCOPE: std::cell::RefCell<Option<PathScope>> = const { std::cell::RefCell::new(None) };
}
@@ -216,15 +219,44 @@ impl PathScope {
}
/// Also the folder of the design at `path` (the open design), when
/// [`design_folder_refusal`] allows it; hidden entries inside it stay out of reach.
pub fn with_design(mut self, path: Option<&str>) -> PathScope {
let dir = path
.map(std::path::Path::new)
.and_then(std::path::Path::parent)
.map(|d| if d.as_os_str().is_empty() { std::path::Path::new(".") } else { d });
if let Some(d) = dir.filter(|d| design_folder_refusal(d).is_none()).and_then(canonical)
/// [`design_folder_refusal`] allows it; hidden entries inside it stay out of reach. It is the
/// folder of the file as [`PathScope::check`] resolves it: a link to a design elsewhere puts
/// the folder it leads to in reach, never the folder the link lies in.
pub fn with_design(self, path: Option<&str>) -> PathScope {
let file = path.and_then(|p| resolve(std::path::Path::new(p)).ok());
match file.as_deref().and_then(std::path::Path::parent) {
Some(d) => self.with_design_root(d),
None => self,
}
}
/// Also the folder of `path`, a design file an agent opened or saved (#7181), on the same
/// terms as the open design's. On Windows its text is judged first, as [`PathScope::check`]
/// judges a path: resolving a UNC path would already make Windows connect out.
pub fn with_design_file(self, path: &str) -> PathScope {
if cfg!(windows) && windows_refusal(path).is_some() {
return self;
}
self.with_design(Some(path))
}
/// Also `dir`, a folder an agent opened or saved a design in (a request's `design_folders`),
/// on the same terms as the open design's folder, its text judged first on Windows.
pub fn with_design_folder(self, dir: &std::path::Path) -> PathScope {
if cfg!(windows) && windows_refusal(&dir.to_string_lossy()).is_some() {
return self;
}
self.with_design_root(dir)
}
fn with_design_root(mut self, dir: &std::path::Path) -> PathScope {
if design_folder_refusal(dir).is_none()
&& let Some(d) = canonical(dir)
&& !self.design_roots.contains(&d)
{
if self.design_roots.len() >= MAX_DESIGN_FOLDERS {
self.design_roots.remove(0);
}
self.design_roots.push(d);
}
self
@@ -235,7 +267,7 @@ impl PathScope {
&self.roots
}
/// The open design's folder, when it counts.
/// The design folders that count.
pub fn design_roots(&self) -> &[std::path::PathBuf] {
&self.design_roots
}
@@ -962,6 +994,34 @@ mod tests {
let _ = std::fs::remove_dir_all(&base);
}
/// Folders an agent opened or saved a design in (#7181) count as the open design's folder
/// does, hidden ones never, and a scope keeps at most `MAX_DESIGN_FOLDERS`: the oldest gives
/// way.
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn a_scope_keeps_the_latest_design_folders() {
use super::{MAX_DESIGN_FOLDERS, PathScope};
let base = super::temp_dir().join(format!("solidcraft-vfs-design-folders-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&base);
let dirs: Vec<_> = (0..=MAX_DESIGN_FOLDERS).map(|i| base.join(format!("d{i}"))).collect();
for d in dirs.iter().chain([&base.join(".hidden")]) {
std::fs::create_dir_all(d).unwrap();
}
let scope = dirs
.iter()
.fold(PathScope::new([]), |s, d| s.with_design_folder(d))
.with_design_folder(&dirs[1])
.with_design_folder(&base.join(".hidden"));
let canon = |d: &std::path::Path| std::fs::canonicalize(d).unwrap();
assert_eq!(scope.design_roots().len(), MAX_DESIGN_FOLDERS, "{scope:?}");
assert_eq!(scope.design_roots().last(), Some(&canon(&dirs[MAX_DESIGN_FOLDERS])), "{scope:?}");
let file = |d: &std::path::Path| d.join("part.solidcraft").to_string_lossy().to_string();
assert!(scope.check(&file(&dirs[1])).is_ok());
assert!(scope.check(&file(&dirs[0])).is_err(), "the oldest gave way");
assert!(scope.check(&file(&base.join(".hidden"))).is_err(), "a hidden folder never counts");
let _ = std::fs::remove_dir_all(&base);
}
/// A save follows a symbolic link to the file it points to (#845), so the link's target is
/// what a scope judges: a link inside an allowed folder that leads out is refused, a chain of
/// links that stays inside is fine.
+4
View File
@@ -273,6 +273,10 @@ impl Remote {
// The app confines the files this request reaches to the agent's folders (control.rs).
if let (Some(scope), Some(o)) = (solidcraft_engine::io::vfs::current_scope(), params.as_object_mut()) {
o.insert("allow_paths".into(), json!(scope.roots().iter().map(|r| r.to_string_lossy()).collect::<Vec<_>>()));
// And the folders it opened or saved a design in, which count as its open design's.
if !scope.design_roots().is_empty() {
o.insert("design_folders".into(), json!(scope.design_roots().iter().map(|r| r.to_string_lossy()).collect::<Vec<_>>()));
}
}
let mut msg = json!({"id": id, "method": method, "params": params});
// The token goes with every request (an app restarted mid-session has a new one).
+2 -1
View File
@@ -25,7 +25,8 @@ use solidcraft_engine::io::vfs::{self, PathScope};
/// The folders `solidcraft-cli mcp` lets its agent read, write and delete in by default: the
/// app's own recovery folder, this server's private scratch folder (screenshots), and each
/// `allowed` folder (`--allow-path`). The open design's folder joins on every call when it is a
/// safe one (`vfs::design_folder_refusal`; the server adds it). The working folder, the home
/// safe one (`vfs::design_folder_refusal`; the server adds it), and stays for the rest of the run
/// like the folder of every design a call opens or saves (#7181). The working folder, the home
/// folder and anything above it never count by themselves, so `~/.ssh`, `~/.bashrc` and other
/// dotfiles are out of reach unless a folder holding them is allowed on purpose.
pub fn agent_scope(allowed: impl IntoIterator<Item = PathBuf>) -> PathScope {
+36 -2
View File
@@ -43,6 +43,29 @@ pub struct Server {
scope: Option<PathScope>,
}
/// The design files a call opens or saves (#7181): `open` and `save`, and the commands they run
/// (`doc.open`, `file.save`, `file.save_as`) through `execute` or as `batch` steps. Each reads or
/// writes the file it names through the agent's scope.
fn design_files(name: &str, args: &Value) -> Vec<String> {
let step = |command: &str, params: &Value| {
let params = match command {
"open" | "save" | "doc.open" | "file.save" | "file.save_as" => params,
"execute" if matches!(params["command"].as_str(), Some("doc.open" | "file.save" | "file.save_as")) => &params["params"],
_ => return None,
};
params["path"].as_str().map(str::to_owned)
};
match name {
"batch" => args["commands"]
.as_array()
.into_iter()
.flatten()
.filter_map(|s| step(s["command"].as_str().or_else(|| s["id"].as_str())?, &s["params"]))
.collect(),
_ => step(name, args).into_iter().collect(),
}
}
fn response(id: Value, result: Value) -> Value {
json!({"jsonrpc": "2.0", "id": id, "result": result})
}
@@ -185,10 +208,21 @@ impl Server {
Some(a) => a.clone(),
};
check_arguments(name, &args).map_err(|e| (INVALID_PARAMS, e))?;
// The open design's folder counts as it is now (a save-as or open moves it).
let scope = self.scope.clone().map(|s| s.with_design(self.backend.design_path().as_deref()));
// The open design's folder counts, and goes on counting for the rest of this run
// when a save-as or open moves the design elsewhere (#7181).
let open = self.backend.design_path();
self.scope = self.scope.take().map(|s| s.with_design(open.as_deref()));
let scope = self.scope.clone();
let backend = self.backend.as_mut();
let mut result = vfs::scoped(scope, || call_tool(backend, name, &args));
// So does the folder of each design file the call opened or saved: the call reached
// it, so it was one of the agent's folders already. Only paths given in full: a
// running app resolves a relative one against its own working folder.
if result["isError"] != true {
for file in design_files(name, &args).iter().filter(|f| std::path::Path::new(f).is_absolute()) {
self.scope = self.scope.take().map(|s| s.with_design_file(file));
}
}
if let Some(note) = backend.notice()
&& let Some(content) = result.get_mut("content").and_then(Value::as_array_mut)
{
+90
View File
@@ -897,6 +897,59 @@ fn the_default_folders_are_the_designs_the_recovery_folder_and_the_scratch_folde
let _ = std::fs::remove_dir_all(&base);
}
/// #7181: the folder the agent opened or saved a design in stays one of its folders when the
/// design moves on (a new design, a STEP file opened from there, a save-as into a subfolder), so
/// a later `save` beside it works. Its hidden files and the folders beside it stay out of reach,
/// and a refused call adds nothing.
#[test]
fn a_folder_the_agent_saved_a_design_in_stays_its_folder() {
use solidcraft_engine::io::vfs::PathScope;
let base = solidcraft_engine::io::vfs::temp_dir().join(format!("solidcraft-mcp-remembered-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&base);
let (proj, other) = (base.join("proj"), base.join("other"));
std::fs::create_dir_all(proj.join("sub")).unwrap();
std::fs::create_dir_all(&other).unwrap();
let at = |d: &std::path::Path, f: &str| d.join(f).to_string_lossy().to_string();
let mut session = solidcraft_engine::Session::default();
session.execute("solid.box", &json!({"length": 10, "width": 10, "height": 10})).unwrap();
session.execute("file.save_as", &json!({"path": at(&proj, "part.solidcraft")})).unwrap();
let mut s = Server::new(Box::new(Headless::new(session))).with_path_scope(Some(PathScope::new([])));
tool(&mut s, "export", json!({"path": at(&proj, "part.step")}));
tool(&mut s, "new_design", json!({}));
tool(&mut s, "execute", json!({"command": "solid.box", "params": {"length": 5, "width": 5, "height": 5}}));
tool(&mut s, "save", json!({"path": at(&proj, "part-2.solidcraft")}));
// A STEP file opens as a new, unsaved design; it saves beside its file.
tool(&mut s, "open", json!({"path": at(&proj, "part.step")}));
tool(&mut s, "save", json!({"path": at(&proj, "part-3.solidcraft")}));
// A save-as into a subfolder moves the design there; the folder above goes on counting.
tool(&mut s, "execute", json!({"command": "file.save_as", "params": {"path": at(&proj.join("sub"), "part-4.solidcraft")}}));
tool(&mut s, "save", json!({"path": at(&proj, "part-5.solidcraft")}));
for f in ["part-2", "part-3", "sub/part-4", "part-5"] {
assert!(proj.join(format!("{f}.solidcraft")).exists(), "{f}");
}
// Twice: the first refusal must not have added anything.
for _ in 0..2 {
let r = raw_tool(&mut s, "export", json!({"path": at(&proj, ".env")}));
assert_eq!(r["result"]["isError"], json!(true), "{r}");
let r = raw_tool(&mut s, "save", json!({"path": at(&other, "x.solidcraft")}));
assert!(r.to_string().contains("outside the folders this agent may use"), "{r}");
}
assert!(!proj.join(".env").exists());
assert_eq!(std::fs::read_dir(&other).unwrap().count(), 0);
// A link beside it to a design here counts where it leads, never where it lies.
#[cfg(unix)]
{
std::os::unix::fs::symlink(proj.join("part.step"), other.join("link.step")).unwrap();
std::os::unix::fs::symlink(proj.join("part.solidcraft"), other.join("link.solidcraft")).unwrap();
tool(&mut s, "open", json!({"path": at(&other, "link.step")}));
tool(&mut s, "open", json!({"path": at(&other, "link.solidcraft")}));
let r = raw_tool(&mut s, "save", json!({"path": at(&other, "x.solidcraft")}));
assert!(r.to_string().contains("outside the folders this agent may use"), "{r}");
assert!(!other.join("x.solidcraft").exists());
}
let _ = std::fs::remove_dir_all(&base);
}
/// Tool calls reach files only inside the server's folders (#205): the usual workflow (save,
/// export, open, screenshots) works there; a path outside, directly, through `..` or through a
/// symlink that leads out, is refused with a clear error and nothing is written.
@@ -1041,6 +1094,43 @@ fn a_bridged_request_carries_the_agents_folders() {
echo.join().unwrap();
}
/// #7181, bridged: once the agent has saved a design through the app, that file's folder goes
/// with every later request as `design_folders`, so the app counts it after the design moves on.
/// Not before the save succeeded, not for one the app refused, not for a relative path (the app
/// resolves those against its own working folder).
#[test]
fn a_bridged_server_sends_the_folders_the_agent_saved_designs_in() {
use solidcraft_engine::io::vfs::PathScope;
let base = solidcraft_engine::io::vfs::temp_dir().join(format!("solidcraft-mcp-bridged-folders-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&base);
let (proj, other) = (base.join("proj"), base.join("other"));
std::fs::create_dir_all(&proj).unwrap();
std::fs::create_dir_all(&other).unwrap();
let at = |d: &std::path::Path, f: &str| d.join(f).to_string_lossy().to_string();
let sent = std::sync::Arc::new(std::sync::Mutex::new(Vec::<Value>::new()));
let (log, refused) = (sent.clone(), at(&other, "x.solidcraft"));
let (addr, _) = scripted_app(move |req| {
if req["method"] == "engine.execute" {
log.lock().unwrap().push(req["params"]["design_folders"].clone());
}
if req["params"]["params"]["path"] == refused.as_str() {
json!({"ok": false, "error": "outside the folders this agent may use"})
} else {
json!({"ok": true, "result": {}})
}
});
let remote = crate::Remote::connect_with_token(&addr, Some("0123456789abcdef0123456789abcdef")).unwrap();
let mut s = Server::new(Box::new(remote)).with_path_scope(Some(PathScope::new([])));
let r = raw_tool(&mut s, "save", json!({"path": at(&other, "x.solidcraft")}));
assert_eq!(r["result"]["isError"], json!(true), "{r}");
tool(&mut s, "save", json!({"path": "relative/y.solidcraft"}));
tool(&mut s, "save", json!({"path": at(&proj, "a.solidcraft")}));
tool(&mut s, "new_design", json!({}));
let proj = std::fs::canonicalize(&proj).unwrap();
assert_eq!(*sent.lock().unwrap(), [Value::Null, Value::Null, Value::Null, json!([proj.to_string_lossy()])]);
let _ = std::fs::remove_dir_all(&base);
}
/// #528: an agent saves the angle of a product photo as a named view once, then renders the
/// model from that view after each change. The render must use the saved camera, not a
/// standard view.
+4 -1
View File
@@ -316,7 +316,10 @@ pub fn tool_definitions() -> Vec<Value> {
tool(
"save",
"Save the design",
"Save the design to `path` or its current file (a design opened as .solidcraft keeps that name). New designs are .sc files. The default is a design container; a .json path selects plain JSON. Set format to container or json to override the path.",
"Save the design to `path` or its current file (a design opened as .solidcraft keeps that name). New designs are .sc files. The default is a design container; a .json path selects plain JSON. Set format to container or json to override the path. \
By default the path must lie in one of the agent's folders: the folder of a design opened or saved in this session (not its hidden files), \
SolidCraft's recovery folder, or a folder this server was started with `--allow-path DIR`. For a folder outside them, ask the user \
to add `--allow-path` and that folder to this server's arguments in their MCP client configuration.",
obj(
json!({"path": string("Path to save to, e.g. part.sc (default: the current file)"), "format": {"type": "string", "enum": ["container", "json"], "description": "Design encoding (default: JSON for .json, container otherwise)"}}),
&[],
+53 -2
View File
@@ -366,12 +366,21 @@ fn with_timings(mut reply: Value, timed: bool, rows: Vec<Value>, total_ms: f64)
/// file the request reaches must lie inside them (docs/mcp.md). `None`: it names none.
pub fn request_scope(app: &SolveApp, params: &Value) -> Result<Option<vfs::PathScope>, String> {
let Some(allowed) = params.get("allow_paths") else { return Ok(None) };
let Some(roots) = allowed.as_array().and_then(|a| a.iter().map(|r| r.as_str().map(std::path::PathBuf::from)).collect::<Option<Vec<_>>>()) else {
let folders = |v: &Value| v.as_array().and_then(|a| a.iter().map(|r| r.as_str().map(std::path::PathBuf::from)).collect::<Option<Vec<_>>>());
let Some(roots) = folders(allowed) else {
return Err("`allow_paths` must be a list of folders".into());
};
// The folders the agent opened or saved a design in (#7181), judged as the open design's is.
let designs = match params.get("design_folders") {
None => Vec::new(),
Some(v) => folders(v)
.filter(|d| d.len() <= vfs::MAX_DESIGN_FOLDERS)
.ok_or_else(|| format!("`design_folders` must be a list of at most {} folders", vfs::MAX_DESIGN_FOLDERS))?,
};
// Plus the app's own recovery folder and, when it is a safe one, the open design's folder.
let roots = roots.into_iter().chain(solidcraft_engine::recovery::default_dir());
Ok(Some(vfs::PathScope::new(roots).with_design(app.session.path.as_deref())))
let scope = designs.iter().fold(vfs::PathScope::new(roots), |s, d| s.with_design_folder(d));
Ok(Some(scope.with_design(app.session.path.as_deref())))
}
/// What a picture of the view shows: the model as the window shows it (theme and colour vision
@@ -420,6 +429,7 @@ pub fn handle(app: &mut SolveApp, ctx: &egui::Context, req: &ControlRequest) ->
let mut p = req.params.clone();
if let Some(o) = p.as_object_mut() {
o.remove("allow_paths");
o.remove("design_folders");
}
vfs::scoped(Some(scope), || dispatch(app, ctx, &req.method, &p))
}
@@ -1916,6 +1926,47 @@ mod tests {
assert!(path.is_file());
}
/// A request's `design_folders` (where its MCP agent opened or saved a design, #7181) count
/// as the open design's folder does: their files are reachable, their hidden files and the
/// folders beside them are not, and a list that is not one of at most
/// `vfs::MAX_DESIGN_FOLDERS` folders is refused.
#[test]
fn a_requests_design_folders_count_as_the_open_designs() {
let mut s = Session::default();
s.execute("solid.box", &json!({"length": 10, "width": 10, "height": 10})).unwrap();
let mut app = SolveApp::new(s, Services::default());
let base = vfs::temp_dir().join(format!("solidcraft-control-design-folders-{}", std::process::id()));
let (root, proj, out) = (base.join("root"), base.join("proj"), base.join("out"));
for d in [&root, &proj.join(".git"), &out] {
std::fs::create_dir_all(d).unwrap();
}
let at = |d: &std::path::Path, f: &str| d.join(f).to_string_lossy().to_string();
let mut call = |path: String, designs: Value| {
let params =
json!({"command": "file.export", "params": {"path": path}, "allow_paths": [root.to_string_lossy()], "design_folders": designs});
let (req, _rx) = ControlRequest::new("engine.execute", params);
match handle(&mut app, &crate::fonts::test_context(), &req) {
Outcome::Done(v) => v,
Outcome::Screenshot { path } => json!({"ok": true, "screenshot": path}),
}
};
let designs = json!([proj.to_string_lossy()]);
assert_eq!(call(at(&proj, "a.step"), designs.clone())["ok"], true);
for p in [at(&proj, ".secret.step"), at(&proj, ".git/a.step"), at(&out, "a.step")] {
let v = call(p.clone(), designs.clone());
assert!(v["ok"] == false && v.to_string().contains("outside the folders this agent may use"), "{p}: {v}");
}
assert!(!proj.join(".secret.step").exists() && !proj.join(".git/a.step").exists());
assert_eq!(std::fs::read_dir(&out).unwrap().count(), 0, "nothing written beside it");
let too_many = json!(vec![proj.to_string_lossy(); vfs::MAX_DESIGN_FOLDERS + 1]);
for bad in [json!(proj.to_string_lossy()), json!([1]), too_many] {
let v = call(at(&proj, "b.step"), bad);
assert!(v["error"].as_str().is_some_and(|e| e.contains("design_folders")), "{v}");
}
assert!(!proj.join("b.step").exists());
let _ = std::fs::remove_dir_all(&base);
}
/// `ui.camera` reads the camera and sets it; its reply, passed back, sets the same view
/// again. Fields left out keep their values, `fit` frames occurrences, and a refused field
/// changes nothing.
+3 -1
View File
@@ -124,7 +124,9 @@ reads, writes or deletes (command paths such as `file.export`'s `path` or `doc.r
`dir`, `ui.render`, `ui.screenshot`) must then lie inside one of those folders after `..` and
symlinks are resolved, or the request fails with `… outside the folders this agent may use …`.
The app adds its own recovery folder and, when it lies safely inside the home folder and not in
a hidden folder, the open design's folder (whose hidden files stay out of reach). The bridged
a hidden folder, the open design's folder (whose hidden files stay out of reach). With
`allow_paths`, `design_folders: ["/abs/folder", …]` (at most 16) names folders the agent opened
or saved a design in; each counts on the open design folder's terms. The bridged
MCP server sends its folders this way on every request ([mcp.md](mcp.md)). Without
`allow_paths` file paths are not limited: a client holding the token can do what the user can.
+22 -6
View File
@@ -77,11 +77,19 @@ design is left as it was. Calls bridged to the app are not checked yet.
Tool calls read, write and delete files only inside the server's folders:
- the folder of the open design (the `--in` design, or whatever the agent last opened or saved),
but only when it lies strictly inside your home folder (or the temporary folder) and not in a
hidden folder. Home itself, a folder above it (`/`, `/home`, `/Users`, a drive's root),
hidden folders such as `~/.config` and folders elsewhere don't count. Hidden files and folders
inside the design's folder (`.env`, `.git`) are out of reach too;
- the folder of the open design (the `--in` design, the design open in the app, or whatever
the agent last opened or saved), but only when it lies strictly inside your home folder (or
the temporary folder) and not in a hidden folder. Home itself, a folder above it (`/`,
`/home`, `/Users`, a drive's root), hidden folders such as `~/.config` and folders elsewhere
don't count. Hidden files and folders inside the design's folder (`.env`, `.git`) are out of
reach too;
- on the same terms, every folder the agent opened or saved a design file in during this
server's run (`open`, `save`, or `doc.open`, `file.save` and `file.save_as` through `execute`
or `batch`, with the path given in full) and, headless, every folder a design was open in,
until the server stops (the 16 most recent). So after a new design, an opened STEP file or a
save-as elsewhere, the agent can still save beside the design it worked on. Such a call
succeeded only because its folder was already one of the agent's, so no folder joins just
because the agent names it;
- SolidCraft's own recovery folder, so `doc.recovery_list`, `doc.recover` and
`doc.recovery_discard` work out of the box (discarding deletes only real recovery entries);
- the server's own scratch folder (a new private `solidcraft-mcp-*` folder in the temporary
@@ -116,7 +124,15 @@ solidcraft-cli mcp --allow-path ~/designs --allow-path ~/exports
solidcraft-cli mcp --allow-any-path # no limit (the behaviour before this option existed)
```
Bridged, the server sends its folders with every request (`allow_paths`, see
When a `save` (or any other call) is refused with `… outside the folders this agent may use …`,
add the folder to the server's `args` in your MCP client's configuration (the `mcpServers`
entries below, or what `solidcraft-cli mcp setup` wrote), for example
`"args": ["mcp", "--allow-path", "/Users/NAME/Documents/Designs"]`, and restart the client.
An agent should ask you to do that rather than save through the app's control port, which
knows nothing of these folders.
Bridged, the server sends its folders with every request (`allow_paths`, and the folders the
agent opened or saved a design in as `design_folders`, see
[control-protocol.md](control-protocol.md)) and the app adds its own recovery folder and the
folder of the design open in it, under the same rules, so give absolute paths: a relative one
resolves against the app's working folder, not the server's. The app's own