API Reference

MCP tools available in r3.

Tools overview

r3 provides these tools to Antigravity CLI through the MCP protocol:

ToolDescriptionResponse time
add_memoryStore new informationUnder 10ms
search_memoryFind relevant memoriesUnder 5ms (cache)
get_all_memoriesList all memoriesUnder 50ms
update_memoryModify existing memoryUnder 10ms
delete_memoryRemove a memoryUnder 10ms
delete_all_memoriesClear all memoriesUnder 100ms
get_memory_historyView memory changesUnder 20ms
cache_statsGet performance metricsUnder 1ms
optimize_cacheReorganize cacheUnder 500ms
health_checkCheck system statusUnder 5ms

add_memory

Store new information in the memory system.

Parameters

ParameterTypeRequiredDescription
contentstringNo*Text content to remember
messagesarrayNo*Conversation messages to remember
user_idstringNoUser identifier (default: from env)
prioritystringNocritical, high, medium, low (default: medium)
metadataobjectNoAdditional context
asyncbooleanNoProcess in background (default: true)

*Either content or messages is required.

Example

json
{
"tool": "add_memory",
"parameters": {
"content": "User prefers dark mode and 14px font size",
"priority": "high",
"metadata": {
"category": "preferences",
"updated": "2024-01-15"
}
}
}

Response

json
{
"memory_id": "mem_abc123xyz",
"message": "Memory added successfully",
"cached": true
}

search_memory

Find memories using semantic search.

Parameters

ParameterTypeRequiredDescription
querystringYesSearch query
user_idstringNoFilter by user
limitnumberNoMax results (default: 10)
prefer_cachebooleanNoSkip cloud if in cache (default: true)
metadata_filterobjectNoFilter by metadata

Example

json
{
"tool": "search_memory",
"parameters": {
"query": "user preferences for UI",
"limit": 5,
"metadata_filter": {
"category": "preferences"
}
}
}

Response

json
{
"results": [
{
"memory": "User prefers dark mode and 14px font size",
"metadata": {
"category": "preferences",
"updated": "2024-01-15"
},
"score": 0.92,
"id": "mem_abc123xyz",
"created_at": "2024-01-15T10:30:00Z",
"user_id": "default"
}
],
"source": "cache"
}

get_all_memories

Retrieve all memories for a user.

Parameters

ParameterTypeRequiredDescription
user_idstringNoUser identifier (default: from env)

Example

json
{
"tool": "get_all_memories",
"parameters": {
"user_id": "sarah_chen"
}
}

Response

json
{
"memories": [
{
"id": "mem_abc123xyz",
"memory": "User prefers dark mode",
"hash": "a1b2c3d4",
"metadata": null,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z",
"user_id": "sarah_chen"
}
],
"source": "cache",
"count": 1
}

update_memory

Modify an existing memory.

Parameters

ParameterTypeRequiredDescription
memory_idstringYesMemory ID to update
contentstringYesNew content
metadataobjectNoNew metadata

Example

json
{
"tool": "update_memory",
"parameters": {
"memory_id": "mem_abc123xyz",
"content": "User strongly prefers dark mode",
"metadata": {
"emphasized": true
}
}
}

Response

json
{
"success": true,
"message": "Memory updated successfully"
}

delete_memory

Remove a specific memory.

Parameters

ParameterTypeRequiredDescription
memory_idstringYesMemory ID to delete

Example

json
{
"tool": "delete_memory",
"parameters": {
"memory_id": "mem_abc123xyz"
}
}

Response

json
{
"success": true,
"message": "Memory deleted successfully"
}

delete_all_memories

Clear all memories for a user.

Parameters

ParameterTypeRequiredDescription
user_idstringNoUser identifier (default: from env)

Example

json
{
"tool": "delete_all_memories",
"parameters": {
"user_id": "sarah_chen"
}
}

Response

json
{
"deleted": 42,
"message": "Deleted 42 memories"
}

get_memory_history

View the change history of a memory.

Parameters

ParameterTypeRequiredDescription
memory_idstringYesMemory ID

Example

json
{
"tool": "get_memory_history",
"parameters": {
"memory_id": "mem_abc123xyz"
}
}

Response

json
{
"history": [
{
"version": 1,
"content": "User prefers dark mode",
"timestamp": "2024-01-15T10:30:00Z",
"action": "created"
},
{
"version": 2,
"content": "User strongly prefers dark mode",
"timestamp": "2024-01-15T11:00:00Z",
"action": "updated"
}
],
"message": "Retrieved 2 history entries"
}

cache_stats

Get cache performance metrics.

Parameters

None

Example

json
{
"tool": "cache_stats",
"parameters": {}
}

Response

json
{
"hits": 1234,
"misses": 56,
"hit_rate": "95.7%",
"size": 789,
"max_size": 10000,
"memory_usage": "4.2MB",
"evictions": 12,
"avg_response_time": "3.2ms",
"connection_pool": {
"active": 2,
"idle": 8,
"waiting": 0
}
}

optimize_cache

Reorganize cache based on access patterns.

Parameters

ParameterTypeRequiredDescription
force_refreshbooleanNoForce refresh all entries (default: false)
max_memoriesnumberNoMax memories to optimize (default: 1000)

Example

json
{
"tool": "optimize_cache",
"parameters": {
"force_refresh": true,
"max_memories": 500
}
}

Response

json
{
"promoted": 45,
"demoted": 23,
"expired": 12,
"duration": "234ms",
"memory_freed": "1.2MB"
}

health_check

Check system component status.

Parameters

None

Example

json
{
"tool": "health_check",
"parameters": {}
}

Response

json
{
"redis": true,
"mem0": true,
"cache": {
"l1_size": 456,
"l2_size": 1234,
"hit_rate": "94.3%"
},
"uptime": "3d 14h 22m",
"memory": {
"used": "45.6MB",
"rss": "128MB"
}
}

Error responses

All tools can return errors:

json
{
"error": "Redis connection failed",
"code": "REDIS_CONNECTION_ERROR",
"details": {
"host": "localhost",
"port": 6379
}
}

Common error codes:

CodeDescription
REDIS_CONNECTION_ERRORCan't connect to Redis
MEM0_API_ERRORMem0 API request failed
INVALID_PARAMETERSMissing or invalid parameters
MEMORY_NOT_FOUNDMemory ID doesn't exist
RATE_LIMIT_EXCEEDEDToo many requests

Rate limits

  • Add operations: 100/minute
  • Search operations: 500/minute
  • Delete operations: 50/minute
  • Cache operations: No limit

Performance tips

  • Use priority levels - Mark important memories as high or critical
  • Enable async mode - For non-critical additions
  • Batch operations - Use messages array for conversations
  • Cache first - Set prefer_cache: true for searches
  • Optimize regularly - Run optimize_cache weekly