MCP open: pass a design's model choice to geometry.open

The open tool's schema and description name the keep/new choice and the
reply's related/stale report; docs/mcp.md says the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-14 18:07:30 -04:00
1 parent 4a60674530
commit 14e2d25e68
3 files changed
+22 -5

No files matched your search

+2
View File
@@ -163,6 +163,7 @@ fn hostile_tool_arguments_are_tool_errors() {
("open", json!({"path": "/etc/passwd"})),
("open", json!({"path": "/no/such/model.fieldcraft"})),
("open", json!({"path": huge.clone() + ".solidcraft"})),
("open", json!({"path": "/no/such/model.fieldcraft", "model": "new"})),
("save", json!({})),
("write_deck", json!({"format": "abaqus", "path": "/no/such/dir/x.inp"})),
("mesh", json!({"method": "tet", "params": {"body": "Nope", "tolerance": 0.5}})),
@@ -270,6 +271,7 @@ fn file_access_stays_inside_the_roots() {
refused(&mut s, "open", json!({"path": input.join("link.solidcraft")}));
refused(&mut s, "execute", json!({"command": "geometry.open", "params": {"path": input.join("../outside/c.solidcraft")}}));
ok(&mut s, "open", json!({"path": input.join("c.solidcraft")}));
ok(&mut s, "open", json!({"path": input.join("c.solidcraft"), "model": "new"}));
refused(&mut s, "save", json!({"path": outside.join("m.fieldcraft")}));
refused(&mut s, "save", json!({"path": input.join("m.fieldcraft")}));
refused(&mut s, "execute", json!({"command": "file.save_as", "params": {"path": outside.join("m.fieldcraft")}}));
+19 -4
View File
@@ -139,9 +139,17 @@ pub fn tool_definitions() -> Vec<Value> {
"open",
"Open a file",
"Open by extension: a .fieldcraft model (file.open: replaces the model; its design and meshes open again), a \
SolidCraft design .solidcraft (geometry.open: its bodies become the geometry) or a face-tagged .3mf mesh \
(geometry.import.mesh: added as a surface).",
obj(json!({"path": string("Path to a .fieldcraft, .solidcraft or .3mf file")}), &["path"]),
SolidCraft design .solidcraft (geometry.open: its bodies become the geometry; `model` \"keep\", the default, \
keeps the mesh and definitions for a reopen after an edit, \"new\" starts a new model; the reply's `related` \
and `stale` say what no longer resolves on another part) or a face-tagged .3mf mesh (geometry.import.mesh: \
added as a surface).",
obj(
json!({
"path": string("Path to a .fieldcraft, .solidcraft or .3mf file"),
"model": {"type": "string", "enum": ["keep", "new"], "description": "For a .solidcraft design: keep the current model (default) or start a new one"},
}),
&["path"],
),
false,
true,
),
@@ -450,7 +458,14 @@ fn dispatch(b: &mut dyn Backend, name: &str, a: &Map<String, Value>) -> Result<V
Some("3mf") => "geometry.import.mesh",
_ => return Err("open: a .fieldcraft model, a .solidcraft design or a .3mf mesh".into()),
};
let r = b.execute(command, json!({"path": path}))?;
let mut params = json!({"path": path});
if let Some(model) = a.get("model").filter(|m| !m.is_null()) {
if command != "geometry.open" {
return Err("open: `model` applies to a .solidcraft design only".into());
}
params["model"] = model.clone();
}
let r = b.execute(command, params)?;
Ok(json!({"command": command, "result": r}))
}
"save" => b.execute("file.save", pick(a, &["path"])),