liminal_cli/mcp/
template_tools.rs1use super::tools::ToolResult;
4use crate::network::Rail;
5use serde_json::{Map, Value, json};
6
7#[must_use]
9pub fn tool_entries() -> Vec<Value> {
10 vec![
11 json!({"name":"propose_template","description":"Propose the bound builder's command for its site while it is building. The server validates operator roots, hashes the file and holds exact path, digest, args, environment names and subjects for a person's approval.",
12 "inputSchema":invocation()}),
13 json!({"name":"templates_update","description":"Change a complete site's program after it is rebuilt: the server hashes the file again under the operator roots; on an open exchange the change executes now, on a gated one it is held for approvers. The next start runs the new digest.",
14 "inputSchema":invocation()}),
15 ]
16}
17
18fn invocation() -> Value {
20 json!({"type":"object","required":["service","command","args","env","stop_timeout_ms"],"additionalProperties":false,
21 "properties":{"service":{"type":"string"},"command":{"type":"string"},"args":{"type":"array","items":{"type":"string"}},
22 "env":{"type":"array","items":{"type":"string"}},"stop_timeout_ms":{"type":"integer","minimum":1},"operation":{"type":"string"}}})
23}
24
25#[must_use]
27pub fn tool<R: Rail>(rail: &R, name: &str, arguments: &Map<String, Value>) -> Option<ToolResult> {
28 let subject = match name {
29 "propose_template" => "services.propose_template",
30 "templates_update" => "templates.update",
31 _ => return None,
32 };
33 Some(super::plan_tools::forward(rail, name, subject, arguments))
34}
35
36#[cfg(test)]
37#[path = "template_tools_tests.rs"]
38mod tests;