MCPcopy Create free account
hub / github.com/GCWing/BitFun / metadata_tools

Function metadata_tools

src/crates/execution/agent-runtime/src/custom_agent.rs:620–647  ·  view source on GitHub ↗
(metadata: &Value, kind: CustomAgentKind)

Source from the content-addressed store, hash-verified

618}
619
620fn metadata_tools(metadata: &Value, kind: CustomAgentKind) -> Result<Option<Vec<String>>, String> {
621 let Some(value) = metadata.get("tools") else {
622 return Ok(None);
623 };
624
625 match value {
626 Value::String(raw) => Ok(Some(
627 raw.split(',')
628 .map(|item| item.trim().to_string())
629 .filter(|item| !item.is_empty())
630 .collect(),
631 )),
632 Value::Sequence(values) => {
633 let mut tools = Vec::new();
634 for item in values {
635 let Some(tool) = item.as_str() else {
636 return Err(format!("Invalid tools field for {:?}", kind));
637 };
638 let tool = tool.trim();
639 if !tool.is_empty() {
640 tools.push(tool.to_string());
641 }
642 }
643 Ok(Some(tools))
644 }
645 _ => Err(format!("Invalid tools field for {:?}", kind)),
646 }
647}
648
649fn metadata_user_context_policy(metadata: &Value) -> Result<Option<UserContextPolicy>, String> {
650 let Some(value) = metadata.get("user_context_policy") else {

Callers 1

Calls 6

collectMethod · 0.80
trimMethod · 0.80
getMethod · 0.45
is_emptyMethod · 0.45
as_strMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected