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
impl ToolIndex
Sourcepub fn from_inventory() -> Self
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.
Sourcepub fn definitions(&self) -> &[ToolDefinition]
pub fn definitions(&self) -> &[ToolDefinition]
All tool definitions advertised by tools/list, sorted by name.
Sourcepub fn dispatch_for(&self, name: &str) -> Option<&DispatchFn>
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.