Build a production-quality MCP server that any AI agent (Claude, GPT, Cursor, etc.) would love to use as persistent cognitive memory. This is the #1 adoption driver — if the MCP experience is great, people will install it from the HN post on Tuesday.
src/yantrikdb/mcp/— Python MCP server using FastMCPserver.py— lifespan context, YantrikDB + sentence-transformers inittools.py— 10 tools: remember, recall, relate, entities, beliefs, conflicts, patterns, consolidate, forget, statsresources.py— MCP resources
- Install:
pip install yantrikdb[mcp]thenyantrikdb-mcpcommand - Config: env vars
YANTRIKDB_DB_PATH,YANTRIKDB_EMBEDDING_MODEL,YANTRIKDB_EMBEDDING_DIM
- Basic remember/recall/relate flow
- Entity graph operations
- Consolidation, conflict detection, pattern mining via
think() - Runs as stdio MCP server
-
Tool descriptions are too terse — agents don't know when to call each tool. Need rich descriptions with examples that guide auto-pilot behavior (like the instructions block in Claude Code's yantrikdb server config).
-
No server instructions — MCP servers can provide instructions that get injected into the agent's system prompt. This is where we tell the agent "auto-recall at conversation start, auto-remember when you learn something important." Currently this is done via manual config in
.claude/mcp.json— should be built into the server. -
Missing tools:
think— run full cognition loop (consolidation + conflicts + patterns + triggers)correct— user correction flow (tombstone old memory, create corrected one)search_entities— search entities by name patternget_memory— get a specific memory by IDupdate_importance— adjust importance of existing memorybulk_remember— store multiple memories at once (efficient for conversation summaries)
-
recall is too basic — needs filters: by domain, source, memory_type, time_window. The Rust engine supports all of these via RecallQuery builder but the MCP tool doesn't expose them.
-
No streaming — for large recall results, should support pagination or streaming.
-
Startup is slow — sentence-transformers model download on first run. Need a progress indicator or pre-download step.
-
No health check — agents can't verify the server is working before relying on it.
- Current:
all-MiniLM-L6-v2(384 dims, ~80MB, good quality) - Consider: making it configurable, supporting OpenAI embeddings as alternative
- First-run experience matters — downloading 80MB silently is bad UX
- Current:
~/.yantrikdb/memory.db - Should support per-project databases (workspace-scoped memory)
- Consider:
YANTRIKDB_DB_PATHenv var already works, but add auto-detection of project root
The MCP spec allows servers to provide instructions. These should include:
- Auto-recall behavior (when to search memory)
- Auto-remember behavior (what to store)
- Auto-relate behavior (when to create entity links)
- What NOT to remember (ephemeral stuff, code, git history)
src/yantrikdb/mcp/
├── __init__.py — main() entry point
├── server.py — FastMCP server + lifespan
├── tools.py — tool definitions
└── resources.py — MCP resources
src/yantrikdb/
├── __init__.py — YantrikDB class (Rust bindings)
├── consolidate.py — consolidation logic
├── triggers.py — trigger evaluation
├── cli.py — CLI commands
└── api.py — REST API server
RecallQuerybuilder: top_k, memory_type, namespace, time_window, domain, source, expand_entitiesthink()with full ThinkConfig- Conflict resolution with strategies (keep_a, keep_b, merge, ask_user)
- Pattern mining with configurable thresholds
- Personality profile extraction
- Spaced repetition reinforcement on access
- Batch record operations
- Replication/sync (CRDT-based)
pip install yantrikdb[mcp]→ add 3 lines to mcp.json → agent has persistent memory- Agent auto-recalls relevant context at conversation start without being told
- Agent auto-remembers decisions, preferences, corrections without being told
- Agent detects and surfaces contradictions naturally
- Works with Claude Code, Cursor, Windsurf, and any MCP client
- First-run takes < 30 seconds (model download + DB init)
- Memory persists across sessions, consolidates over time
- The agent experience is noticeably better than without YantrikDB
These work well and should be the basis for built-in server instructions:
YantrikDB is your persistent cognitive memory. Use it AUTOMATICALLY.
## Auto-recall (before responding)
- At conversation start, call `recall` with a summary of the user's first message
- When the user references past work, decisions, people, or preferences, call `recall`
## Auto-remember (during conversation)
Proactively call `remember` whenever you encounter:
- Decisions made, user preferences, people & relationships, project context, corrections, important facts
## Auto-relate (knowledge graph)
Call `relate` when you learn about entity relationships
## What NOT to remember
- Ephemeral task details, things derivable from code/git, verbatim code
## Memory quality
- Use specific, searchable text
- Set importance: 0.8-1.0 critical, 0.5-0.7 useful, 0.3-0.5 minor
- Set domain: "work", "preference", "architecture", "people", "infrastructure"