pub fn idempotent(message: &Value) -> boolExpand description
Whether sending message twice changes nothing that sending it once did not.
Every MCP method but tools/call reads. A tools/call is idempotent when its tool’s
declared execution hints say so (crate::capability::ExecutionPolicy::hints), looked
up in the compiled-in registry; a tool that registry does not know is assumed not to
be, because a call wrongly withheld is reported while a call wrongly repeated may have
written twice. A batch is idempotent when every message in it is.
use majordomus_cli::mcp::bridge::idempotent;
use serde_json::json;
let call = |tool: &str| json!({ "method": "tools/call", "params": { "name": tool } });
assert!(idempotent(&json!({ "method": "resources/read", "params": { "uri": "majordomus://repository" } })));
assert!(idempotent(&call("majordomus_repository")));
assert!(!idempotent(&call("majordomus_plan_transition")));
assert!(!idempotent(&call("no_such_tool")));
assert!(!idempotent(&json!([call("majordomus_repository"), call("majordomus_plan_transition")])));