cd /news/artificial-intelligence/i-built-persistent-ai-memory-for-cla… · home topics artificial-intelligence article
[ARTICLE · art-2071] src=dev.to pub= topic=artificial-intelligence verified=true sentiment=↑ positive

I built persistent AI memory for Claude on Cloudflare's free tier

"second-brain-cloudflare," a self-hosted MCP server that provides persistent memory for AI assistants like Claude and ChatGPT across sessions, running entirely on Cloudflare's free tier. It uses vector embeddings and a tag-aware half-life scoring system to improve memory retrieval, while preventing duplicate entries and supporting real-time query streaming with a web UI. The solution requires no external databases or API keys beyond a Cloudflare account token.

read1 min views7 publishedMay 20, 2026

Every Claude session starts fresh. You copy context, explain your setup, reintroduce your project, and then do it all over again the next day. I got tired of this and created a solution. second-brain-cloudflare is a self-hosted MCP server that provides Claude, ChatGPT, Cursor, and any MCP-compatible client with persistent memory across sessions. It operates entirely on Cloudflare's free tier. Here’s how it works. wrangler deploy

bge-small-en-v1.5
for embeddings,
@cf/meta/llama-4-scout-17b-16e-instruct
for web UI synthesisOne deployment. No external databases. No API keys needed beyond your Cloudflare account token.

Pure vector similarity has a drawback. A memory from three months ago can outrank something you saved yesterday if it’s semantically closer. The solution is to fetch three times more candidates than needed (topK=5 pulls 15), then score each using a tag-aware half-life: adjusted_score = cosine_similarity × e^(-age_in_days / half_life) Before storing anything, embed the incoming content and query Vectorize for its nearest neighbor: duplicate-candidate tagWithout this step, Claude creates 20–30 nearly identical entries for the same decision. Long notes split at sentence ends, with a 200-character overlap. Each chunk receives its own vector. Chunk IDs are stored in D1, so forget() reliably removes all related vectors. Queries now support time limits: Queries flow through @cf/meta/llama-4-scout-17b-16e-instruct before being rendered. Answers stream in real time, with source memories that can be collapsed underneath. You’ll find Append and Forget buttons. This runs on your own Cloudflare account.

Deploy: https://thesecondbrain.dev
GitHub: https://github.com/rahilp/second-brain-cloudflare
If this was helpful, please give it a star.
── more in #artificial-intelligence 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-built-persistent-a…] indexed:0 read:1min 2026-05-20 ·