Skip to main content

systemprompt_provider_contracts/tool/
inventory.rs

1//! The typed partial outcome of a tool listing across several servers.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use systemprompt_identifiers::McpServerId;
7
8use super::definition::ToolDefinition;
9
10/// Tools gathered from every reachable server plus the servers that could
11/// not be listed.
12///
13/// A consumer that needs the full inventory must treat a non-empty
14/// `failed_servers` as a failure, never as "fewer tools".
15#[derive(Debug, Clone, Default)]
16pub struct ToolInventory {
17    pub tools: Vec<ToolDefinition>,
18    pub failed_servers: Vec<ServerListingFailure>,
19}
20
21#[derive(Debug, Clone)]
22pub struct ServerListingFailure {
23    pub server: McpServerId,
24    pub message: String,
25}
26
27impl ToolInventory {
28    #[must_use]
29    pub const fn complete(tools: Vec<ToolDefinition>) -> Self {
30        Self {
31            tools,
32            failed_servers: Vec::new(),
33        }
34    }
35
36    #[must_use]
37    pub const fn is_complete(&self) -> bool {
38        self.failed_servers.is_empty()
39    }
40}