use std::sync::Arc;
use aion_mcp::protocol::meta::Implementation;
use aion_mcp::{McpServer, McpServerConfig};
use crate::config::ResolvedMcpConfig;
use crate::{ServerError, ServerState};
use super::service::AssistantToolService;
pub(crate) struct AssistantMcpRuntime {
server: McpServer<AssistantToolService>,
}
impl AssistantMcpRuntime {
pub(crate) fn build(
state: ServerState,
config: &ResolvedMcpConfig,
) -> Result<Self, ServerError> {
let service = AssistantToolService::new(state).map_err(|error| ServerError::Config {
message: format!("the assistant MCP tool catalog is invalid: {error}"),
})?;
Ok(Self {
server: McpServer::new(
Arc::new(service),
McpServerConfig::new(
Implementation::new("aion-assistant", env!("CARGO_PKG_VERSION")),
config.discover_ttl_ms,
config.tools_list_ttl_ms,
config.task_poll_interval_ms,
config.allowed_origins.clone(),
),
),
})
}
pub(crate) const fn server(&self) -> &McpServer<AssistantToolService> {
&self.server
}
}