pub use merry_mcp::{
MCP_CALL_TOOL, MCP_SEARCH_TOOL, McpDiscovery, McpDiscoveryStage, McpError, McpFailureKind,
McpResult, McpServerConfig, McpServerConfigBuilder, McpServerDiagnostic, McpServerIssue,
McpToolRegistration, discover_mcp_tools,
};
use merry_runtime::RegisteredTool;
#[derive(Default)]
pub struct McpToolset {
tools: Vec<RegisteredTool>,
warnings: Vec<McpServerDiagnostic>,
}
impl McpToolset {
pub async fn discover(servers: &[McpServerConfig]) -> McpResult<Self> {
let discovery = discover_mcp_tools(servers).await?;
Ok(Self::from_discovery(discovery))
}
#[must_use]
pub fn from_discovery(discovery: McpDiscovery) -> Self {
let (registrations, warnings) = discovery.into_parts();
Self {
tools: registrations
.into_iter()
.map(|registration| registration.tool)
.collect(),
warnings,
}
}
#[must_use]
pub fn len(&self) -> usize {
self.tools.len()
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.tools.is_empty()
}
#[must_use]
pub fn warnings(&self) -> &[McpServerDiagnostic] {
&self.warnings
}
#[doc(hidden)]
#[must_use]
pub fn into_parts(self) -> (Vec<RegisteredTool>, Vec<McpServerDiagnostic>) {
(self.tools, self.warnings)
}
}