pub fn extract_arg(arguments: &str, name: &str) -> Option<String>Expand description
Extract an argument from a tool/prompt arguments JSON object: a
string’s value, or a number’s or boolean’s literal text ("3",
"true"). Objects, arrays and null are None. Numbers and booleans
used to be None too, so a tool reading "enabled": true saw nothing.
use rust_web_server::mcp::extract_arg;
assert_eq!(extract_arg(r#"{"text":"hello"}"#, "text").as_deref(), Some("hello"));
assert_eq!(extract_arg(r#"{"enabled":true,"n":3}"#, "enabled").as_deref(), Some("true"));
assert_eq!(extract_arg(r#"{"enabled":true,"n":3}"#, "n").as_deref(), Some("3"));
assert_eq!(extract_arg(r#"{}"#, "missing"), None);