Skip to main content

mur_common/skill/
inventory.rs

1use std::sync::Arc;
2
3/// Read-only snapshot of MCP tool names visible to one agent.
4/// Cheap to build, cheap to clone — just `Vec<String>` behind an `Arc`.
5/// Built once per inject pass and threaded into the resolver.
6#[derive(Debug, Clone, Default)]
7pub struct McpInventory {
8    tools: Arc<Vec<String>>,
9}
10
11impl McpInventory {
12    pub fn from_tool_names(tools: Vec<String>) -> Self {
13        Self {
14            tools: Arc::new(tools),
15        }
16    }
17
18    pub fn contains(&self, name: &str) -> bool {
19        self.tools.iter().any(|t| t == name)
20    }
21
22    pub fn iter(&self) -> impl Iterator<Item = &str> {
23        self.tools.iter().map(|s| s.as_str())
24    }
25
26    pub fn is_empty(&self) -> bool {
27        self.tools.is_empty()
28    }
29}