MCPcopy Index your code
hub / github.com/AI45Lab/Code / register

Method register

core/src/tools/registry.rs:74–88  ·  view source on GitHub ↗

Register a tool If a tool with the same name already exists as a builtin, the registration is rejected to prevent shadowing of core tools.

(&self, tool: Arc<dyn Tool>)

Source from the content-addressed store, hash-verified

72 /// If a tool with the same name already exists as a builtin, the registration
73 /// is rejected to prevent shadowing of core tools.
74 pub fn register(&self, tool: Arc<dyn Tool>) {
75 let name = tool.name().to_string();
76 let builtins = self.builtins.read().unwrap();
77 if builtins.contains(&name) {
78 tracing::warn!(
79 "Rejected registration of tool '{}': cannot shadow builtin",
80 name
81 );
82 return;
83 }
84 drop(builtins);
85 let mut tools = self.tools.write().unwrap();
86 tracing::debug!("Registering tool: {}", name);
87 tools.insert(name, tool);
88 }
89
90 /// Unregister a tool by name
91 ///

Calls 4

containsMethod · 0.80
writeMethod · 0.80
nameMethod · 0.45
insertMethod · 0.45