Skip to main content

ToolDefinition

Struct ToolDefinition 

Source
pub struct ToolDefinition {
Show 18 fields pub tool_id: String, pub name: String, pub version: String, pub tool_type: String, pub endpoint: String, pub description: String, pub capabilities: Vec<String>, pub category: String, pub creator_did: Option<String>, pub creator_wallet: Option<Address>, pub price_per_call: u128, pub status: ToolStatus, pub created_at: u64, pub invocation_count: u64, pub last_seen_at: u64, pub upstream_auth: Option<UpstreamAuth>, pub spawn_spec: Option<StdioSpawnSpec>, pub allowed_to_subjects: Option<Vec<String>>,
}
Expand description

A tool (MCP server, API endpoint, or native capability) published to the Tenzro Network tools registry.

Tools are discovered by agents and invoked to take real-world actions: web search, code execution, file access, API calls, etc. Unlike skills (which encode reasoning/logic), tools are the actual external interfaces agents connect to.

Tool types:

  • "mcp" — MCP server at endpoint (JSON-RPC 2.0 Streamable HTTP)
  • "api" — OpenAPI-compatible REST endpoint
  • "native" — built-in node capability

Fields§

§tool_id: String

Unique tool identifier (UUID v4)

§name: String

Human-readable tool name (e.g., “web-search-mcp”, “code-executor”)

§version: String

Semantic version string (e.g., “1.0.0”)

§tool_type: String

Tool type: “mcp”, “api”, or “native”

§endpoint: String

MCP/API endpoint URL (required for mcp and api types)

§description: String

Description of what this tool does

§capabilities: Vec<String>

Capabilities provided by this tool (e.g., [“web-search”, “read-url”])

§category: String

Category for discovery (e.g., “search”, “code”, “data”, “automation”)

§creator_did: Option<String>

DID of the agent or human who registered this tool

§creator_wallet: Option<Address>

Payout wallet for the creator’s share of paid invocations. Mandatory for any non-zero price_per_call; registration fails (ToolError::MissingCreatorWallet) if omitted for a paid tool. Free tools (price_per_call == 0) may leave this None.

§price_per_call: u128

Price per invocation in TNZO atto-tokens (1 TNZO = 10^18 atto). Set to 0 for a free tool. The split is identical to the agent template marketplace: MARKETPLACE_COMMISSION_BPS (5%) to the treasury, remainder to creator_wallet.

§status: ToolStatus

Current status of the tool

§created_at: u64

Unix timestamp (seconds) when the tool was registered

§invocation_count: u64

Number of times this tool has been invoked

§last_seen_at: u64

Unix timestamp (seconds) of the last liveness signal. Liveness sweeper flips status to Inactive once the tool stays silent past the configured TTL. Charitable serde default keeps pre-upgrade rows alive until they actually go silent.

§upstream_auth: Option<UpstreamAuth>

Upstream credential injection for this tool. When Some, the operator’s sealed secret (looked up by sealed_secret_ref at invocation time) is injected per the variant rules — into a request header for Mcp / McpSse / Api, into an env var for McpStdio. Tenants NEVER see the underlying secret. Default None means no credentials are injected (public MCPs).

§spawn_spec: Option<StdioSpawnSpec>

Subprocess spawn specification for McpStdio transport. Required when tool_type == "mcp-stdio". Ignored for other transports.

§allowed_to_subjects: Option<Vec<String>>

Optional subject-level access list. When Some(vec), only API-key subjects whose subject appears in vec are permitted to invoke this tool. None (the default) means the tool is open to any API key that is allowed by AgentDelegation.

Implementations§

Source§

impl ToolDefinition

Source

pub fn new( name: String, version: String, tool_type: String, endpoint: String, description: String, category: String, ) -> Self

Creates a new tool definition with default values

Source

pub fn transport_mode(&self) -> Option<ToolTransportMode>

Returns the typed transport mode derived from the legacy tool_type string. Returns None for unknown strings so the caller can refuse to invoke an unknown transport safely.

Source

pub fn set_transport_mode(&mut self, mode: ToolTransportMode)

Sets both the typed transport mode and the legacy tool_type string field in lockstep. Use this from the registration RPC when the caller passes a strongly-typed transport mode.

Source

pub fn is_subject_allowed(&self, subject: Option<&str>) -> bool

Returns true when subject is permitted to invoke this tool per the optional subject-level access list. When the list is None, the tool is open to any API key (subject-gating is disabled). When Some(vec), only subjects in vec are allowed.

Source

pub fn is_paid(&self) -> bool

Returns true when this tool is paid (non-zero price_per_call).

Source

pub fn validate_for_registration(&self) -> Result<(), &'static str>

Validate registration invariants. Any paid tool must declare a creator_wallet to receive the creator share of each invocation. Free tools (price_per_call == 0) may omit creator_wallet.

Source

pub fn is_available(&self) -> bool

Returns true if the tool is available for invocation

Source

pub fn touch(&mut self)

Bumps last_seen_at to current wall-clock time.

Trait Implementations§

Source§

impl Clone for ToolDefinition

Source§

fn clone(&self) -> ToolDefinition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolDefinition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ToolDefinition

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ToolDefinition

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.