MCP Memory Tools: Store & Search
Set up HatiData's MCP server for Claude Desktop with persistent memory storage and semantic search across sessions.
What You'll Build
A complete MCP tool setup for Claude Desktop that enables persistent memory storage and semantic search.
Prerequisites
$hati init
$Claude Desktop installed
Architecture
┌──────────────┐ MCP ┌──────────────┐ ┌──────────────┐ │ Claude │──────▶│ HatiData │───▶│ Engine │ │ Desktop │ │ MCP Server │ │ + Vectors │ └──────────────┘ │ (5440) │ └──────────────┘ store_memory ──▶ SQL INSERT + embed ──▶ dual storage
Key Concepts
- ●MCP (Model Context Protocol): standard protocol for connecting AI assistants to tools — HatiData exposes 24 tools via MCP
- ●Dual storage: store_memory writes to both the SQL engine (queryable) and the vector index (searchable) simultaneously
- ●Agent state: key-value JSON storage for structured data like preferences and session context
- ●SQL power: advanced queries with GROUP BY, window functions, and CTEs available alongside semantic search
Step-by-Step Implementation
Configure MCP Server
Add HatiData as an MCP server in your Claude Desktop configuration.
{
"mcpServers": {
"hatidata": {
"command": "hati",
"args": ["mcp-server"],
"env": {
"HATIDATA_HOST": "localhost",
"HATIDATA_PORT": "5440"
}
}
}
}Save to: ~/Library/Application Support/Claude/claude_desktop_config.jsonNote: On macOS the config lives in ~/Library/Application Support/Claude/. On Linux, ~/.config/Claude/.
Store a Memory
Use the store_memory MCP tool to save information that persists across conversations.
# In Claude Desktop, say:
"Store a memory: My team uses Python 3.12 and deploys to AWS us-east-1"
# Claude calls the store_memory MCP tool:
# Tool: store_memory
# Arguments:
# content: "Team uses Python 3.12 and deploys to AWS us-east-1"
# namespace: "team-preferences"Memory stored successfully.
ID: mem_a1b2c3d4
Namespace: team-preferences
Embedding: generated (384 dimensions)Note: Memories are automatically embedded for semantic search. You can organize them by namespace.
Search Memories
Use semantic search to find relevant memories based on meaning, not just keywords.
# In Claude Desktop, say:
"What programming language does my team use?"
# Claude calls search_memory internally:
# Tool: search_memory
# Arguments:
# query: "programming language team uses"
# namespace: "team-preferences"
# limit: 5Found 1 relevant memory:
- "Team uses Python 3.12 and deploys to AWS us-east-1"
Similarity: 0.87 | Stored: 2 minutes agoNote: Semantic search finds memories by meaning. Asking about 'programming language' matches 'Python 3.12' even without exact keyword overlap.
Get and Set Agent State
Use agent state tools to persist structured data like preferences and session context.
# Store structured state
# Tool: set_agent_state
# Arguments:
# agent_id: "claude-desktop"
# key: "user_preferences"
# value: {"theme": "dark", "verbosity": "concise", "expertise": "senior"}
# Retrieve state in a new conversation
# Tool: get_agent_state
# Arguments:
# agent_id: "claude-desktop"
# key: "user_preferences"State saved: claude-desktop/user_preferences
# In next conversation:
Retrieved state: {"theme": "dark", "verbosity": "concise", "expertise": "senior"}Note: Agent state is key-value JSON — useful for preferences, session context, and configuration that should persist.
Query with SQL
Use the SQL query tool for advanced memory queries with filters and aggregations.
# In Claude Desktop, say:
"Show me all memories from the last week grouped by namespace"
# Claude calls the query tool:
# Tool: query
# Arguments:
# sql: "SELECT namespace, COUNT(*) as count,
# MAX(created_at) as latest
# FROM _hatidata_memory.memories
# WHERE created_at > NOW() - INTERVAL '7 days'
# GROUP BY namespace
# ORDER BY count DESC"namespace | count | latest
-------------------|-------|--------------------
team-preferences | 3 | 2026-02-28 14:30:00
project-notes | 7 | 2026-02-28 12:15:00
meeting-summaries | 2 | 2026-02-27 16:45:00Note: The full power of SQL is available for complex queries. HatiData's query engine supports window functions, CTEs, and aggregations.
Related Use Case
Operations
Customer Support
Agents That Remember Every Customer