agentmux_mcp/tools/
identity_tool.rs1use super::family::{pick, relabeled, Act};
11use super::*;
12
13pub(super) const ACTS: &[Act] = &[
14 Act { action: "presets", tool: "PresetList", rename: &[] },
15 Act { action: "preset", tool: "PresetGet", rename: &[] },
16 Act { action: "accounts", tool: "IdentityAccounts", rename: &[] },
17 Act { action: "validate", tool: "IdentityValidate", rename: &[] },
18 Act { action: "switch", tool: "IdentitySwitch", rename: &[] },
19 Act { action: "check_limits", tool: "IdentityCheckLimits", rename: &[] },
20 Act { action: "signin", tool: "IdentitySignin", rename: &[] },
21 Act { action: "aws_grants", tool: "IdentityAwsGrants", rename: &[] },
22 Act { action: "aws_grant", tool: "IdentityAwsGrant", rename: &[] },
23];
24
25pub(super) async fn call(name: &str, arguments: &Value, cx: &ToolCtx<'_>) -> Result<String> {
26 match name {
27 "Identity" => {
28 let (act, args) = pick("Identity", ACTS, arguments)?;
29 let result = match act.tool {
30 "PresetList" | "PresetGet" => presets::call(act.tool, &args, cx).await,
31 "IdentityAwsGrants" | "IdentityAwsGrant" => aws_grants::call(act.tool, &args, cx).await,
32 _ => accounts::call(act.tool, &args, cx).await,
33 };
34 relabeled("Identity", ACTS, result)
35 }
36 _ => Err(not_in_family()),
37 }
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn every_action_is_in_the_schema() {
46 let schema: Value = serde_json::from_str(crate::tool_schemas::IDENTITY_TOOL).unwrap();
47 let mut listed: Vec<&str> = schema["inputSchema"]["properties"]["action"]["enum"]
48 .as_array()
49 .unwrap()
50 .iter()
51 .filter_map(|v| v.as_str())
52 .collect();
53 let mut want = super::super::family::action_names(ACTS);
54 listed.sort();
55 want.sort();
56 assert_eq!(listed, want);
57 }
58}