MCP: describe_command and execute_command accept id again (#365 follow-up)

#365 rejects arguments missing from a tool's schema; both tools read `id`
as an alias of `command`, so declare it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-09 09:25:25 -04:00
co-authored by Claude Opus 5.5
parent 7b41793ab4
commit 3df56ce9d9
3 changed files with 21 additions and 4 deletions
+11
View File
@@ -1053,3 +1053,14 @@ fn panicked_render_worker_finishes_with_an_error() {
let reply: Value = serde_json::from_slice(&out).unwrap();
assert_eq!(reply["result"]["isError"], true, "{reply}");
}
/// `id` is an accepted alias of `command` (#365 made unknown keys an error).
#[test]
fn command_tools_accept_id_as_an_alias() {
let mut s = server();
let d = call_json(&mut s, "describe_command", json!({"id": "comp.new"}));
assert_eq!(d["id"], "comp.new", "{d}");
call_json(&mut s, "execute_command", json!({"id": "comp.new", "params": {"name": "Alias", "width": 64, "height": 36}}));
let (_, err) = call(&mut s, "execute_command", json!({}));
assert!(err, "neither key is an error");
}
+8 -2
View File
@@ -537,7 +537,12 @@ static TOOLS: &[ToolDef] = &[
name: "describe_command",
description: "One command in full: id, label, menu path, shortcut, the `params` doc, a JSON Schema of its parameters (`schema`: properties, required, additionalProperties) and whether it can run now (`why` if not). Use before execute_command when unsure of the parameters; execute_command rejects unknown keys.",
bridge_only: false,
schema: || schema(json!({"command": {"type": "string", "description": "Command id, e.g. `layer.newText`."}}), &["command"]),
schema: || {
schema(
json!({"command": {"type": "string", "description": "Command id, e.g. `layer.newText`."}, "id": {"type": "string", "description": "Alias of `command`."}}),
&[],
)
},
run: describe_command,
},
ToolDef {
@@ -548,9 +553,10 @@ static TOOLS: &[ToolDef] = &[
schema(
json!({
"command": {"type": "string", "description": "Command id, e.g. `comp.new`, `layer.newText`, `effect.apply` (see list_commands)."},
"id": {"type": "string", "description": "Alias of `command`."},
"params": {"type": "object", "description": "Command parameters as documented by list_commands.", "additionalProperties": true}
}),
&["command"],
&[],
)
},
run: execute_command,