retavyn
Retavyn provides persistent memory for Claude, automatically storing and injecting memories across sessions to maintain context and recall past information.
README
<p align="center"> <img src="retavyn_avatar.png" width="180" alt="Retavyn mascot" /> </p>
<h1 align="center">retavyn</h1> <p align="center"><strong>Persistent memory for Claude across sessions.</strong></p>
<p align="center"> <img src="https://img.shields.io/badge/python-3.11+-4f8ef7?style=flat-square" alt="Python 3.11+" /> <img src="https://img.shields.io/badge/PostgreSQL-18-316192?style=flat-square&logo=postgresql&logoColor=white" alt="PostgreSQL 18" /> <img src="https://img.shields.io/badge/pgvector-semantic_search-7c6af7?style=flat-square" alt="pgvector" /> <img src="https://img.shields.io/badge/transport-stdio_%7C_HTTP%2FSSE-22c55e?style=flat-square" alt="stdio | HTTP/SSE" /> <img src="https://img.shields.io/badge/license-MIT-888890?style=flat-square" alt="MIT License" /> </p>
Every Claude session starts cold — no memory of what you worked on yesterday, what decisions you made, what you learned. Retavyn fixes that. It stores what matters and injects it back into Claude's context automatically at the start of every session.
You talk to Claude normally. It remembers.
Features
- Automatic context injection — a
SessionStarthook dumps all memories to a local cache and injects them into context before the first message - Hybrid search — full-text (
tsvector/tsquery) and semantic similarity (pgvector) combined for recall that works on exact words or general concepts - Two transport modes — stdio for Claude Code, HTTP/SSE for claude.ai remote access
- Category tagging — store memories with categories (
ci-cd,journal,project, etc.) for filtered recall - Bulk ingestion —
ingest_pathwalks a file or directory tree and stores each file as a memory, with automatic embedding backfill - Live cache refresh — a
PostToolUsehook refreshes the local cache immediately after everyremembercall - OAuth-secured remote access — custom OAuth 2.0 + JWT flow required by the MCP spec for HTTP transport, served behind a Cloudflare Tunnel
How it works
Retavyn runs as an MCP server alongside Claude. When a session starts, a hook fires automatically — it dumps all stored memories to a local cache file and injects them into Claude's context before the first message. A second hook refreshes that cache after every remember call, so new memories are available in the next session immediately.
Search is hybrid: full-text (tsvector/tsquery) for exact matches and semantic similarity (pgvector cosine distance) for concept-level recall. Results from both passes are merged and ranked.
The server supports two transports. In stdio mode, Claude Code spawns it as a local subprocess — zero network exposure. In HTTP/SSE mode, it runs on a server behind a Cloudflare Tunnel with OAuth 2.0 + JWT auth, and claude.ai connects to it as a remote MCP server. That same HTTP endpoint is also what lets multiple machines share one memory pool — every Claude Code install can point its MCP config at the remote database, so your memories follow you across machines.
Architecture
Claude Code (local, stdio)
┌──────────────────────────────────────────────────────────┐
│ Claude Code │
│ SessionStart hook ──► inject retavyn-cache.md │
│ PostToolUse hook ──► refresh cache after remember │
└───────────────────────────┬──────────────────────────────┘
│ stdio (MCP protocol)
┌────────▼────────┐
│ retavyn │ Python + FastMCP
│ MCP server │
└────────┬────────┘
│
┌────────▼────────┐
│ PostgreSQL 18 │ Docker · port 5433
│ + pgvector │ tsvector + pgvector
└─────────────────┘
claude.ai (remote, HTTP/SSE)
claude.ai → https://mcp.retavyn.com → Cloudflare edge (TLS)
→ cloudflared tunnel → retavyn :8765 → PostgreSQL :5433
OAuth flow: claude.ai opens /authorize, user authenticates, server issues a JWT, claude.ai uses it as a Bearer token on all subsequent MCP calls.
Search internals
When you call recall("billing pipeline"), retavyn runs two passes and merges the results:
- Full-text search —
tsvector @@ to_tsquery('billing & pipeline'), ranked byts_rank - Semantic search — cosine distance between the query embedding and stored embeddings via pgvector (
embedding <=> $1 < threshold) - Results are deduplicated and returned ranked by combined score
Embeddings are generated via OpenAI text-embedding-3-small or Cohere embed-english-v3.0 (configurable). Memories without embeddings fall back to full-text only.
MCP tools
| Tool | Description |
|---|---|
remember |
Store a memory with optional category tag |
recall |
Hybrid full-text + semantic search across memories |
update_memory |
Edit an existing memory by ID |
forget |
Delete a memory by ID |
forget_path |
Delete all memories ingested from a file or directory path |
ingest_path |
Bulk-import a file or directory tree as memories |
backfill_embeddings |
Generate embeddings for memories that don't have them |
ask_infra |
Ask a DevOps question — runs a full agent loop (memory search + live gcloud) and returns a synthesized answer |
ask_infra
ask_infra is an agent embedded inside retavyn. When called, it spins up its own Claude tool-use loop with two tools — recall_memory (hybrid search over your retavyn memories) and run_gcloud (read-only live GCP queries) — iterates until it has a complete answer, then returns it as a single response.
From Claude Code's perspective it's one tool call. Under the hood it's a full agent making multiple passes across memory and live infrastructure state before synthesizing an answer.
Example questions:
"What load balancer setup do we use for Cloud Run services?"
"Which GKE clusters are running in prod right now?"
"How do we handle Cloud SQL private service connect?"
The agent is also available as a standalone CLI — see infra-agent/README.md.
Setup
| Guide | What it covers |
|---|---|
| INSTALL.md | Local setup — run retavyn on your machine with Claude Code |
| SERVER.md | Remote server — deploy to a VM for claude.ai and cross-machine access |
Environment variables
| Variable | Default | Description |
|---|---|---|
MEMORY_DB_HOST |
localhost |
PostgreSQL host |
MEMORY_DB_PORT |
5433 |
PostgreSQL port |
MEMORY_DB_NAME |
retavyn |
Database name |
MEMORY_DB_USER |
claude |
Database user |
MEMORY_DB_PASSWORD |
claude |
Database password |
MEMORY_TRANSPORT |
stdio |
stdio or streamable-http |
MEMORY_HOST |
0.0.0.0 |
Bind address (HTTP mode) |
MEMORY_PORT |
8765 |
Port (HTTP mode) |
OAUTH_SECRET |
— | JWT signing secret (HTTP mode) |
OAUTH_PASSWORD |
— | Auth password for browser flow (HTTP mode) |
OPENAI_API_KEY |
— | For OpenAI embeddings (optional) |
COHERE_API_KEY |
— | For Cohere embeddings (optional) |
Documentation
| File | Contents |
|---|---|
| INSTALL.md | Local install: setup.sh, MCP config, hooks |
| SERVER.md | Remote deploy: GCE VM, Cloudflare Tunnel, OAuth, claude.ai |
| TUTORIAL.md | First memory → first recall → journaling |
| API.md | Complete tool reference, search internals, advanced usage |
CLI commands
python main.py # start MCP server (stdio)
python main.py dump # export all memories to ~/.claude/retavyn-cache.md
python main.py remember <content> [category] # store a memory from the CLI
python main.py health # check DB connection and memory count
python main.py ingest <path> [category] # bulk ingest a file or directory
© 2026 Matt Bucknam — MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。