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:
co-authored by
Claude Opus 5.5
parent
7b41793ab4
commit
3df56ce9d9
@@ -1053,3 +1053,14 @@ fn panicked_render_worker_finishes_with_an_error() {
|
|||||||
let reply: Value = serde_json::from_slice(&out).unwrap();
|
let reply: Value = serde_json::from_slice(&out).unwrap();
|
||||||
assert_eq!(reply["result"]["isError"], true, "{reply}");
|
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");
|
||||||
|
}
|
||||||
|
|||||||
@@ -537,7 +537,12 @@ static TOOLS: &[ToolDef] = &[
|
|||||||
name: "describe_command",
|
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.",
|
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,
|
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,
|
run: describe_command,
|
||||||
},
|
},
|
||||||
ToolDef {
|
ToolDef {
|
||||||
@@ -548,9 +553,10 @@ static TOOLS: &[ToolDef] = &[
|
|||||||
schema(
|
schema(
|
||||||
json!({
|
json!({
|
||||||
"command": {"type": "string", "description": "Command id, e.g. `comp.new`, `layer.newText`, `effect.apply` (see list_commands)."},
|
"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}
|
"params": {"type": "object", "description": "Command parameters as documented by list_commands.", "additionalProperties": true}
|
||||||
}),
|
}),
|
||||||
&["command"],
|
&[],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
run: execute_command,
|
run: execute_command,
|
||||||
|
|||||||
+2
-2
@@ -80,8 +80,8 @@ See [MCP conventions](mcp.md) for core tools, resources, strict arguments, and r
|
|||||||
| Tool | What it does |
|
| Tool | What it does |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `list_commands {filter?, enabled_only?, schemas?}` | Discover command ids, their param docs (and, with `schemas`, a JSON Schema each), and whether each can run now. |
|
| `list_commands {filter?, enabled_only?, schemas?}` | Discover command ids, their param docs (and, with `schemas`, a JSON Schema each), and whether each can run now. |
|
||||||
| `describe_command {command}` | One command in full: label, menu, shortcut, params doc, JSON `schema`, enabled / `why`. |
|
| `describe_command {command \| id}` | One command in full: label, menu, shortcut, params doc, JSON `schema`, enabled / `why`. |
|
||||||
| `execute_command {command, params?}` | Run any command (undoable). Unknown parameter keys are rejected with the accepted list. |
|
| `execute_command {command \| id, params?}` | Run any command (undoable). Unknown parameter keys are rejected with the accepted list. |
|
||||||
| `get_state` | Editor state (active comp, time, selections, tool) plus `app`: version, command and effect counts, export formats, parity summary. |
|
| `get_state` | Editor state (active comp, time, selections, tool) plus `app`: version, command and effect counts, export formats, parity summary. |
|
||||||
| `run_script {code, name?}` | Run JavaScript with the After Effects-style scripting object model (`app.project`, `comp.layers.addText(…)`, `layer.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(…)`…). Returns `{ok, result, output, error: {message, line, column}}`; edits are undoable. |
|
| `run_script {code, name?}` | Run JavaScript with the After Effects-style scripting object model (`app.project`, `comp.layers.addText(…)`, `layer.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(…)`…). Returns `{ok, result, output, error: {message, line, column}}`; edits are undoable. |
|
||||||
| `get_project` / `get_comp {comp?}` | Project items, comp settings and layers. |
|
| `get_project` / `get_comp {comp?}` | Project items, comp settings and layers. |
|
||||||
|
|||||||
Reference in New Issue
Block a user