Skip to main content

mcp_session_memory/
store.rs

1use crate::error::MemoryError;
2use crate::types::*;
3
4#[async_trait::async_trait]
5pub trait SessionStore: Send + Sync {
6    async fn get_session(&self, session_id: &str) -> Result<Session, MemoryError>;
7    async fn put_session(&self, session: Session) -> Result<(), MemoryError>;
8    async fn update_session(&self, session: Session) -> Result<(), MemoryError>;
9
10    async fn list_events(&self, session_id: &str, event_types: Option<&[EventType]>, limit: usize) -> Result<Vec<SessionEvent>, MemoryError>;
11    async fn put_event(&self, event: SessionEvent) -> Result<(), MemoryError>;
12
13    async fn put_snapshot(&self, snapshot: ReplaySnapshot) -> Result<(), MemoryError>;
14    async fn get_snapshot(&self, snapshot_id: &str) -> Result<ReplaySnapshot, MemoryError>;
15}
16
17#[async_trait::async_trait]
18pub trait MemoryStore: Send + Sync {
19    async fn retrieve(&self, subject_type: &str, subject_id: &str, memory_types: Option<&[MemoryType]>, query: Option<&str>, limit: usize) -> Result<Vec<MemoryEntry>, MemoryError>;
20    async fn get_memory(&self, memory_id: &str) -> Result<MemoryEntry, MemoryError>;
21    async fn put_memory(&self, entry: MemoryEntry) -> Result<(), MemoryError>;
22    async fn update_memory(&self, entry: MemoryEntry) -> Result<(), MemoryError>;
23    async fn delete_memory(&self, memory_id: &str) -> Result<(), MemoryError>;
24    async fn list_by_session(&self, session_id: &str) -> Result<Vec<MemoryEntry>, MemoryError>;
25}