feat: enhance error handling in OAuth URL building and client creation; improve tool argument sanitization

This commit is contained in:
asepharyana
2026-07-12 10:23:26 +07:00
parent 0cc60c12ce
commit bb621fdff2
10 changed files with 79 additions and 43 deletions
+3 -3
View File
@@ -13,8 +13,8 @@ const MCP_CALL_TIMEOUT_MS: u64 = 60_000;
fn mcp_static_str(s: &str) -> &'static str {
static CACHE: OnceLock<Mutex<Vec<&'static str>>> = OnceLock::new();
let mut cache = CACHE.get_or_init(|| Mutex::new(Vec::new())).lock().unwrap();
if let Some(existing) = cache.iter().find(|e| **e == s) {
return *existing;
if let Some(&existing) = cache.iter().find(|e| **e == s) {
return existing;
}
let leaked: &'static str = Box::leak(s.to_string().into_boxed_str());
cache.push(leaked);
@@ -163,7 +163,7 @@ fn call_via_stdio(
let mut guard;
let child: &mut StdioChild = if let Some(mtx) = existing_handle {
guard = mtx.lock().map_err(|e| anyhow::anyhow!("MCP handle lock: {}", e))?;
&mut *guard
&mut guard
} else {
let mut fresh = spawn_stdio_child(command, extra_args)?;
let result = fresh.call("tools/call", json!({