API Reference

Markdown

r3 v1.3.2 exposes 14 tools through the Model Context Protocol (MCP) over stdio.

MCP tool schemas (JSON) · Published source

Schema and transport

The machine-readable schema contains every tool name, description, annotation, and input schema from the published release. Connect an MCP client and call tools/list to read the definitions from your running server.

This release does not expose an HTTP REST API, so it has no OpenAPI document. The JSON schemas above describe MCP tool arguments. They are not an OpenAI API endpoint.

Use tools/call with a tool name and arguments. Your MCP client handles the JSON-RPC transport:

{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_memory",
"arguments": {
"query": "programming preferences",
"limit": 5
}
}
}

user_id selects a memory namespace. Its default comes from the server’s MEM0_USER_ID environment variable. The downloadable schema records the release default.

Tools overview

ToolPurpose
add_memoryStore a new memory with automatic deduplication and indexing.
get_memoryRetrieve a single memory by its unique ID.
update_memoryModify an existing memory's content or metadata.
search_memoryFind memories matching a natural language query using hybrid semantic + keyword search.
get_all_memoriesList all memories for a user with pagination.
delete_memoryPermanently remove a memory by ID.
deduplicate_memoriesDetect and optionally remove duplicate memories using content similarity.
optimize_cacheReorganize cache for optimal hit rates.
cache_statsView cache performance metrics and health status.
sync_statusCheck background job queue and sync status.
extract_entitiesExtract named entities and relationships from text using NLP.
get_knowledge_graphBuild a knowledge graph from stored memories.
find_connectionsDiscover relationship paths between entities in the knowledge graph.
import_memoriesBulk import memories from external sources.

add_memory

Store a new memory with automatic deduplication and indexing. Use for persisting facts, preferences, or conversation context. Checks for duplicates by default (85% similarity threshold). Returns immediately; background processing handles indexing. Prefer over update_memory for new content. Returns: confirmation text. Side effects: creates memory record, updates search index, may skip if duplicate detected.

ArgumentTypeRequiredDescription
messagesarrayNoConversation messages to store. Use instead of content for multi-turn context. Each message needs role and content fields.
contentstringNoPlain text content to store. Use instead of messages for simple facts. Either content or messages required, not both.
user_idstringNoUser namespace for memory isolation. Default: "oliver". Use consistent IDs to retrieve related memories.
metadataobjectNoKey-value pairs for categorization (e.g., {category: 'preferences', source: 'onboarding'}). Searchable via search_memory.
prioritystringNoCache priority. high: immediate L1 cache (24h TTL). medium: standard processing. low: L2 cache (7d TTL). Default: medium. Values: high, medium, low.
asyncbooleanNoEnable background processing. true: returns immediately, indexes async. false: blocks until complete. Default: true.
skip_duplicate_checkbooleanNoBypass duplicate detection. Use only when intentionally storing similar content. Default: false.

get_memory

Retrieve a single memory by its unique ID. Use when you have a specific memory_id from prior search/list results. Returns null if not found. Prefer search_memory for content-based lookup. Read-only operation. Returns: Memory object {id, content, user_id, metadata} or null.

ArgumentTypeRequiredDescription
memory_idstringYesUnique identifier of the memory to retrieve. Obtained from add_memory response, search_memory results, or get_all_memories.
user_idstringNoUser namespace. Must match the user_id used when memory was created. Default: "oliver".

update_memory

Modify an existing memory's content or metadata. Use for corrections or adding context to existing memories. Fails if memory_id not found. Prefer add_memory for new content. Invalidates search cache. Returns: updated Memory object. Side effects: modifies memory record, invalidates cached search results.

ArgumentTypeRequiredDescription
memory_idstringYesUnique identifier of the memory to update. Must exist or operation fails with error.
contentstringNoNew content to replace existing. Omit to keep current content unchanged.
metadataobjectNoMetadata fields to merge. Existing fields not specified are preserved. Pass null value to remove a field.
user_idstringNoUser namespace. Must match original. Default: "oliver".

search_memory

Find memories matching a natural language query using hybrid semantic + keyword search. Primary retrieval tool for content-based lookup. Uses vector similarity (enhanced mode) or keyword matching (basic mode). Cache-first by default for speed. Returns ranked results with relevance scores. Read-only. Returns: array of Memory objects or 'No memories found' text.

ArgumentTypeRequiredDescription
querystringYesNatural language search query. Supports keywords, phrases, or questions. More specific queries yield better relevance ranking.
user_idstringNoUser namespace to search within. Default: "oliver".
limitnumberNoMaximum results to return. Range: 1-100. Higher values increase latency. Default: 10.
prefer_cachebooleanNotrue: check cache first, fall back to storage. false: query storage directly, then cache results. Default: true.

get_all_memories

List all memories for a user with pagination. Use for browsing or bulk operations. For content search, use search_memory instead. Cache-first by default. Large result sets are automatically truncated. Read-only. Returns: {total, limit, offset, returned, hasMore, source, memories[]}.

ArgumentTypeRequiredDescription
user_idstringNoUser namespace to list. Default: "oliver".
limitnumberNoMaximum memories per page. Range: 1-500. Default: 100. Use with offset for pagination.
offsetnumberNoNumber of memories to skip. Use for pagination: page N = offset (N-1)*limit. Default: 0.
include_cache_statsbooleanNoAppend cache statistics to response. Useful for monitoring. Default: true.
prefer_cachebooleanNotrue: return cached memories (faster). false: fetch from storage (fresher). Default: true.

delete_memory

Permanently remove a memory by ID. Irreversible operation. Removes from storage, cache, and search index. Use deduplicate_memories with dry_run first to preview bulk deletions. Returns: confirmation text. Side effects: deletes memory record, removes from all indexes, invalidates cache.

ArgumentTypeRequiredDescription
memory_idstringYesUnique identifier of memory to delete. Obtain from search_memory or get_all_memories. Operation succeeds even if ID not found.

deduplicate_memories

Detect and optionally remove duplicate memories using content similarity. Run with dry_run=true first to preview. Compares all memories pairwise using Jaccard similarity. Groups duplicates with a primary (oldest) and candidates for removal. Returns: summary with duplicate groups. Side effects (when dry_run=false): deletes duplicate memories, invalidates cache.

ArgumentTypeRequiredDescription
user_idstringNoUser namespace to deduplicate. Default: "oliver".
similarity_thresholdnumberNoMinimum similarity (0-1) to consider as duplicate. 0.85 = 85% similar. Higher = stricter. Range: 0.5-1.0. Default: 0.85.
dry_runbooleanNotrue: preview duplicates without deletion (safe). false: actually delete duplicates (destructive). Default: true.

optimize_cache

Reorganize cache for optimal hit rates. Promotes frequently accessed memories to L1 (24h TTL), demotes cold data to L2 (7d TTL). Use periodically for large memory stores. May temporarily increase latency during optimization. Returns: summary of cached memories. Side effects: modifies cache TTLs, may evict old entries.

ArgumentTypeRequiredDescription
force_refreshbooleanNotrue: clear cache and reload all from storage. false: optimize existing cache. Default: false.
max_memoriesnumberNoMaximum memories to keep in cache. Range: 100-10000. Older/colder items evicted first. Default: 1000.

cache_stats

View cache performance metrics and health status. Use for monitoring and debugging. Shows memory count, access patterns, and hit rates. Read-only. Returns: summary text with cached memory count. No side effects.

No arguments required.

sync_status

Check background job queue and sync status. Shows pending async operations from add_memory calls. Use to verify all writes completed. Read-only. Returns: count of pending operations or 'All operations complete'. No side effects.

No arguments required.

extract_entities

Extract named entities and relationships from text using NLP. Identifies people, organizations, technologies, and projects. Also extracts relationships (WORKS_FOR, USES, etc.) and keywords. Requires enhanced intelligence mode. Read-only, stateless. Returns: {people[], organizations[], technologies[], projects[], relationships[], keywords[]}.

ArgumentTypeRequiredDescription
textstringYesInput text to analyze. Longer text yields more entities. Supports natural language, code comments, or structured text.

get_knowledge_graph

Build a knowledge graph from stored memories. Returns entities as nodes and relationships as edges. Use for visualizing connections between concepts. Requires enhanced intelligence mode with prior entity extraction. Read-only. Returns: {nodes[], edges[]} where nodes have {id, type, name, memories[]} and edges have {from, to, type, confidence}.

ArgumentTypeRequiredDescription
entity_typestringNoFilter nodes by type: 'people', 'organizations', 'technologies', or 'projects'. Omit for all types.
entity_namestringNoFilter nodes containing this name (case-insensitive substring match). Omit for all entities.
relationship_typestringNoFilter edges by relationship: 'WORKS_FOR', 'USES', 'BUILT_WITH', 'KNOWS', etc. Omit for all relationships.
limitnumberNoMaximum nodes to return. Range: 1-100. Default: 20. Edges limited proportionally.

find_connections

Discover relationship paths between entities in the knowledge graph. Uses BFS traversal to find how entities connect. Useful for answering 'how is X related to Y?' questions. Requires enhanced mode. Read-only. Returns: {from, to, max_depth, paths_found, paths[]} where each path is array of {from, to, type} edges.

ArgumentTypeRequiredDescription
from_entitystringYesStarting entity name for path search. Must match an entity in the knowledge graph exactly.
to_entitystringNoTarget entity name. If omitted, returns all reachable entities up to max_depth.
max_depthnumberNoMaximum relationship hops to traverse. Range: 1-5. Higher values exponentially increase results. Default: 2.

import_memories

Bulk import memories from external sources. Supports Mem0 API export or local JSON files. Processes in batches with duplicate detection. Use for migration or backup restoration. Returns: summary with imported/skipped/failed counts. Side effects: creates multiple memory records, updates search index.

ArgumentTypeRequiredDescription
sourcestringYesImport source. 'mem0_api': fetch from Mem0 cloud (requires api_key). 'json_file': read local file (requires file_path). Values: mem0_api, json_file.
api_keystringNoMem0 API token for authentication. Required when source='mem0_api'. Get from https://mem0.ai dashboard.
user_idstringNoUser namespace for imported memories. Default: "oliver".
file_pathstringNoAbsolute path to JSON file. Required when source='json_file'. Must be array of memory objects or {memories: [...]}.
batch_sizenumberNoMemories per batch. Lower values are safer but slower. Range: 10-200. Default: 50.
prioritystringNoCache priority for all imported memories. Default: high (L1 cache). Values: high, medium, low.
skip_duplicatesbooleanNoCheck each memory for duplicates before import. Slower but prevents bloat. Default: true.

Search docs

Answers use the published r3 docs.

Loading documentation…