lean-ctx 3.6.5

Context Runtime for AI Agents with CCP. 51 MCP tools, 10 read modes, 60+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%.
Documentation
use rmcp::model::{
    Notification, NotificationNoParam, ResourceUpdatedNotificationParam, ServerNotification,
    ToolListChangedNotificationMethod,
};
use rmcp::service::{Peer, RoleServer};

pub async fn send_resource_updated(peer: &Peer<RoleServer>, uri: &str) {
    let notif = Notification::new(ResourceUpdatedNotificationParam::new(uri));
    let server_notif = ServerNotification::ResourceUpdatedNotification(notif);
    if let Err(e) = peer.send_notification(server_notif).await {
        tracing::debug!("Failed to send resource updated notification: {e}");
    }
}

pub async fn send_tools_list_changed(peer: &Peer<RoleServer>) {
    let notif = NotificationNoParam {
        method: ToolListChangedNotificationMethod,
        extensions: rmcp::model::Extensions::default(),
    };
    let server_notif = ServerNotification::ToolListChangedNotification(notif);
    if let Err(e) = peer.send_notification(server_notif).await {
        tracing::debug!("Failed to send tools list changed notification: {e}");
    }
}

pub const RESOURCE_URI_SUMMARY: &str = "lean-ctx://context/summary";
pub const RESOURCE_URI_PRESSURE: &str = "lean-ctx://context/pressure";

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn notification_types_construct_correctly() {
        let notif = Notification::new(ResourceUpdatedNotificationParam::new(RESOURCE_URI_SUMMARY));
        let sn = ServerNotification::ResourceUpdatedNotification(notif);
        assert!(matches!(
            sn,
            ServerNotification::ResourceUpdatedNotification(_)
        ));

        let notif = NotificationNoParam {
            method: ToolListChangedNotificationMethod,
            extensions: rmcp::model::Extensions::default(),
        };
        let sn = ServerNotification::ToolListChangedNotification(notif);
        assert!(matches!(
            sn,
            ServerNotification::ToolListChangedNotification(_)
        ));
    }
}