recall
CLAUDE.md174 starsChanged 11 months agoMITView on GitHub
Recall is an MCP (Model Context Protocol) server providing long-term memory for Claude conversations. It stores context in Redis or Valkey with semantic search capabilities to survive context window limitations. Key Principle: This server IS the solution to context loss - treat it with care and always maintain backward compatibility.
- Reads credentials
- Sends data out
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
21 rules. About 0 are common, 6 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 225
Add Zod schema to types.ts
- Very specific: line 226
Add method to MemoryStore in persistence/memory-store.ts
- Very specific: line 227
Add tool handler to tools/index.ts or create new tool file
- Very specific: line 235
Add types to types.ts
- Very specific: line 236
Create/update service in services/ (e.g., rlm.service.ts)
- Very specific: line 237
Write tests: *.test.ts alongside the service
- Very specific: line 238
Create thin tool handlers in tools/rlm-tools.ts
- Very specific: line 242
Add route in http/server.ts
- Very specific: line 243
Add types to http/types.ts
- Very specific: line 244
Create service file if complex (e.g., billing.service.ts, team.service.ts)
- Very specific: line 245
Use AuthenticatedRequest for tenant-scoped endpoints
- Distinctive: line 249
Create provider in embeddings/providers/
- Distinctive: line 252
Add env var documentation
- Very specific: line 256
CRITICAL: If changing MemoryStore methods:
- Distinctive: line 258
Ensure index updates are atomic (use pipelines)
- Distinctive: line 259
Test with existing Redis data
- Very specific: line 268
ESM Modules: Use .js extensions in imports (even for .ts files)
- Very specific: line 271
Error Handling: Use MCP error codes (ErrorCode.InvalidRequest, ErrorCode.InternalError)
- Distinctive: line 321
Check embedding provider API key validity
- Very specific: line 322
Check Redis connection: redis-cli KEYS memory:*
- Distinctive: line 324
Check Claude Desktop logs for errors
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Context
Recall is an MCP (Model Context Protocol) server providing long-term memory for Claude conversations. It stores context in Redis or Valkey with semantic search capabilities to survive context window limitations.
Key Principle: This server IS the solution to context loss - treat it with care and always maintain backward compatibility.
Build & Run Commands
npm run build # Production build (tsup)
npm run dev # Watch mode for development
npm run start # Run MCP server (stdio transport)
npm run start:http # Run HTTP server (for SaaS deployment)Testing
# Unit tests with vitest (primary test runner)
npm test # Run all tests once
npm run test:watch # Watch mode
npm run test:coverage # With coverage report
# Run specific test file
npx vitest run src/services/rlm.service.test.ts
# Static checks (fast, no dependencies)
./tests/test-v1.5.0-simple.sh
# Runtime tests (requires Redis)
ANTHROPIC_API_KEY="test-key" node tests/test-runtime.jsManual Testing
# Start Redis
redis-server
# Run MCP server manually
REDIS_URL=redis://localhost:6379 ANTHROPIC_API_KEY=sk-... node dist/index.js
# Run HTTP server for SaaS testing
REDIS_URL=redis://localhost:6379 STRIPE_SECRET_KEY=sk_test_... node dist/server-http.js
# Test Redis connection
redis-cli ping # Should return PONG
redis-cli KEYS memory:*Architecture Overview
Entry Points
- index.ts - MCP server (stdio transport) - use for Claude Desktop/Claude Code
- server-http.ts - HTTP server for SaaS deployment (recallmcp.com)
Core Components
src/
├── index.ts # MCP server entry (stdio)
├── server-http.ts # HTTP server entry (SaaS)
├── types.ts # Zod schemas, TypeScript types
├── persistence/ # Storage layer (abstracted)
│ ├── storage-client.interface.ts # Interface for storage adapters
│ ├── storage-client.factory.ts # Creates Redis or Valkey adapter
│ ├── storage-client.ts # Storage client singleton
│ ├── memory-store.ts # Core memory CRUD operations
│ ├── redis-client.ts / redis-adapter.ts
│ └── valkey-client.ts / valkey-adapter.ts
├── embeddings/ # Multi-provider embedding system
│ ├── factory.ts # Auto-detects provider from API keys
│ ├── generator.ts # Embedding generation orchestration
│ ├── types.ts # Provider interface
│ └── providers/ # Provider implementations
│ ├── voyage-provider.ts # Voyage AI (best quality)
│ ├── cohere-provider.ts # Cohere (multilingual)
│ ├── openai-compatible-provider.ts # OpenAI/Deepseek/Grok
│ ├── anthropic-provider.ts # Anthropic (keyword fallback)
│ └── ollama-provider.ts # Local Ollama
├── services/ # Business logic services
│ └── rlm.service.ts # RLM (Recursive Language Model) for large context
├── tools/ # MCP tool handlers
│ ├── index.ts # Core tools (store, search, delete)
│ ├── context-tools.ts # Smart context (recall, analyze, summarize)
│ ├── rlm-tools.ts # RLM tools (create_execution_context, decompose, etc.)
│ ├── relationship-tools.ts # Memory linking/graphs
│ ├── version-tools.ts # Version history/rollback
│ ├── template-tools.ts # Memory templates
│ ├── category-tools.ts # Category management
│ └── export-import-tools.ts # Backup/restore
├── resources/ # MCP resource handlers
├── prompts/ # MCP prompt handlers
├── analysis/ # Claude-powered conversation analysis
└── http/ # HTTP/SaaS infrastructure
├── server.ts # Express server setup
├── mcp-handler.ts # MCP-over-HTTP with session management
├── auth.middleware.ts # API key authentication + tenant isolation
├── billing.service.ts # Stripe subscription management
├── workspace.service.ts # Workspace limit enforcement
├── team.service.ts # Team/organization management
├── oauth.service.ts # OAuth flow for Claude Desktop
├── audit.service.ts # API usage auditing
├── firebase-admin.ts # Firebase auth integration
└── types.ts # HTTP-specific types (TenantContext, etc.)RLM (Recursive Language Model) System
For processing content larger than context windows (~100KB+):
- create_execution_context - Store large content, get processing strategy
- decompose_task - Break into subtasks (filter/chunk/recursive/aggregate)
- inject_context_snippet - Extract relevant portions for each subtask
- update_subtask_result - Store results as you process
- merge_results - Combine all subtask results
- verify_answer - Cross-check against source context
HTTP/SaaS Multi-Tenant Architecture
Each API key creates an isolated tenant with:
- Scoped Redis key prefix:
tenant:{tenantId}:workspace:{workspaceId}:memory:* - Session-based MCP server instances (30min timeout)
- Plan-based limits (free: 500 memories, pro: 5000, team: 25000)
- Workspace isolation per project directory
Embedding Provider System
The embedding factory auto-detects providers based on available API keys:
Priority order (best quality first):
- Voyage AI (
VOYAGE_API_KEY) - Premium retrieval quality - Cohere (
COHERE_API_KEY) - Multilingual, high MTEB - OpenAI (
OPENAI_API_KEY) - Standard, widely adopted - Deepseek (
DEEPSEEK_API_KEY) - Standard - Grok (
GROK_API_KEY) - Standard - Anthropic (
ANTHROPIC_API_KEY) - Fallback (keyword-based) - Ollama (
OLLAMA_BASE_URL) - Local inference
Force a specific provider with EMBEDDING_PROVIDER=voyage|cohere|openai|anthropic|etc
Key Environment Variables
Core
| Variable | Purpose | Default |
REDIS_URL | Redis connection string | redis://localhost:6379 |
BACKEND_TYPE | redis or valkey | redis |
VALKEY_HOST / VALKEY_PORT | Valkey connection | localhost:6379 |
EMBEDDING_PROVIDER | Force specific embedding provider | auto-detect |
WORKSPACE_MODE | isolated, global, or hybrid | isolated |
PORT | HTTP server port (for SaaS) | 8080 |
SaaS/HTTP Server
| Variable | Purpose |
STRIPE_SECRET_KEY | Stripe API key for billing |
STRIPE_WEBHOOK_SECRET | Stripe webhook signature verification |
STRIPE_PRICE_PRO / STRIPE_PRICE_TEAM | Stripe price IDs |
GOOGLE_APPLICATION_CREDENTIALS | Firebase service account JSON path |
FIREBASE_PROJECT_ID | Firebase project for OAuth |
Critical Constraints (Do Not Break)
Immutable Schema Patterns
Redis key patterns - changing these requires migration:
# Self-hosted (stdio transport)
memory:{id} → Hash
memories:all → Set
memories:timeline → Sorted Set (score = timestamp)
memories:type:{type} → Set
memories:tag:{tag} → Set
memories:important → Sorted Set (score = importance ≥8)
session:{id} → Hash
sessions:all → Set
# SaaS (HTTP transport) - tenant-scoped
tenant:{tenantId}:workspace:{workspaceId}:memory:{id}
tenant:{tenantId}:apikeys → Set of API key records
tenant:{tenantId}:customer → Stripe customer record
rlm:chain:{chainId} → RLM execution chain stateContext Types (Never Remove)
These 10 types are core - removing breaks existing memories:
directive, information, heading, decision, code_pattern, requirement, error, todo, insight, preference
Adding new types is safe - edit types.ts.
Importance Scale
- 1-3: Low (transient)
- 4-7: Medium (general)
- 8-10: High (critical, auto-indexed in
memories:important)
Making Changes
Adding a New MCP Tool
- Add Zod schema to types.ts
- Add method to
MemoryStorein persistence/memory-store.ts - Add tool handler to tools/index.ts or create new tool file
- Register in http/mcp-handler.ts if using HTTP transport
- Update README.md
Adding RLM Tools (Complex Logic)
For tools requiring significant business logic, use the service pattern:
- Add types to types.ts
- Create/update service in services/ (e.g.,
rlm.service.ts) - Write tests:
*.test.tsalongside the service - Create thin tool handlers in tools/rlm-tools.ts
Adding HTTP Endpoints
- Add route in http/server.ts
- Add types to http/types.ts
- Create service file if complex (e.g.,
billing.service.ts,team.service.ts) - Use
AuthenticatedRequestfor tenant-scoped endpoints
Adding a New Embedding Provider
- Create provider in embeddings/providers/
- Implement
EmbeddingProviderinterface from embeddings/types.ts - Register in embeddings/factory.ts
- Add env var documentation
Modifying Storage Logic
CRITICAL: If changing MemoryStore methods:
- Ensure index updates are atomic (use pipelines)
- Test with existing Redis data
- Document migration path
- Bump version in package.json
Code Style
- TypeScript: Strict mode, full type safety
- ESM Modules: Use
.jsextensions in imports (even for.tsfiles) - Naming: camelCase for variables/functions, PascalCase for types/classes
- Files: kebab-case for filenames (e.g.,
memory-store.ts) - Error Handling: Use MCP error codes (
ErrorCode.InvalidRequest,ErrorCode.InternalError)
Memory Storage Best Practices
Store HIGH-SIGNAL context only:
- ✅ Decisions and reasoning ("Chose PostgreSQL because...")
- ✅ Preferences (coding style, architecture patterns)
- ✅ Constraints (API limits, security requirements)
- ✅ Learned patterns from bugs/solutions
Don't store LOW-SIGNAL content:
- ❌ Code implementations (put in files)
- ❌ General knowledge
- ❌ Temporary session context
- ❌ Duplicates of documentation
Debugging
MCP Server (stdio) Not Starting
redis-cli ping # Check Redis
echo $REDIS_URL # Check env vars
tail -f ~/Library/Logs/Claude/mcp*.log # Check MCP logsHTTP Server Issues
# Check if server is running
curl http://localhost:8080/health
# Test authentication
curl -H "Authorization: Bearer sk-recall-xxx" http://localhost:8080/api/stats
# Check MCP session
curl -X POST http://localhost:8080/mcp \
-H "Authorization: Bearer sk-recall-xxx" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'Memory Not Storing
- Check embedding provider API key validity
- Check Redis connection:
redis-cli KEYS memory:* - For SaaS: Check tenant key prefix
redis-cli KEYS tenant:* - Check Claude Desktop logs for errors
Version History
Current: 1.7.0
See CHANGELOG.md for detailed changes.
Semantic Versioning:
- Major: Breaking changes (schema, removed tools)
- Minor: New features (tools, providers, context types)
- Patch: Bug fixes, performance
Maintainer: José Airosa Repository: https://github.com/joseairosa/recall
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

