mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-27 04:16:48 -06:00
tools/call checks the arguments against the tool's input schema: an
unknown tool, non-object arguments, a missing required argument or one
of the wrong type is a JSON-RPC -32602 error, as the MCP spec says, so
`command_line {}` no longer presses Enter and `script {}` no longer
succeeds. An empty batch `[]` gets one Invalid Request (-32600).
The `entities` command behind query_entities rejects a malformed window,
non-string type/layer and bad limit/offset instead of ignoring them.
`count` is every match, `returned` the page (`offset` is now in the tool
schema), and a window matches objects whose geometry is inside or
crosses it (the window/crossing selection test), with `crossing: false`
for entirely inside.
list_commands' filter matches command ids, labels and aliases, not any
text in the command's JSON.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.0 KiB
Rust
29 lines
1.0 KiB
Rust
//! The `entities` query (control channel `engine.execute`, MCP `query_entities`) rejects malformed
|
|
//! filters instead of ignoring them and returning everything.
|
|
|
|
use cadcraft_engine::Session;
|
|
use serde_json::json;
|
|
|
|
#[test]
|
|
fn malformed_filters_are_errors() {
|
|
let mut s = Session::new();
|
|
s.execute("circle", &json!({"center": [0, 0], "radius": 1})).unwrap();
|
|
s.execute("circle", &json!({"center": [100, 100], "radius": 1})).unwrap();
|
|
for p in [
|
|
json!({"window": [-5, -5, 5, 5]}),
|
|
json!({"window": [[-5, -5]]}),
|
|
json!({"window": [[-5, -5], [5, 5], [9, 9]]}),
|
|
json!({"window": {"min": [-5, -5], "max": [5, 5]}}),
|
|
json!({"window": "x"}),
|
|
json!({"type": 7}),
|
|
json!({"layer": ["0"]}),
|
|
json!({"limit": -1}),
|
|
json!({"offset": "1"}),
|
|
json!({"crossing": "yes"}),
|
|
] {
|
|
assert!(s.execute("entities", &p).is_err(), "{p} must be rejected");
|
|
}
|
|
let r = s.execute("entities", &json!({"window": [[-5, -5], [5, 5]]})).unwrap();
|
|
assert_eq!(r["count"], 1, "{r}");
|
|
}
|