persistent-memory
Deploys the MCP server as a Cloudflare Worker, providing serverless execution.
Uses OpenAI's text-embedding-3 model to generate embeddings for semantic search.
Stores pages and chunks in Supabase PostgreSQL with pgvector for vector similarity search.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@persistent-memorysearch my vault for project ideas"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Second Brain
Persistent memory for any AI agent.

Every assistant forgets the moment the chat ends. Second Brain is the memory they keep: a folder of Markdown pages you own, held in a hosted database with a vector index so they can be found by meaning, and served to any agent over the Model Context Protocol. Claude, ChatGPT, Grok, Gemini, Claude Code, Codex, Cursor: if it speaks MCP, it can remember.
Three parts, one product:
Part | What it is | Where |
The rulebook |
| |
The librarian | An MCP memory server with five tools. Chops every page at its headings, vectorizes the pieces, files them, and answers questions. | |
The library | A hosted Postgres with pgvector. Two tables: every page whole, and every page in chunks with its vectors. The rolodex is the vector index. |
Plus two tools for the machine that holds your notes: a bulk loader and a two-way file sync, so you can keep editing in any editor and the memory stays current.
Built and used daily as the memory behind one person's entire working life (every project, every decision, thousands of pages). Extracted here clean.
Quick start
The fastest route is to paste KIT.md into an agent with a shell
and let it do the setup. By hand:
Library. A Postgres with pgvector (Supabase is one click). Run the SQL in
migrations/in order.Config.
cp .env.example .envand fill it in. Never commit.env.Load.
npm install && npm run embedreads your notes folder and fills the library. A large vault costs a few dollars once.Serve.
cd server, setSUPABASE_URLinwrangler.toml,wrangler secret putthe three secrets,npx wrangler deploy.Connect. Add
https://<worker>/mcp/<AUTH_TOKEN>as an MCP connector in any client. The token rides in the URL because some clients cannot send a bearer header. Treat the URL as a password.Sync (optional).
npm run syncon the notes machine keeps folder and library mirrored both ways.
Related MCP server: ilma
The five tools
Tool | Does |
| Semantic search across every live page. Returns chunks with their page path, title, kind and heading. |
| The full page: title, kind, body, metadata, updated_at. |
| Create or overwrite a page. Derives kind from the path, extracts headings and |
| Insert under a |
| Soft-delete. Needs |
GET / is a liveness probe. GET /rules returns the rulebook. initialize
returns the rulebook as MCP instructions, so a client that honours them
needs no extra prompt.
How it works
Any agent ──MCP──▶ librarian (Worker, 5 tools) ──▶ library (Postgres + pgvector)
▲ │ hands over AGENTS.md │ pages + chunks
└──── the right memory comes back ◀───────────────────┘
Your notes folder ⇄ sync ⇄ the same library (edit anywhere; you own the files)Pages are chunked at
##headings, about 500 tokens each with 50 of overlap, then embedded withtext-embedding-3-large(3072 dims, stored ashalfvec). Search embeds the question and asks thesearch_chunksRPC for the nearest chunks.The database is the source of truth. The folder is a mirror you can read, grep and edit offline. Every write re-embeds only the page that changed, so running cost is pennies.
Kind is derived from the path (
wiki/projects/→project, and so on), so the folder map inAGENTS.mdis also the schema.
What is in the box
AGENTS.md the rulebook (also served on connect and at /rules)
KIT.md paste-prompt: an agent sets the whole thing up for you
server/ Cloudflare Worker, MCP HTTP transport, 5 tools
migrations/ pages + chunks schema, search RPC, soft delete
src/embed.ts bulk loader: folder → chunks → vectors → library
src/sync.ts two-way mirror between the folder and the library
src/parse.ts path → kind, title, headings, wikilinks
reconcile.mjs repairs drift between folder and library
docs/ the explainer image and the memory-layers note
.env.example what the local tools needDesign notes
Embeddings: OpenAI by default; swap the provider in one function in
src/embed.tsand one inserver/src/index.ts.Auth: one shared token per server. For several people, issue a token per agent and check it against a table; the compare is already constant-time.
Local-only mode (local Postgres + local embedder, no cloud) is not built yet. The hosted version is the product.
Pairs with Mothership
Second Brain solves "the model does not know my projects, rules or past work
across any chat". A different amnesia, "this long session forgot what we
decided three hours ago", is solved by
Mothership's state ledger,
transcript tail and exact recall. Use both. See
docs/memory-layers.md.
License
MIT. Use it, fork it, build your own memory on it.
Made by lennymadethat.
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloud-hosted MCP server for durable AI memory
- memnodeOAuthdev.memnode
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
An MCP memory server. One memory your agents share — across models, devices and apps.
Persistent memory for AI agents across Claude, ChatGPT and any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceSelf-hosted MCP server giving AI agents persistent memory for personalization and context across conversations.41 PyPI278Apache 2.0
- AlicenseNot gradedqualityCmaintenanceFramework-agnostic MCP server for agent memory with Postgres + pgvector, enabling persistent memory, recall, and task management across sessions.MIT
- FlicenseNot gradedqualityDmaintenanceA self-hosted MCP server that gives AI agents persistent, searchable memory with importance scoring, knowledge graphs, and autonomous memory consolidation.1-
- AlicenseAqualityAmaintenanceA self-hosted MCP server that gives AI agents shared, long-term memory over a git-backed folder of markdown, enabling persistent knowledge search, read, and write without a database.1620 npm11MIT