pub struct InternalTool {
pub name: String,
pub description: String,
pub parameters: Value,
pub metadata: HashMap<String, Value>,
}Expand description
Internal tool representation - the hub format for all protocols.
This type serves as the canonical representation for tools from any source:
- Native tools (e.g., from CATS)
- MCP tools (from Model Context Protocol servers)
- A2A tools (from Agent-to-Agent protocol, future)
Protocol-specific metadata is preserved in the metadata field to enable
round-trip conversion without data loss.
§Example
use umf::internal::InternalTool;
use serde_json::json;
let tool = InternalTool::new(
"get_weather",
"Get the current weather for a location",
json!({
"type": "object",
"properties": {
"location": { "type": "string", "description": "City name" }
},
"required": ["location"]
}),
);Fields§
§name: StringTool name (unique identifier within a registry).
description: StringTool description for LLM consumption.
parameters: ValueJSON Schema for tool parameters.
This should follow the JSON Schema specification and typically has the structure:
{
"type": "object",
"properties": { ... },
"required": [ ... ]
}metadata: HashMap<String, Value>Protocol-specific metadata preserved through conversion.
Used to store protocol-specific fields that don’t map directly to the internal format, enabling lossless round-trip conversion. Keys are prefixed with the protocol name (e.g., “mcp_annotations”).
Implementations§
Source§impl InternalTool
impl InternalTool
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
parameters: Value,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, parameters: Value, ) -> Self
Create a new internal tool.
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Add metadata to the tool.
Sourcepub fn has_metadata(&self, key: &str) -> bool
pub fn has_metadata(&self, key: &str) -> bool
Check if the tool has a specific metadata key.
Sourcepub fn get_metadata(&self, key: &str) -> Option<&Value>
pub fn get_metadata(&self, key: &str) -> Option<&Value>
Get a metadata value by key.
Trait Implementations§
Source§impl Clone for InternalTool
impl Clone for InternalTool
Source§fn clone(&self) -> InternalTool
fn clone(&self) -> InternalTool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more