MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / register_tool_execution_intercept

Method register_tool_execution_intercept

crates/python/src/py_plugin.rs:605–637  ·  view source on GitHub ↗
(
        &self,
        name: &str,
        priority: i32,
        callback: Py<PyAny>,
    )

Source from the content-addressed store, hash-verified

603
604 #[pyo3(signature = (name: "str", priority: "int", callback: "object") -> "None", text_signature = "(name: str, priority: int, callback: object) -> None")]
605 fn register_tool_execution_intercept(
606 &self,
607 name: &str,
608 priority: i32,
609 callback: Py<PyAny>,
610 ) -> PyResult<()> {
611 let qualified_name = self.qualify_name(name);
612 register_tool_execution_intercept(
613 &qualified_name,
614 priority,
615 wrap_py_tool_exec_intercept_fn(callback),
616 )
617 .map_err(to_py_err)?;
618
619 let name_owned = qualified_name;
620 let mut guard = self.registrations.lock().map_err(|e| {
621 pyo3::exceptions::PyRuntimeError::new_err(format!("plugin context lock poisoned: {e}"))
622 })?;
623 guard.push(PluginRegistration::new(
624 "plugin",
625 name_owned.clone(),
626 Box::new(move || {
627 deregister_tool_execution_intercept(&name_owned)
628 .map(|_| ())
629 .map_err(|e| {
630 PluginError::RegistrationFailed(format!(
631 "tool execution intercept deregistration failed: {e}"
632 ))
633 })
634 }),
635 ));
636 Ok(())
637 }
638
639 fn __repr__(&self) -> String {
640 "<PluginContext>".to_string()

Calls 5

qualify_nameMethod · 0.45
pushMethod · 0.45