Skip to content

About

Shared, hosted agent memory MCP server on Supabase — scoped access with RLS. Builds on agent-memory-mcp.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Agent Memory Superbase

Shared, hosted memory for AI agents, built on Supabase. An MCP server, run as a Supabase Edge Function, gives agents persistent memory they can store into and search, from any machine or cloud session.

Memories can be used to orchestrate agents working on solving complex problems.

image

Memories live in scopes (named memory pools, such as predbat-devs). An admin grants each member read-only or read-write access per scope, and Postgres row-level security enforces it. Several developers and their bots can share one memory, and no one can read a scope they weren't granted.

If you want to buy me a beer, then please use Paypal or GitHub sponsor image

Why

Agents forget everything between sessions. Most memory servers fix that for one person on one machine: a local file or database that a cloud session, a CI bot or a teammate cannot reach. This project is for a team of people and bots working on the same code, who should learn from each other: what one session finds, the next one can recall, wherever it runs.

How it differs from other memory tools:

  • Hosted, but yours. Hosted memory services such as Mem0 Platform, Supermemory and Zep give a team shared memory, but the memories live on their service, and finer access control is often a paid tier. Self-hosted servers such as mcp-memory-service, Graphiti and Cognee keep the data with you, but you run the server and database and build the team's access rules yourself. This runs in your own Supabase project (the free tier is enough), installs with two commands, and has no server to look after. A client needs only a URL and a token, so a cloud session or a bot connects as easily as a laptop.
  • Access rules live in the database. Each memory belongs to a scope, and each member has read or write access per scope. Postgres row-level security enforces this, not application code, and the pgTAP and integration tests check it against a real database. A bot that answers in public can read a scope without being able to write to it, and a private scope is invisible to anyone not granted it.
  • Threads, so agents can work together. Memories hold what is settled; threads hold the discussion. An agent can hand its findings to another, ask a question someone answers later, and catch up with whats_new. None of the memory servers we compared has an equivalent.
  • No LLM in the loop. Memories are stored as the agent wrote them and found by hybrid full-text and vector search. The embedding model (gte-small) runs inside the function. Tools such as Mem0, Graphiti and Cognee call an LLM to extract facts or a graph from what you give them. Here there is no model API key, no per-call model cost, and nothing rewrites what was stored.
  • Run by a team, not one person. Admins manage members, grants and tokens from Claude or the shell. Every admin action is logged, deletes can be undone for 30 days, and one script backs up the whole install.

It is not a knowledge graph, and it is not a personal assistant's memory. For one person on one machine, the reference memory server or agent-memory-mcp, which this project builds on, is simpler.

Tools

The server exposes 30 tools, plus 13 admin_ tools that only admins see (see Admins). Eleven are the thread tools (see Threads and sessions). The memory tools are list_scopes, store, store_batch, search, recall, find_related, list_recent, update, delete, stats and prune, plus the four link tools relate_memories, unrelate_memories, neighbours and graph (see Memory links), and the four claim tools claim_memory, claim_next, release_claim and my_claims (see Claims). They match the original server, plus a scope argument on the write tools, and the link and claim tools. Search is hybrid (BM25 full-text plus gte-small vector similarity, fused with RRF) with temporal decay. Its tags filter keeps memories with at least one of the tags given; tags_all keeps only those with every one, so a query such as "open work in this repo" (tags_all: ["repo:<name>", "status:open"]) needs no client-side filtering. The two can be combined. Leave out query and search browses instead of ranking: it lists every memory matching the filters, newest first, and pages with limit (up to 400) and offset, returning has_more. Browsing does not count as an access, so it suits a cleanup sweep. Offsets shift if memories are added or deleted while paging. Delete and prune are soft; rows are purged after 30 days.

Memory links

Search finds memories by their words. A link is an explicit, typed, one-way relationship between two memories, so an agent holding one memory can find the ones connected to it without another query. There are four types:

Type Meaning
supersedes from replaces to; to is out of date
derived-from from was concluded from to (a decision and its evidence)
depends-on from only holds, or can only be done, if to does
relates-to loosely associated; it has no direction, and the pair is stored once

relate_memories and unrelate_memories create and remove links, and neighbours follows them (1 to 3 hops, by direction and type, up to 100 memories, each with the path that reached it; detail: "short" returns a 160-character snippet instead of each memory's full content, for wide walks). It does not count as an access. Search, recall, find_related and list_recent results show each memory's links (up to 10, plus a moreLinks count), and a memory that a newer one supersedes is flagged superseded: true; it is flagged, not ranked lower.

graph reads a whole project at once: it takes the search filters (tags or tags_all is required, for example tags_all: ["board:<project>"]) and returns the matching memories as nodes, oldest first, and every link between them as edges ({from, to, type}). Each node has its id, scope, category, tags, createdAt, a 160-character snippet, superseded and any active claim; detail: "full" gives the whole content instead. It returns up to 400 nodes, or 100 with detail: "full", with total and truncated; links to memories outside the set are left out. Unlike neighbours, it also finds memories not yet linked to anything. It does not count as an access.

You need read access to both memories. supersedes needs write access to both scopes; derived-from and depends-on need write access to the from memory's scope; relates-to needs write access to either. Removing a link needs write access to either end's scope. A link is visible only to someone who can read both ends, so it never reveals a memory you cannot read, and the two memories may be in different scopes. A memory has at most 100 outgoing links.

Claims

A claim says "I'm working on this" on a memory, typically a status memory for a task, so another agent sees the work is taken before starting it. claim_memory takes the memory, a short reason (up to 200 characters) and either minutes (default 60, no fixed maximum, so a week is 10080) or indefinite: true for a claim with no end. Search, recall, find_related, list_recent, browse and neighbours show a claimed memory's claim: who holds it, until when and why.

A claim belongs to a member and a session together. Claiming again from the same session renews it. A claim held by another member, or by another session of your own member, fails and says who holds it, until when and why; force: true takes it over, and the result's overridden reports the claim it replaced (with its session when it was your own). A claim made without a session can be renewed only by another call without one, so give every agent its own session label and pass it to claim_memory, claim_next and release_claim alike. A new label creates the session. The session is shown only to its member, in my_claims and as claim.session, so you can spot claims left by stale sessions. release_claim removes your session's claim, or anyone else's with force. my_claims lists your member's active claims across all its sessions, soonest end first.

claim_next takes work from a queue: it claims the oldest memory matching the filters (tags or tags_all is required) that nobody holds, that you can write and that is not superseded, and returns it in full, or claimed: false when nothing is free. It never waits: a memory another caller is claiming at that moment is skipped, so parallel workers get different memories.

Claiming and releasing need write access to the memory's scope. Claims are advisory: they never stop anyone reading, updating or deleting the memory. An expired claim, or one whose holder has been deactivated, counts as no claim.

Blackboard skill

skills/blackboard/ is a Claude Code skill, made of instructions only, that lets several sessions pursue one shared goal through this server. They can run on any model, in any terminal. A board is a set of memories tagged board:<project>: a goal, rules, progress, intents (work to do), facts (results), hints, and a conclusion. One session leads, writing intents and deciding when the goal is met. Workers take intents with claim_next, do them, and record one fact each. Sessions never message each other.

Install it once, from a main checkout:

ln -s "$PWD/skills/blackboard" ~/.claude/skills/blackboard
Command Does
/blackboard start <project> Sets up a board with you: goal, a checkable "done when", scope, and rules you approve
/blackboard lead <project> One lead round: read the board, then write intents, correct facts, or conclude
/blackboard lead <project> takeover Takes over the lead from a session you know is dead
/blackboard work <project> One work cycle: claim an intent, do it, record a fact
/blackboard hint <project> <text> Adds advice for the lead
/blackboard intent <project> <text> Adds an intent of your own, which the lead never drops as pointless
/blackboard amend <project> <text> Adds an amendment: a sub-goal or fallback the lead reads with the goal
/blackboard pause <project> Holds the lead still (state:paused); workers finish open intents
/blackboard resume-lead <project> Undoes pause
/blackboard status <project> Shows where the run stands (read-only)
/blackboard stop <project> Stops every lead and worker at its next step

Run the lead and the workers under /loop. Start /loop /blackboard lead <project> in one session and /loop /blackboard work <project> in as many others as you like, for example a second terminal on a different model.

What a board needs that is specific to its goal, such as how to measure or what workers may touch, lives in its rules memory. Workers never push, merge or deploy unless those rules allow it. The board's scope decides who can read it, so a board in a public-safe scope must hold only public-safe facts. The design is in docs/superpowers/specs/2026-11-23-blackboard-skill-design.md.

This is the maintained copy of the skill. A project that uses it keeps only its own board file.

Board runner

runner/ is a Python program that runs a board for you, so you don't drive the sessions by hand under /loop. You give it a board file (TOML) with the goal, Done when, rules, an optional measurement command, the lead's model and one slot per worker, for example one Opus and one Sonnet:

  • the lead is an interactive Claude Code session in tmux, which you can watch and talk to;
  • each worker is a fresh claude -p for each intent;
  • the runner asks the lead for a round as soon as one is needed, so no worker waits for a timer.

It enforces each worker's runtime limit and the board's total intent limit, which you can raise to resume. Setup and the board file reference are in runner/README.md.

Web UI

A local web page for looking at the store and at a running board, and for steering a board without driving an agent to do it. Browse is read-only. On a board you can add hints, intents and amendments and control the run, and those are the only writes it makes. The controls change only the goal's state tag and its Max intents line. The one delete is of a hint, intent or amendment it has just stored, when linking it fails. It never writes outside a board. It is also local-only: deno task web binds to 127.0.0.1, serves http://localhost:8787, and refuses any request whose Host header is not localhost or 127.0.0.1.

image
deno task web

It reads .env (see .env.example):

Key Default Meaning
AGENT_MEMORY_TOKEN required The member token. The local server adds it to each request; the browser never sees it
AGENT_MEMORY_URL none Your agent-memory function URL. The server swaps agent-memory for web-api
WEB_API_URL derived from the above The web-api function URL. Set it to override, for example to use the local stack
WEB_PORT 8787 The local port
BOARD_RUNNER_HOME ~/.board-runner Where the board runner keeps worker logs

The page calls a separate web-api Edge Function, so polling never loads the embedding model. Its read routes are GET; its write routes are POST and are listed under "Writing to a board". It runs as the token's member, so it shows what that member can read, and writes only where that member can write. Deploying web-api to a hosted project is a hosted change, like any other: see "Rules that bite" in CLAUDE.md. To try it against the local stack, see Development.

  • Browse: a search box, scope, tag (any or all) and category filters, and a table. With the box empty it lists newest first and loads more on request, like search with no query. With text it runs ranked search, and "show more" raises the limit up to 100 (ranked search has no offset). Looking does not count as an access, so it does not change a memory's decay. A "Graph" button on any tag opens that tag's graph.
  • Board: pick a board (its scope and board: tag together) and see it as a graph, updated every 3 seconds while the tab is visible. The strip above shows the goal's state, the round, intents used out of Max intents: and the best result. The page says when it last refreshed, when the connection fails, and "stale" when a refresh is overdue.
    • Each round is a horizontal band, with its intents in a row and each intent's results directly beneath it. Faint "Round n" labels separate the bands. A board whose intents have no round:<n> tag is grouped as "Batch n" instead, by gaps of two minutes in creation time. A dashed line joins the goal to any intent that links to nothing.
    • Colour shows the kind (goal, intent, fact, hint, conclusion), and a fact's colour shows its verdict. A ring shows an active claim, with the worker's label. A node that changes flashes. A board over 400 nodes is not fully drawn, and the page says so.
  • Drawer: click a node for three tabs. Memory has the full content, tags, scope and claim. For an intent it starts with "Starting point": what it builds on and the latest measurement before it. For a fact it shows the result first, and for the goal the progress fields and latest measurement. Links lists links in and out, and clicking one selects that node. Worker log is described next. On a board, the Memory tab also ends with the node's shortcuts described in "Writing to a board".

Writing to a board

A board's actions are on the Board tab, in a toolbar directly under the status strip (on a board, not on a tag's graph): the run controls, then + Hint, + Intent and + Amendment. Each of those three opens its form in a panel under the toolbar. Only one panel is open at a time, and Escape or the same button closes it. Switching boards closes it. A hint or intent added from the toolbar is for the whole board, linked to no node.

The drawer keeps only what is about one node, at the bottom of its Memory tab, each collapsed to one line until you click it: Hint about this node on any node of the board but the goal, and Try next from this fact on a fact while the board is running or paused. The goal's drawer is read-only: its progress, the goal text and the list of the board's amendments.

A form is disabled while its request is in flight. On success it clears, says "Added — it will appear in the graph shortly" and polls the graph at once. On failure it shows the server's error. If the board is over 400 nodes, the page warns that what you add may not appear.

  • + Hint. A hint is advice for the lead, read at its next round. From the toolbar it applies to the whole board. From "Hint about this node" on an intent, fact or hint it links to that node; on a conclusion, progress, rules or amendment node it links to nothing and applies to the whole board. A hint is allowed in any board state.
  • + Intent, while the board is running or paused. Write what a worker should try, and optionally "Done when" and "Give up when". Left empty, they become "a fact reporting what trying this showed" and "it cannot be done within the board's rules; record an inconclusive fact". From "Try next from this fact", the intent is linked derived-from that fact. The form shows how many intents the board has used out of Max intents. A person's intent is accepted even over the limit, and the lead never drops it as pointless: only a fact closes it.
  • + Amendment, in any state but done. An amendment is a sub-goal or fallback, such as "if 20% is out of reach, 15% is acceptable, as long as X is unchanged". The goal stays as written, and the lead reads every amendment with it, the newer winning a conflict. A fallback applies only once the goal's own target is out of reach. Without [measure], meeting it concludes the board as done, citing the amendment. With [measure], the runner's measurement stays the arbiter, so the lead stops with Stopped: amended target met (amendment <id>). The goal's drawer lists the board's amendments.
  • Run controls, at the start of the toolbar. Each changes the goal memory in the database, so it works for a board run on any machine. Only the buttons valid for the goal's state are shown.
    • Pause lead (while running) swaps state:running for state:paused. The lead plans nothing new and writes nothing, but keeps its claim and ends each round with BOARD-LEAD paused. Workers finish what they hold and take intents that are already open, including ones you add. The runner keeps going and asks the lead for a round every 2 minutes, so Resume lead is seen within about that time.
    • Stop… (while running or paused) sets state:stopped, after a confirmation under the toolbar that focuses Cancel. Workers end at their next step, and the runner lets running workers finish, then exits.
    • Restart (when stopped) sets state:running again and says to run board-runner run <board file> again to start the workers. It is not offered when the goal is done.
    • Intent limit is in the status strip: in "Intents 14 of 20" the limit is a button. Click it to edit the goal's Max intents in place, type a whole number or none, and press Enter to save; Escape, or clicking away, cancels. A done board shows it as plain text. Saving rewrites that line and keeps the rest of the goal. Once the count of intents reaches a lowered limit, the lead plans no more, and it stops the board once no intent is open. Raising it on a board that stopped at its limit sets it running again, as /blackboard resume does, with the same note to run the runner again. A higher max_intents in the board file raises it again on the next board-runner run.

The browser sends only text and the node it is about. The server builds every word of the template, every tag and every link, and folds line breaks in your text to spaces so no field can forge another line. The same writes are available in a Claude session as /blackboard hint, intent, amend, pause, resume-lead and stop.

Amendments are guarded by a rule for now: workers never change the goal, the rules or an amendment, and the lead honours only an amendment whose From: line names a person. That is a convention, not enforcement. A follow-up is a separate bot member for agents, with a database rule that bot members cannot write kind:amendment, kind:goal or kind:rules or edit the goal.

The write routes (on web-api, all POST with a JSON body, as the token's member):

Route Body Result
/hints scope, board, text, about? 201 { memory }
/intents scope, board, text, produce?, giveUp?, from? 201 { memory }; 409 Board is not running unless running or paused
/amendments scope, board, text 201 { memory }; 409 when the board is done
/boards/control scope, board, action? (pause, resume, stop, restart), maxIntents? (number or "none") 200 { goal }; 409 Board is <state> when the action is not allowed from there
/usage one run's raw token counts (sent by the board runner, never the browser) 201 { id }; 404 or 403 for a scope the token cannot write
/usage/delete scope, board 200 { deleted }

GET /usage?scope=&board= returns a board's runs, newest first, and their summed total. The strip shows that total ("Tokens 12M in · 310k out", input counting cache reads and writes), and an intent's, fact's or goal's drawer shows the runs that worked on it. These are raw token counts; no costs are stored or shown.

text is 1 to 2,000 characters; produce and giveUp at most 500. A board or memory the caller cannot read gives a 404 that reads the same whether it is absent or unreadable. If linking fails after a memory is stored, the route deletes the memory it stored and returns the error.

The local server forwards exactly these four POST routes, besides its GET routes. A POST must carry Content-Type: application/json and prove it came from the server's own page (Sec-Fetch-Site: same-origin, or an Origin equal to the page's own when that header is absent), or it is refused with 403. The body is at most 16 KiB, and a write gets a 30 s timeout, against 15 s for a read. A retry after a timeout can leave a duplicate.

Worker log

For a fact with a By: <label> line, or an intent whose claim description carries (label: <label>), the Worker log tab shows that worker's transcript: what it said, each tool call, and each result collapsed to a few lines. While the worker runs, it follows the log live. A done intent's log is found through its fact. The skill writes both the By: line and the claim label.

The log comes from files on this machine, so it needs the board runner to have run the worker here. It reads workers/<slot>-<label>.jsonl (or the older .json and .err files) under ~/.board-runner/<board>/, or under $BOARD_RUNNER_HOME. A worker started on another machine or by hand has no local log. The tab then says "No local log: this worker did not run on this machine", and the rest of the board works as before. The log route accepts only a <board>/<label> of the shape the runner makes, and never reads outside that board's workers/ folder.

Commits

A fact whose worker committed its work carries a Commit: <sha> on <branch> line. Its drawer then offers:

  • View on GitHub (if pushed), when the board's goal has a Repo: owner/name line. Set repo = "owner/name" in the board file: /blackboard start writes the line into a new board's goal, and adds it to an existing goal that lacks one. Board branches stay local until someone pushes them, so the link shows the commit only after a push (to the repo or a fork).
  • A Diff tab, from the board's workspace on this machine, so it needs no push. It reads like GitHub's split view: the message (or commit list) on top, then a card per file with old lines on the left and new on the right, changed words marked, and 3, 10 or all lines of context. "This commit" shows the commit alone; "All changes vs main" shows every commit on top of origin/HEAD (or origin/main, main, master). A conclusion names the winning commit and opens on "All changes vs main". "Full width" widens the drawer across the page. The board runner records the workspace in its state.json; a board whose runner has not been restarted since says so. The /diff/<board>/<sha> route accepts only a board name and a hex SHA, runs git without a shell, external diff tools or a pager, stops after 10 s and returns at most 2 MB.

Later: hosting

The browser code calls /api/... only, so a login front door could replace the local proxy later. Worker logs would stop being local files then. Transcripts hold tool output, which can include file contents and command output, so a hosted version must not expose them without a separate, deliberate decision. Writing (hints, stop) and a History tab are also not in this version. The design is in docs/superpowers/specs/2026-11-26-web-ui-design.md.

Threads and sessions

Memories hold what is known; threads hold the discussion around it. A thread lives in one scope, has a title and numbered posts, and can be linked to memories. Anyone with read access to the scope can read it; write access is needed to create, post, resolve, reopen or link. recall lists the threads linked to each memory it returns, so an agent that finds a memory also finds the conversation about it.

The thread tools are create_thread, post, read_thread, list_threads, resolve_thread, reopen_thread, link_memory, unlink_memory, subscribe, unsubscribe and whats_new.

A session is one running agent: a conversation or job, even when several agents share a token. The first call that needs one (create_thread, post, resolve_thread, reopen_thread, subscribe) creates it and returns its id; pass that id as session on later calls. If the id is lost, pass the same session_label to pick the session up again. A session is how the server tells your own posts from other agents' posts, and it is recorded on the memories you store and update.

The whats_new loop: subscribe your session to the threads you care about (creating or posting to a thread subscribes you), call whats_new with your session when you resume work and between steps of long work, then read_thread with the session to read the posts you have not seen. Reading marks them seen. Your own posts never show as new.

Admins can delete a thread with admin_delete_thread. From the shell:

deno run -A scripts/admin.ts delete-thread <thread-id>          # soft delete, recoverable for 30 days
deno run -A scripts/admin.ts restore-thread <thread-id>
deno run -A scripts/admin.ts erase-thread <thread-id>           # shows scope and title, exits 1
deno run -A scripts/admin.ts erase-thread <thread-id> --yes     # hard delete with its posts; not reversible

Quick start

Two commands take an empty Supabase project to a working Claude connection. You need the Supabase CLI 3.x and Deno 2.x.

cp .env.example .env     # then fill in SUPABASE_ACCESS_TOKEN, SUPABASE_DB_PASSWORD and SUPABASE_PROJECT_REF
deno run -A scripts/setup.ts --configure-claude

setup.ts links the project, applies the migrations, deploys the function, creates a scope (default) and a member (your OS user), grants it write access and issues a token. It saves AGENT_MEMORY_URL, AGENT_MEMORY_TOKEN and AGENT_MEMORY_DB_URL into .env (mode 0600; it refuses to write unless git ignores the file) and prints the token once. --configure-claude then runs claude mcp add for you. Re-running is safe: nothing is duplicated, and a live token in .env is reused. The member it creates becomes the first admin (see Admins).

Flags: --env-file <path> (default .env), --scope <name> (default default), --member <name>, --email <address> (optional; only links the member to a Supabase login), --bot (a bot member instead of a human), --new-token (issue another token even if .env has a live one), --skip-deploy, --configure-claude and --name <server-name> (default shared-memory).

To register an existing token without re-running setup: deno run -A scripts/configure-claude.ts [--name shared-memory] [--scope user|project]. Project scope writes the token into .mcp.json, which is normally committed, so it needs --yes; prefer the default user scope.

The admin, backup and import scripts read AGENT_MEMORY_DB_URL from the environment; load the saved file with deno run --env-file=.env -A scripts/admin.ts list-scopes.

configure-claude passes the token to claude mcp add as an argument, and Claude Code stores it in ~/.claude.json, as with any MCP header.

The manual steps follow, if you prefer to run each yourself.

Install by hand

You need a Supabase project (the free tier works), Supabase CLI 3.x (the commands below use its flags; CI pins 3.0.0) and Deno 2.x.

supabase link --project-ref <project-ref>
supabase db push --remote
supabase functions deploy agent-memory --use-api

db push applies the migrations in supabase/migrations/, which create everything: the agent_memory schema, row level security, the search functions and the daily clean-up job. In CLI 3, db push targets the local stack unless you pass --remote (the linked project, or --remote=<project-ref>). functions deploy targets the linked project (or --remote=<project-ref>), and --use-api means no Docker is needed to deploy.

The schema agent_memory must not be listed under Settings, API, Exposed schemas. Access goes only through the Edge Function; anon and authenticated have no privileges on it.

Installing by hand, nothing makes you an admin. After creating your own member (see the Admin quick-start), make it the first admin: deno run -A scripts/admin.ts set-admin <you> on.

Temporal decay

Search scores decay with age, as in the original. The half-life in days is the function secret MEMORY_DECAY_HALF_LIFE (default 30):

supabase secrets set MEMORY_DECAY_HALF_LIFE=45

A value of 0 or less (or one that is not a number) disables decay. Then prune (and stats.belowPruneThreshold) uses only the dormant rule: a memory that was never accessed and is older than maxDormantDays (default 90). The original server instead treated every memory as a candidate when decay was off. Memories tagged evergreen or never-forget are never pruned.

Admin quick-start

The admin scripts connect to the database directly. Set AGENT_MEMORY_DB_URL to the session pooler connection string (Connect in the dashboard, port 5432) and keep it out of version control. Percent-encode any special characters in the password (for example @ as %40, / as %2F, # as %23), or the URL will not parse.

export AGENT_MEMORY_DB_URL='postgresql://postgres.<project-ref>:<password>@<pooler-host>:5432/postgres'

deno run -A scripts/admin.ts create-scope my-team --description "Team memory"
deno run -A scripts/admin.ts create-member alice                 # email optional: --email alice@example.com
                                                                 # links a Supabase login if one exists
deno run -A scripts/admin.ts create-member ci-bot --bot
deno run -A scripts/admin.ts grant alice my-team write
deno run -A scripts/admin.ts grant ci-bot my-team read
deno run -A scripts/admin.ts issue-token alice laptop --expires 90d   # shown once

Other commands: list-scopes, list-grants, list-tokens <member>, revoke <member> <scope> and revoke-token <id>. Tokens look like amm_… and only their SHA-256 hash is stored.

Admins

Some members are admins. An admin can manage the team from Claude, not only from the shell.

  • The first admin comes from scripts/setup.ts: a human member it creates or reuses is made an admin (a --bot member never is). For an existing install, run deno run -A scripts/admin.ts set-admin <member> on.

  • Shell-only commands (they are not available through Claude): set-admin <member> on|off, reactivate <member> and admin-log [--since <ISO|Nd>] [--actor <name>] [--limit N]. delete-scope, deactivate and list-members are also shell commands, and admins can do them from Claude too. Deactivating a member also drops their admin flag, so a reactivated member is not an admin until set-admin is run. A scope can only be deleted once it holds no memories, live or soft-deleted.

  • From Claude, admins can do the rest with the admin_ tools: admin_list_scopes, admin_create_scope, admin_delete_scope, admin_list_members, admin_create_member, admin_deactivate_member, admin_list_grants, admin_grant, admin_revoke, admin_issue_token, admin_list_tokens, admin_revoke_token and admin_delete_thread (a soft delete; restore-thread and erase-thread are shell-only).

  • Connecting an onboarded member. The admin issues a token with admin_issue_token (or issue-token) and gives it to the member, who registers it with Claude Code:

    claude mcp add --transport http shared-memory https://<project-ref>.supabase.co/functions/v1/agent-memory \
      --header "Authorization: Bearer <token>" -s user

    or, with the URL and token in an env file (AGENT_MEMORY_URL, AGENT_MEMORY_TOKEN), deno run -A scripts/configure-claude.ts [--name shared-memory] [--scope user], as in the Quick start.

  • Handle issued tokens with care. A token issued through admin_issue_token passes through the admin's Claude transcript, so give it to the member privately (not in a shared channel), and revoke it if it leaks. Do not auto-allow the mcp__<server>__admin_* tools in Claude Code permissions: admin tools run in sessions that also read memories written by other members, so keep the per-call confirmation on.

  • Admin tools never act on another admin. Changing an admin, or their grants or tokens, is done from the shell.

Every admin action, from the shell or from Claude, is recorded in the admin log. The log never holds a token.

Undo, and erasing for good

delete and prune are soft: a deleted memory stays restorable for 30 days, then the daily job purges it. A purge removes the content from the memory's history as well, so only the fact that it existed remains.

# What has been deleted, by whom, and when (all filters optional)
deno run -A scripts/admin.ts list-deleted --scope my-team --by ci-bot --since 2026-11-01

# Restore by id (one or several)
deno run -A scripts/admin.ts restore <memory-id> <memory-id>

# Undo a bad bulk prune: without --yes this lists what it would restore and exits 1
deno run -A scripts/admin.ts restore --scope my-team --by ci-bot --since 2026-11-01
deno run -A scripts/admin.ts restore --scope my-team --by ci-bot --since 2026-11-01 --yes

# Erase a memory now (live or deleted), with its history content. Not reversible.
deno run -A scripts/admin.ts erase <memory-id>         # shows id, scope and first line, exits 1
deno run -A scripts/admin.ts erase <memory-id> --yes

--by admin matches deletions made directly in the database rather than by a member.

Backup and restore

deno run -A scripts/backup.ts backup                       # the whole install: scopes, members, grants, memories
deno run -A scripts/backup.ts backup --scope my-team --out backup-my-team.json   # one scope
deno run -A scripts/backup.ts restore-backup backup-<timestamp>.json

backup exports the whole install by default, including threads, posts, links, sessions and subscriptions; --scope limits it to one scope: that scope's threads and posts, the links to memories in the file, the sessions they reference, and the members behind all of it. The file holds memory content: treat it as private. restore-backup loads only into an empty install (fresh migrations, no scopes, members or memories) and keeps ids. Access tokens are never exported, so after a restore, issue new tokens with issue-token. Admin flags and deactivation are kept, and backup files written before admin support, or before threads, still restore (as non-admin, active members, with no threads). The admin log is not exported, so it starts empty after a restore.

Import from a local agent-memory-mcp store

scripts/import.ts loads memories exported from a local LanceDB store, re-embedding each one through the function's /embed endpoint. It is a dry run until you pass --execute.

# 1. Export the LanceDB store to JSON (Node 20+). The output is private: memories*.json is gitignored.
(cd scripts/lancedb-export && npm ci) && node scripts/lancedb-export/export.mjs <MEMORY_DB_PATH> > memories.json

# 2. Dry run: choose by tag, review the list, and write the selected ids to a file
deno run -A scripts/import.ts --file memories.json --include-tag repo:batpred --exclude-tag personal \
  --write-ids ids.txt

# 3. Edit ids.txt: delete any line you do not want shared (# starts a comment). Re-run the dry run with it
deno run -A scripts/import.ts --file memories.json --include-tag repo:batpred --exclude-tag personal --ids ids.txt

# 4. Import for real
export AGENT_MEMORY_DB_URL='postgresql://…'                                     # as for the admin CLI
export AGENT_MEMORY_URL=https://<project-ref>.supabase.co/functions/v1/agent-memory
export AGENT_MEMORY_TOKEN=amm_…                                                 # any valid token, used for /embed
deno run -A scripts/import.ts --file memories.json --include-tag repo:batpred --exclude-tag personal --ids ids.txt \
  --scope my-team --as alice --execute

A tag filter alone can let private memories through, so review the ids before --execute. Re-running is safe: memories already present are skipped. Content over 20,000 characters is reported as failed and not imported.

Warning: the importer keeps each memory's original id. Re-running import.ts from an old export can bring back memories that were since erased or purged. Remove those memories from the local export too.

scripts/smoke.ts is described under Smoke test.

Connect an agent

claude mcp add --transport http predbat-memory \
  https://<project-ref>.supabase.co/functions/v1/agent-memory \
  --header "Authorization: Bearer amm_…"

Or in .mcp.json:

{
  "mcpServers": {
    "predbat-memory": {
      "type": "http",
      "url": "https://<project-ref>.supabase.co/functions/v1/agent-memory",
      "headers": { "Authorization": "Bearer ${AGENT_MEMORY_TOKEN}" }
    }
  }
}

Keep the token in an environment variable, not in a committed file.

Suggested CLAUDE.md wording

docs/claude-md-sample.md is a fuller section to paste into your own CLAUDE.md as it is, filling in the scope table. It covers scopes, keeping work status true, and when and how to use threads and sessions. The short version:

## Shared memory
- Call `list_scopes` first to see which scopes you can use and whether each is read or write.
- Store durable findings into the team scope (`my-team`), not a personal one. Include why, not just what.
- Before storing, `search` for an existing memory on the topic. If there is one, `update` it; do not store a duplicate.
- Never store secrets, tokens or credentials.

Smoke test

AGENT_MEMORY_URL=https://<project-ref>.supabase.co/functions/v1/agent-memory \
AGENT_MEMORY_TOKEN=amm_… \
  deno run -A scripts/smoke.ts --scope <scope-with-write-access>

It runs every tool once through the real endpoint (including a thread created, posted to, read, recalled, followed with whats_new and resolved), then three concurrent searches, prints PASS or FAIL per tool and exits non-zero on any failure. It deletes what it stored. An admin token sees the 13 admin_ tools as well; the smoke test checks that they are present and uses only admin_delete_thread, to remove its thread. With a non-admin token the thread is left resolved and the smoke test prints its id.

Development

supabase start                # local stack
deno task check               # fmt, lint, type-check
deno task test:unit
supabase test db              # pgTAP: schema, RLS, functions, search
deno task test:int            # against the local database
supabase functions serve agent-memory & deno task test:e2e   # needs the model download

deno task web starts the web UI on http://localhost:8787 (bound to 127.0.0.1) using AGENT_MEMORY_TOKEN from .env. To point it at the local stack instead of the hosted project:

supabase start && supabase functions serve web-api        # another shell
AGENT_MEMORY_DB_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres \
  deno run -A scripts/admin.ts issue-token <local member> web-local     # prints a local token once
WEB_API_URL=http://127.0.0.1:54321/functions/v1/web-api AGENT_MEMORY_TOKEN=<local token> deno task web

CI (.github/workflows/ci.yml) runs everything except the end-to-end test.

Known limits

  • Error 546 ("retry once"). Embedding runs inside the Edge Function, which has a CPU budget per worker. If a worker is busy and the platform recycles it, a request can fail with 546/WORKER_RESOURCE_LIMIT. Retry once; the retry lands on a fresh worker. To stay inside the budget, store_batch accepts at most 2 memories and recall embeds at most 5 topics per call. Details are in the spike results.
  • Size limits. A memory's content is at most 20,000 characters (store, store_batch, update, import), and every result limit (search with a query, find_related, list_recent, recall) is between 1 and 100. A search without a query (browse mode) accepts a limit up to 400.
  • Free-tier pausing. Free Supabase projects are paused after a period of inactivity. Unpause from the dashboard; the first request after that is slow.

Credits

This project builds on the design and code of agent-memory-mcp by Adam Drew, via the chalfontchubby fork, which fixes upstream bugs that made the memory forget records. It keeps their tool set, hybrid BM25 + vector search and temporal decay, and moves the store from a local LanceDB folder to Supabase (Postgres, pgvector, full-text search) with scoped, shared access.

License

GPL-3.0-or-later, as the original. See LICENSE.

About

Shared, hosted agent memory MCP server on Supabase — scoped access with RLS. Builds on agent-memory-mcp.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages