Skip to main content

MemoryMCPServer

Struct MemoryMCPServer 

Source
pub struct MemoryMCPServer { /* private fields */ }
Expand description

MCP server for memory integration

Implementations§

Source§

impl MemoryMCPServer

Source

pub async fn execute_advanced_pattern_analysis( &self, input: AdvancedPatternAnalysisInput, ) -> Result<Value>

Execute the advanced_pattern_analysis tool

§Arguments
  • input - Analysis input parameters
§Returns

Returns comprehensive analysis results

Source

pub async fn execute_quality_metrics( &self, input: QualityMetricsInput, ) -> Result<Value>

Execute the quality_metrics tool

§Arguments
  • input - Quality metrics input parameters
§Returns

Returns quality metrics and noise reduction statistics

Source§

impl MemoryMCPServer

Source

pub async fn list_tools(&self) -> Vec<Tool>

List all available tools

Returns tools based on progressive disclosure - commonly used tools are returned first, advanced tools are shown after usage patterns indicate need.

With lazy loading, this initially returns only core tools to significantly reduce input token usage. Extended tools are loaded on-demand.

Source

pub async fn get_tool(&self, name: &str) -> Option<Tool>

Get a specific tool by name

Loads the tool on-demand from the registry if not already loaded.

Source

pub async fn query_memory( &self, query: String, domain: String, task_type: Option<String>, limit: usize, sort: String, fields: Option<Vec<String>>, ) -> Result<Value>

Execute the query_memory tool

§Arguments
  • query - Search query
  • domain - Task domain
  • task_type - Optional task type filter
  • limit - Maximum results to return
  • sort - Sort order (relevance, newest, oldest, duration, success)
§Returns

Returns a JSON array of relevant episodes

§Field Selection

Clients can request specific fields using the fields parameter:

{
  "query": "test",
  "domain": "web-api",
  "fields": ["episodes.id", "episodes.task_description", "patterns.success_rate"]
}
Source

pub async fn analyze_patterns( &self, task_type: String, min_success_rate: f32, limit: usize, fields: Option<Vec<String>>, ) -> Result<Value>

Execute the analyze_patterns tool

§Arguments
  • task_type - Type of task to analyze
  • min_success_rate - Minimum success rate filter
  • limit - Maximum patterns to return
§Returns

Returns a JSON array of patterns with statistics

§Field Selection

Clients can request specific fields:

{
  "task_type": "code_generation",
  "fields": ["patterns.tool_sequence", "statistics.most_common_tools"]
}
Source

pub async fn get_episodes_by_ids( &self, episode_ids: &[Uuid], ) -> Result<Vec<Episode>>

Execute the bulk_episodes tool

§Arguments
  • episode_ids - List of episode UUIDs to retrieve
§Returns

Returns a result with requested count, found count, and episodes

Source§

impl MemoryMCPServer

Source

pub async fn execute_configure_embeddings( &self, input: ConfigureEmbeddingsInput, ) -> Result<Value>

Execute the configure_embeddings tool

§Arguments
  • input - Configuration parameters for the embedding provider
§Returns

Returns configuration result with provider details

Source§

impl MemoryMCPServer

Source

pub async fn execute_generate_embedding( &self, input: GenerateEmbeddingInput, ) -> Result<Value>

Execute the generate_embedding tool

§Arguments
  • input - Parameters for embedding generation
§Returns

Returns the generated embedding vector with metadata

Source§

impl MemoryMCPServer

Source

pub async fn execute_query_semantic_memory( &self, input: QuerySemanticMemoryInput, ) -> Result<Value>

Execute the query_semantic_memory tool

§Arguments
  • input - Semantic query parameters
§Returns

Returns semantic search results with similarity scores

Source§

impl MemoryMCPServer

Source

pub async fn execute_search_by_embedding( &self, input: SearchByEmbeddingInput, ) -> Result<Value>

Execute the search_by_embedding tool

§Arguments
  • input - Parameters for embedding search
§Returns

Returns episodes similar to the provided embedding vector

Source§

impl MemoryMCPServer

Source

pub async fn execute_embedding_provider_status_tool( &self, input: EmbeddingProviderStatusInput, ) -> Result<Value>

Execute the embedding_provider_status tool

§Arguments
  • input - Parameters for status check
§Returns

Returns detailed status information about the embedding provider

Source§

impl MemoryMCPServer

Source

pub async fn execute_test_embeddings(&self) -> Result<Value>

Execute the test_embeddings tool

§Returns

Returns embedding provider test results

Source§

impl MemoryMCPServer

Source

pub async fn complete_episode_tool(&self, args: Value) -> Result<Value>

Complete an episode with an outcome

This tool finalizes an episode by recording the outcome and triggering the learning cycle (reward calculation, reflection, pattern extraction).

§Arguments (from JSON)
  • episode_id - UUID of the episode to complete
  • outcome_type - Type of outcome (“success”, “partial_success”, “failure”)
  • verdict - Description of the outcome (required for success/partial)
  • artifacts - Array of artifact names (optional, for success)
  • completed - Array of completed items (required for partial_success)
  • failed - Array of failed items (required for partial_success)
  • reason - Failure reason (required for failure)
  • error_details - Detailed error information (optional, for failure)
Source§

impl MemoryMCPServer

Source

pub async fn create_episode_tool(&self, args: Value) -> Result<Value>

Create a new episode

This tool allows AI agents to programmatically create new episodes for tracking task execution through the MCP interface.

§Arguments (from JSON)
  • task_description - Clear description of the task
  • domain - Task domain (e.g., “web-api”, “cli”)
  • task_type - Type of task (e.g., “code_generation”, “debugging”)
  • language - Optional programming language
  • framework - Optional framework name
  • tags - Optional array of tags
  • complexity - Optional complexity level (“simple”, “moderate”, “complex”)
Source§

impl MemoryMCPServer

Source

pub async fn get_episode_tool(&self, args: Value) -> Result<Value>

Get episode details by ID

This tool retrieves complete details of an episode including all steps, outcome, reflection, and extracted patterns.

§Arguments (from JSON)
  • episode_id - UUID of the episode to retrieve
  • fields - Optional array of field paths to return (e.g., [“episode.id”, “episode.task_description”])
§Field Selection

Clients can request specific fields to reduce token usage:

{
  "episode_id": "123e4567-e89b-12d3-a456-426614174000",
  "fields": ["episode.id", "episode.task_description", "episode.outcome"]
}
Source

pub async fn delete_episode_tool(&self, args: Value) -> Result<Value>

Delete an episode permanently

This tool removes an episode from all storage backends. Warning: This operation cannot be undone.

§Arguments (from JSON)
  • episode_id - UUID of the episode to delete
  • confirm - Must be set to true to confirm deletion
Source§

impl MemoryMCPServer

Source

pub async fn add_episode_relationship_tool(&self, args: Value) -> Result<Value>

Add a relationship between two episodes

This tool creates a directed relationship from one episode to another with validation. Supports relationship types: parent_child, depends_on, follows, related_to, blocks, duplicates, references.

§Arguments (from JSON)
  • from_episode_id - Source episode UUID
  • to_episode_id - Target episode UUID
  • relationship_type - Type of relationship
  • reason - Optional explanation
  • priority - Optional priority (1-10)
  • created_by - Optional creator identifier
Source

pub async fn remove_episode_relationship_tool( &self, args: Value, ) -> Result<Value>

Remove a relationship by ID

This tool removes an existing episode relationship.

§Arguments (from JSON)
  • relationship_id - UUID of the relationship to remove
Source

pub async fn get_episode_relationships_tool(&self, args: Value) -> Result<Value>

Get relationships for an episode

This tool retrieves all relationships for a given episode with optional direction and type filtering.

§Arguments (from JSON)
  • episode_id - Episode UUID to query
  • direction - Optional direction filter (“outgoing”, “incoming”, “both”)
  • relationship_type - Optional relationship type filter

Find episodes related to a given episode

This tool finds all episodes related to the specified episode with optional filtering by relationship type.

§Arguments (from JSON)
  • episode_id - Episode UUID to find relationships for
  • relationship_type - Optional relationship type filter
  • limit - Optional maximum number of results (default: 10)
  • include_metadata - Optional flag to include relationship metadata
Source

pub async fn check_relationship_exists_tool(&self, args: Value) -> Result<Value>

Check if a specific relationship exists

This tool checks whether a relationship of a specific type exists between two episodes.

§Arguments (from JSON)
  • from_episode_id - Source episode UUID
  • to_episode_id - Target episode UUID
  • relationship_type - Type of relationship to check
Source

pub async fn get_dependency_graph_tool(&self, args: Value) -> Result<Value>

Get dependency graph for visualization

This tool builds a relationship graph starting from an episode up to a specified depth, optionally in DOT format for visualization.

§Arguments (from JSON)
  • episode_id - Root episode UUID
  • depth - Optional maximum traversal depth (1-5, default: 2)
  • format - Optional output format (“json” or “dot”, default: “json”)
Source

pub async fn validate_no_cycles_tool(&self, args: Value) -> Result<Value>

Validate that adding a relationship would not create a cycle

This tool checks if adding a relationship between two episodes would create a cycle in the dependency graph. Returns whether a cycle would be created and the cycle path if detected.

§Arguments (from JSON)
  • from_episode_id - Source episode UUID (proposed from)
  • to_episode_id - Target episode UUID (proposed to)
  • relationship_type - Type of relationship being added
Source

pub async fn get_topological_order_tool(&self, args: Value) -> Result<Value>

Get topological ordering of episodes

This tool returns episodes in topological order where dependencies come before dependents. Only works on directed acyclic graphs (DAGs).

§Arguments (from JSON)
  • episode_ids - Array of episode UUIDs to sort
Source§

impl MemoryMCPServer

Source

pub async fn add_episode_step_tool(&self, args: Value) -> Result<Value>

Add a step to an existing episode

This tool allows logging execution steps to track progress within an episode.

§Arguments (from JSON)
  • episode_id - UUID of the episode
  • step_number - Sequential step number
  • tool - Name of the tool/component performing the action
  • action - Description of the action taken
  • parameters - Optional JSON object of parameters
  • result - Optional result object with type and details
  • latency_ms - Optional execution time in milliseconds
Source§

impl MemoryMCPServer

Source

pub async fn get_episode_timeline_tool(&self, args: Value) -> Result<Value>

Get a timeline view of episode execution

This tool provides a chronological view of all steps in an episode, useful for visualizing task progression.

§Arguments (from JSON)
  • episode_id - UUID of the episode
Source§

impl MemoryMCPServer

Source

pub async fn update_episode_tool(&self, args: Value) -> Result<Value>

Update an existing episode with new information

This tool allows AI agents to programmatically update episodes to modify descriptions, tags, and metadata.

§Arguments (from JSON)
  • episode_id - UUID of the episode to update
  • description - Optional new task description
  • add_tags - Optional tags to add to the episode
  • remove_tags - Optional tags to remove from the episode
  • set_tags - Optional tags to replace all existing tags
  • metadata - Optional metadata key-value pairs to merge
Source§

impl MemoryMCPServer

Source

pub async fn execute_configure_agentfs( &self, input: ConfigureAgentFsInput, ) -> Result<Value>

Execute the configure_agentfs tool

§Arguments
  • input - Configuration parameters for the AgentFS provider
§Returns

Returns configuration result with provider details

Source§

impl MemoryMCPServer

Source

pub async fn execute_external_signal_status( &self, input: ExternalSignalStatusInput, ) -> Result<Value>

Execute the external_signal_status tool

§Arguments
  • input - Parameters for status check (provider filter)
§Returns

Returns detailed status information about configured external signal providers

Source§

impl MemoryMCPServer

Source

pub async fn execute_test_agentfs_connection( &self, input: TestAgentFsConnectionInput, ) -> Result<Value>

Execute the test_agentfs_connection tool

§Arguments
  • input - Test parameters including optional db_path override
§Returns

Returns connection test results indicating SDK unavailability

Source§

impl MemoryMCPServer

Source

pub async fn get_stats(&self) -> ExecutionStats

Get execution statistics

Source

pub async fn get_tool_usage(&self) -> HashMap<String, usize>

Get tool usage statistics

Source

pub async fn add_tool(&self, tool: Tool) -> Result<()>

Add a custom tool to the server

Source

pub async fn remove_tool(&self, tool_name: &str) -> Result<()>

Remove a tool from the server

Source

pub fn monitoring_endpoints(&self) -> Arc<MonitoringEndpoints>

Get monitoring endpoints

Source

pub fn monitoring_system(&self) -> Arc<MonitoringSystem>

Get monitoring system

Source

pub async fn update_system_metrics(&self)

Update system metrics (memory, CPU)

Source§

impl MemoryMCPServer

Source

pub async fn health_check(&self) -> Result<Value>

Execute the health_check tool

§Returns

Returns health check results

Source

pub async fn get_metrics(&self, metric_type: Option<String>) -> Result<Value>

Execute the get_metrics tool

§Arguments
  • metric_type - Type of metrics to retrieve
§Returns

Returns monitoring metrics

Source§

impl MemoryMCPServer

Source

pub async fn execute_search_patterns( &self, input: SearchPatternsInput, ) -> Result<Value>

Execute search_patterns tool

Source

pub async fn execute_recommend_patterns( &self, input: RecommendPatternsInput, ) -> Result<Value>

Execute recommend_patterns tool

Source§

impl MemoryMCPServer

Source

pub async fn new( _config: SandboxConfig, memory: Arc<SelfLearningMemory>, ) -> Result<Self>

Create a new MCP server

§Arguments
  • config - Sandbox configuration (kept for API compatibility)
  • memory - Self-learning memory system
§Returns

Returns a new MemoryMCPServer instance

Source

pub fn memory(&self) -> Arc<SelfLearningMemory>

Get a reference to the memory system

§Returns

Returns a clone of the Arc<SelfLearningMemory>

Source

pub fn audit_logger(&self) -> Arc<AuditLogger>

Get a reference to the audit logger

§Returns

Returns a clone of the Arc<AuditLogger>

Source

pub fn rate_limiter(&self) -> &RateLimiter

Get a reference to the rate limiter

§Returns

Returns a reference to the RateLimiter

Source

pub fn client_id_from_args(&self, args: &Value) -> ClientId

Extract client ID from tool arguments

§Arguments
  • args - Tool arguments JSON value
§Returns

Returns a ClientId for rate limiting

Source

pub fn check_rate_limit( &self, client_id: &ClientId, operation: OperationType, ) -> RateLimitResult

Check rate limit for a client

§Arguments
  • client_id - Client identifier
  • operation - Type of operation (read or write)
§Returns

Returns the rate limit check result

Source

pub fn rate_limit_headers( &self, result: &RateLimitResult, ) -> Vec<(String, String)>

Get rate limit headers for a response

§Arguments
  • result - Rate limit check result
§Returns

Returns vector of rate limit header tuples

Source

pub fn rate_limited_headers( &self, result: &RateLimitResult, ) -> Vec<(String, String)>

Get rate limit headers for a rate-limited response

§Arguments
  • result - Rate limit check result
§Returns

Returns vector of rate limit header tuples including Retry-After

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> SendAlias for T

Source§

impl<T> SendAlias for T

Source§

impl<T> SyncAlias for T

Source§

impl<T> SyncAlias for T