Skip to main content

Module tools

Module tools 

Source
Expand description

In-process helper functions for memory-oriented operations.

These helpers are convenient for Rust callers embedding rust-memex directly. The authoritative MCP tool contract exposed over stdio and HTTP/SSE comes from tool_definitions(), which mirrors the shared runtime surface instead of maintaining a second, drifting schema list here.

§Example

use rust_memex::{MemexEngine, MemexConfig};
use rust_memex::tools::{store_document, search_documents, tool_definitions, ToolResult};
use serde_json::json;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let engine = MemexEngine::for_app("my-app", "documents").await?;

    // Store a document using the local helper API
    let result = store_document(
        &engine,
        "doc-1".to_string(),
        "Important patient notes about feline diabetes".to_string(),
        json!({"patient_id": "P-123", "doc_type": "notes"}),
    ).await?;
    assert!(result.success);

    // Search for documents
    let results = search_documents(&engine, "diabetes".to_string(), 5, None).await?;
    println!("Found {} documents", results.len());

    // Get the canonical MCP tool definitions exposed by rust-memex
    let tools = tool_definitions();
    println!("Available tools: {:?}", tools.iter().map(|t| &t.name).collect::<Vec<_>>());

    Ok(())
}

Structs§

ToolDefinition
MCP tool definition schema.
ToolResult
Result type for tool operations.

Functions§

delete_document
Delete a document by ID.
delete_documents_by_filter
Delete all documents matching a metadata filter.
get_document
Get a document by ID.
search_documents
Search memory semantically using vector similarity.
store_document
Store text in memory with automatic embedding generation.
store_documents_batch
Batch store multiple documents efficiently.
tool_definitions
Get the canonical MCP tool definitions exposed by rust-memex transports.