Skip to main content

ToolIndex

Struct ToolIndex 

Source
pub struct ToolIndex { /* private fields */ }
Expand description

One-time index built from the global inventory at startup. Holds definitions in registration order (so tools/list output is deterministic across builds — inventory::iter itself orders entries by submission link order, but we sort by name to remove that dependency for tests) and a name → dispatch map for tools/call.

Implementations§

Source§

impl ToolIndex

Source

pub fn from_inventory() -> Self

Build the index from inventory::iter::<McpToolEntry>().

FALSIFY-INVENTORY-002: panics with a clear diagnostic if two entries share the same name. The panic fires the first time any test or production path constructs an AprMcpServer, so a duplicate-name regression cannot escape CI.

Source

pub fn definitions(&self) -> &[ToolDefinition]

All tool definitions advertised by tools/list, sorted by name.

Source

pub fn dispatch_for(&self, name: &str) -> Option<&DispatchFn>

Look up the dispatch function for a tools/call request. Returns None if no tool with that name is registered — the caller is responsible for emitting the appropriate isError envelope.

Source

pub fn names(&self) -> Vec<&'static str>

Names of all registered tools, alphabetically sorted. Used by FALSIFY-INVENTORY-001 to assert the migrated set matches the pre-migration golden list.

Trait Implementations§

Source§

impl Debug for ToolIndex

Source§

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

Formats the value using the given formatter. 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> 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, 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.