Skip to main content

do_memory_mcp/
lib.rs

1#![allow(clippy::useless_attribute)]
2#![allow(clippy::excessive_nesting)]
3#![allow(clippy::missing_errors_doc)]
4#![allow(clippy::ifs_same_cond)]
5
6//! # Memory MCP (Model Context Protocol) Integration
7//!
8//! This crate provides MCP server integration for the self-learning memory system,
9//! enabling memory queries and pattern analysis through standardized tool interfaces.
10//!
11//! ## Features
12//!
13//! - **MCP Server**: Standard MCP server implementation with tool definitions
14//! - **Memory Integration**: Query episodic memory and analyze patterns
15//! - **Progressive Disclosure**: Tools are prioritized based on usage patterns
16//! - **Execution Monitoring**: Detailed statistics and logging
17//!
18//! ## Example
19//!
20//! ```no_run
21//! use do_memory_core::SelfLearningMemory;
22//! use do_memory_mcp::server::MemoryMCPServer;
23//! use do_memory_mcp::types::SandboxConfig;
24//! use std::sync::Arc;
25//!
26//! #[tokio::main]
27//! async fn main() -> anyhow::Result<()> {
28//!     // Create memory and server
29//!     let memory = Arc::new(SelfLearningMemory::new());
30//!     let server = MemoryMCPServer::new(SandboxConfig::default(), memory).await?;
31//!
32//!     // List available tools
33//!     let tools = server.list_tools().await;
34//!     for tool in tools {
35//!         println!("Tool: {} - {}", tool.name, tool.description);
36//!     }
37//!
38//!     Ok(())
39//! }
40//! ```
41//!
42//! ## Architecture
43//!
44//! ```text
45//! ┌─────────────────────────────────────────────────────────┐
46//! │                    MCP Server                           │
47//! │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐ │
48//! │  │ Query Memory │  │ Analyze      │  │ Execute      │ │
49//! │  │              │  │ Patterns     │  │ Operations   │ │
50//! │  └──────────────┘  └──────────────┘  └──────────────┘ │
51//! └───────────────────────┬─────────────────────────────────┘
52//!                         │
53//!          ┌──────────────┴──────────────┐
54//!          ▼                             ▼
55//! ┌─────────────────┐          ┌──────────────────┐
56//! │  Memory System  │          │  Monitoring      │
57//! │  - Episodes     │          │  - Metrics       │
58//! │  - Patterns     │          │  - Health        │
59//! │  - Heuristics   │          │                  │
60//! └─────────────────┘          └──────────────────┘
61//! ```
62
63pub mod batch;
64pub mod cache;
65pub mod error;
66pub mod jsonrpc;
67pub mod mcp;
68pub mod monitoring;
69pub mod patterns;
70pub mod protocol;
71pub mod sandbox;
72pub mod server;
73pub mod types;
74
75// Re-export commonly used types
76pub use batch::{
77    BatchExecutor, BatchMode, BatchOperation, BatchRequest, BatchResponse, BatchStats,
78    DependencyGraph, OperationError, OperationResult,
79};
80pub use cache::{CacheConfig, CacheStats, QueryCache};
81pub use error::{Error, Result};
82pub use sandbox::CodeSandbox;
83pub use sandbox::{FileSystemRestrictions, IsolationConfig, NetworkRestrictions};
84pub use server::MemoryMCPServer;
85pub use server::audit::{AuditConfig, AuditDestination, AuditLogEntry, AuditLogLevel, AuditLogger};
86pub use types::{
87    ErrorType, ExecutionContext, ExecutionResult, ExecutionStats, ResourceLimits, SandboxConfig,
88    SecurityViolationType, Tool,
89};