cardloom-mcp
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., "@cardloom-mcp search for rate limiting strategies in my-app"
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.
cardloom-mcp
Save engineering decisions and fixes your coding agent can look up later. Give your agent instructions to search before answering and to save new lessons as draft cards. Search returns verified cards by default, and you decide what gets verified. Cards are plain markdown in a git repository, and search is a local SQLite index with no LLM on the read path. It works with any MCP client, such as Claude Code, Cursor or Codex.
How it works
Cards. One markdown file per lesson: a
decision,gotcha(with the error message inerror_signature),pattern,playbookorsnippet, tagged with the stack, versions and project it applies to.Lifecycle.
draft → verified → deprecated. An agent can only create drafts; a human approves (verified) or retires (deprecated) them. Deprecated is final and the file is kept for history. Merge promotion can optionally verify drafts whose source commit was merged. Search returns verified cards by default; drafts and deprecated cards only on request, always labelled.Git is the source of truth.
cards/*.mdandevents/*.jsonlare committed locally. The SQLite index is derived and can be rebuilt at any time. Syncing between machines is an ordinary git push/pull that you run; the server never touches a remote.Search. Full-text search (SQLite FTS5) with matching on stack, version and project. Every result says how it matched, so an agent can tell a real hit from a loose one, and carries a trust score from usage feedback and age.
Checks on save and read. Draft and deprecated content is labelled
untrusted/deprecatedin every response, secret patterns are rejected on save, and a card that conflicts with an existing one is refused instead of silently overwriting it.
The agent searches before it works, reports whether a card helped, and saves what it learned as a draft. You decide what a draft becomes:
Related MCP server: memex
Tools
Tool | What it does |
| Find cards by keywords or a pasted error message; returns compact results with a |
| Read one card in full (also available as the resource |
| Save a new card as a draft. |
| Verify, deprecate or reconfirm a card; agents should call it only when you tell them to. |
| Report whether a card helped: |
There is also one prompt, distill_project_knowledge, which guides an agent through turning an existing
project's docs and history into draft cards.
Quickstart
Five steps from an empty knowledge store to your first trusted card:
Register the server and the usage instructions with every agent CLI found on your machine (Claude Code, Codex, Gemini CLI). The first command only prints what it would do:
npx -y cardloom-mcp install npx -y cardloom-mcp install --yesinstall --yesregisters the server for all your projects and adds the instruction block between<!-- cardloom:start -->and<!-- cardloom:end -->in~/.claude/CLAUDE.md,~/.codex/AGENTS.md(or$CODEX_HOME/AGENTS.md) and~/.gemini/GEMINI.md. It never touches acardloomentry that runs another command, and running it again finishes whatever failed without duplicating the block (see Set it up once for all projects). To register by hand for one project instead:claude mcp add cardloom -- npx -y cardloom-mcpRun
npx cardloom-mcp doctorto see the store path and card counts by status. If there are no verified cards, it points you back to this quickstart. The check is read-only.Ask your agent to save one gotcha it just hit, for example: "Save what we learned about this error as a gotcha card, and put the exact error message in
error_signature." The agent callssave_learning_draft; the card lands asdraft.Approve it in chat: "Verify that card." The agent calls
update_card_statuswith actionverify. Until you do this, the draft stays out of default search (see Approving knowledge in chat).Search for it: ask the agent to call
search_knowledgewith the exacterror_signaturetext you saved. With default settings the card comes back withmatch: "exact_signature".
To label results for the repo you are working in, add a .knowledge-map.yaml at that repo's root
(details in .knowledge-map.yaml):
project: acme/billing-api
stack:
- node
domain: backendTo have your agent use the tools without being asked each time, see Enforcing usage.
Setup
The server exposes the same five tools with each setup option.
Options 2 and 3 run from a clone: git clone https://github.com/bangca85/cardloom-mcp.git && cd cardloom-mcp.
Option 1: npx (no clone, no Docker)
Needs Node 22 or newer (CI runs 22 and 24). The launcher keeps your cards in
~/.cardloom/knowledge-store and the SQLite index in ~/.cardloom/index.db; set
KNOWLEDGE_STORE_PATH / INDEX_DB_PATH to put them elsewhere.
claude mcp add cardloom -- npx -y cardloom-mcp
npx cardloom-mcp doctor # read-only health check: store path, card counts by statusclaude mcp add registers the server for the current project only; add --scope user to use it
everywhere (see Set it up once for all projects).
Other clients use the same command. Cursor (~/.cursor/mcp.json):
{
"mcpServers": {
"cardloom": { "command": "npx", "args": ["-y", "cardloom-mcp"] }
}
}Codex (~/.codex/config.toml):
[mcp_servers.cardloom]
command = "npx"
args = ["-y", "cardloom-mcp"]The SQLite driver (better-sqlite3) ships prebuilt binaries for common platforms; elsewhere npm
compiles it, which needs a C++ toolchain.
Option 2: Docker
Build the server:
npm install npm run buildBuild the container image:
docker compose buildRegister the server with your MCP client using the wrapper script at
bin/cardloom-mcp.sh— use an absolute path, since MCP clients spawn the command with an arbitrary working directory and the wrapper needs to finddocker-compose.ymlregardless.Claude Code:
claude mcp add cardloom -- /absolute/path/to/cardloom-mcp/bin/cardloom-mcp.shCursor (
~/.cursor/mcp.json):{ "mcpServers": { "cardloom": { "command": "/absolute/path/to/cardloom-mcp/bin/cardloom-mcp.sh" } } }Codex CLI / Codex extension (VS Code) (
~/.codex/config.toml):[mcp_servers.cardloom] command = "/absolute/path/to/cardloom-mcp/bin/cardloom-mcp.sh" args = []Or via the Codex Settings UI → MCP servers → Connect to a custom MCP (writes to the same
config.toml): Namecardloom, TypeSTDIO, Command to launch =/absolute/path/to/cardloom-mcp/bin/cardloom-mcp.sh, leave Arguments/Environment variables/Working directory empty, Save.Verify: ask your client to list MCP tools. You should see exactly 5 —
search_knowledge,get_card,save_learning_draft,update_card_status,report_card_usage— plus one resource template,knowledge://card/{id}, and one Prompt,distill_project_knowledge(see Ingesting an existing project).
Each MCP session starts a fresh container (docker compose run --rm -i) that exits when the client
disconnects. Cards live in ./knowledge-store (a bind mount: human-editable and git-tracked). The SQLite
index lives in a separate named Docker volume, because a SQLite file on a macOS bind mount is unreliable;
never touch it by hand, it is fully disposable and rebuilds from knowledge-store/ (see
npm run rebuild-index).
Option 3: Native from a clone (no Docker)
Docker on macOS runs a Linux VM (Virtualization.framework) underneath, which reserves several GB
of RAM regardless of how small the container's own workload is. The server itself is light —
measured at ~100MB RSS for the MCP process and ~71MB for the web viewer, both idle at 0% CPU — so
running directly on the host with plain node skips the VM overhead entirely.
npm install
npm run buildRegister the server with your MCP client using node directly instead of the Docker wrapper:
{
"mcpServers": {
"cardloom": {
"command": "node",
"args": ["/absolute/path/to/cardloom-mcp/dist/index.js"],
"env": {
"KNOWLEDGE_STORE_PATH": "/absolute/path/to/cardloom-mcp/knowledge-store",
"INDEX_DB_PATH": "/absolute/path/to/cardloom-mcp/.metadata/index.db"
}
}
}
}Trade-off: you lose container isolation, and git commits use your host's git config. The SQLite
index and its write lock live on your local filesystem, so there is no bind-mount quirk to worry about.
Configuration
Every setting is an environment variable and every one is optional.
Variable | Default | Meaning |
|
| Where cards ( |
|
| The SQLite index. Derived data, safe to delete. |
|
|
|
|
| Result order: |
|
| A verified card older than this is flagged |
|
| A card with this many |
|
| Recorded as |
| the host name | Names this machine's usage log ( |
| off |
|
| beside the index | Absolute path of the telemetry file. Refused if it is inside the knowledge store. |
| off |
|
| see Merge promotion | Control |
|
| Web viewer port. |
| empty, | Web viewer graph tuning. |
How search works
search_knowledge(query, context) takes keywords or a pasted error message. context carries the
calling repo's stack, versions, project and aliases (see
.knowledge-map.yaml).
Each result says how it matched:
| Meaning |
| The card's |
| Your query contains an identifier from the card's |
| Your query is the card's whole title. |
| Every word of your query is in the card. |
| Only some of the words match. |
When all returned cards are partial matches, the response includes no_direct_match: true. Use those
cards as leads for a follow-up search, not as an answer. Set SEARCH_FALLBACK=off to get only cards that
match all words.
search_knowledge returns at most 5 cards by default (it was 10 in earlier versions). Pass limit for more,
for example limit: 10. With the tiered fallback, partial matches are added only when fewer than limit cards
match every word.
Search results stay compact and do not carry source: adding repo, commit and approval date to every result
raised the estimated response size by about 17% at limit 5. get_card returns it for the one card you read:
source: { repo, commit, approved_at }. repo is the card's source_repo, else the first applies_to entry when that looks like owner/name (a guess; component
names such as api give null);
commit is the sha found in source_commit, shortened to 7 characters; approved_at is the date part of
last_verified (null for a draft). Each field is null when it is unknown.
By default only verified, non-restricted cards are returned. include_drafts, include_deprecated and
include_restricted opt in, and those cards are always labelled. Each result also carries a trust score
and flags: drift (the card's version range does not match the caller's), stale and needs_review.
With a project in the context, results also say whether a card belongs to this project, is shared, or
applies to another project; cards for other projects are never hidden.
Ranking. The default (SEARCH_RANKING=baseline) orders results by stack and version match, then text
relevance, then trust. The x and y modes also rank by project. They are opt-in because, in our
benchmark, putting the project ahead of the text score pushed exact matches from shared cards below weaker
matches from the caller's own project. Run npm run benchmark -- --matrix against your own store before
enabling them.
What is tested
tests/integration/trust-guarantees.test.ts checks the JSON
that search_knowledge and get_card return, not internal objects, for these behaviours:
Filtered by default. A default search does not return draft, deprecated or restricted cards, and does not return a card that has been superseded.
Labelled when requested. With
include_drafts, a draft is returned withuntrusted: true; withinclude_deprecated, a deprecated card is returned withdeprecated: true; withinclude_restricted, a restricted card is returned withrestricted: true.get_cardlabels the same three cards the same way (and returns thedeprecation_reason).Flagged when old. A card last verified more than
STALE_THRESHOLD_DAYSago carriesflags.stale: truein search results (the test uses a card verified 400 days before a fixed date).Replacement reported.
get_cardon a superseded card names the card that replaced it inreplacement.superseded_by.
The test shows what the server returns and how it labels it. Whether an agent acts on those labels is not covered by this test.
.knowledge-map.yaml — giving the agent context per repo
Add a .knowledge-map.yaml to the root of each project you work on. Your agent reads it and passes the
project and stack details to search_knowledge, so results are matched against your stack and versions:
# .knowledge-map.yaml — lives in the root of each project repo you work in
project: acme/billing-api
aliases: # optional: other names this project has had in existing cards
- billing-api
stack:
- nextjs@15
- postgres@16
- node
domain: backendproject: is the key the agent passes as context.project (and aliases: as context.aliases)
so results are labelled by scope (this project, shared, other project); they are ranked by project
only when SEARCH_RANKING is set to x or y. Cards for other projects are never hidden.
Older maps that use repo: instead of project: are still accepted by clients.
Workflow for a brand-new repo:
Ask the agent to inspect the repo (package.json, lockfiles, etc.) and generate a draft
.knowledge-map.yaml.Review and edit it yourself — fix wrong stack detection, add domain hints.
Commit it into the project repo (not
cardloom-mcp).Point your agent/client at it so
search_knowledgecalls includecontext: {stack, versions, project, aliases}read from that file.
Session context
npx cardloom-mcp context prints a short list of the verified cards that matter for the project you are
standing in, so an agent starts a session already knowing them. It is meant for a Claude Code SessionStart
hook, whose output is added to the session. It is opt-in: nothing registers it unless you do.
What it prints (nothing else, and nothing at all when the list would be empty):
# Cardloom: verified cards for acme/billing-api
- Retry payments at most twice (pattern-payment-retry): Retry a payment request at most twice, then surface the error.
- Lock before writing (gotcha-write-lock): Take the write lock before touching the index.
Use search_knowledge/get_card for details.Which cards:
verifiedandsensitivity: normalonly, and only cards of this project (theproject:key of.knowledge-map.yamlin the current directory, or one of itsaliases:), global cards, and stack-scoped cards whose stack intersects the map'sstack:. Drafts, deprecated, restricted, stale and needs-review cards are never printed. Without a.knowledge-map.yaml(and without--project <key>, which replaces the map) it prints nothing.Order and size: highest trust first, then most used, then id. At most 5 cards (
--max-cards) and an estimated 800 tokens in total (--max-estimated-tokens; the figure is an estimate, characters divided by 4, not a tokenizer count). Each summary is the first sentence of the card, at most 160 characters. Cards are dropped from the end until the output fits; if not even one fits, nothing is printed.Read-only: it opens the existing index (
INDEX_DB_PATH,~/.cardloom/index.dbby default) for reading and never builds, migrates or creates anything, not even the-walfiles of a WAL index. If the index is missing, unreadable or from an older version, or the store is empty, it prints nothing and exits 0, so a session never breaks. Start the server once to have an index (thenpxserver builds~/.cardloom/index.db).npm run rebuild-indexfrom a clone builds the clone's own index (<store>/.metadata/index.dbunlessINDEX_DB_PATHis set), which is not the file the hook reads unless both point at the sameINDEX_DB_PATH.
Register it with one command (it prints the plan; add --yes to apply):
npx cardloom-mcp install --hooks # plan: shows the change to ~/.claude/settings.json
npx cardloom-mcp install --hooks --yes # applies it--hooks alone changes only ~/.claude/settings.json (Claude Code; codex and gemini have no hook here). The file
is parsed strictly and an invalid one is refused and left untouched; everything else in it, and its indentation, are
kept, and running it again does not add a second entry. To use it together with the normal setup, add --agent
(for example install --agent claude --hooks --yes). To do it by hand, add this to ~/.claude/settings.json:
{
"hooks": {
"SessionStart": [
{ "hooks": [{ "type": "command", "command": "npx -y cardloom-mcp context", "timeout": 15 }] }
]
}
}Things to know before relying on it:
Docker users get no session context. The hook runs on the host and reads the index at
~/.cardloom/index.db(orINDEX_DB_PATH), not the index in the Docker named volume, so with a Docker-only setup it prints nothing.npx -y cardloom-mcp contextmay contact the npm registry on every session start, which can slow the start of a session. For a faster hook, install the package globally (npm install -g cardloom-mcp) and register the commandcardloom-mcp contextinstead.install --hooksregisters thenpx -yform, so edit thecommandin~/.claude/settings.jsonto switch. The entryinstall --hookswrites has"timeout": 15(seconds), so a slow or offline registry cannot hold up a session start for long; an entry you wrote without a timeout is still recognised and left as it is.A custom
INDEX_DB_PATHmust reach the hook too. The hook is a separate process from the MCP server, so anINDEX_DB_PATHset only in your MCP configenvis not seen by it: it reads the default~/.cardloom/index.dbinstead, or prints nothing when that file is missing. Hook commands run in a shell, so put the variable in the command itself, for example"command": "INDEX_DB_PATH=/absolute/path/index.db npx -y cardloom-mcp context".npm run contextfrom a clone reads the clone's own.knowledge-map.yaml(the current directory) and needsINDEX_DB_PATHset to the index to read; without it, it prints nothing.
Enforcing usage (CLAUDE.md / AGENTS.md / GEMINI.md)
Nothing forces the agent to call these tools — MCP tools only fire when the model decides to. To have your agent search before answering, report whether a card helped, and save new lessons as drafts, give it the instructions below, in either of two places:
Globally, once for every project: put the block in your client's global instructions file. See Set it up once for all projects.
Per project: put it in the repo's own
CLAUDE.md(Claude Code),AGENTS.md(Codex) orGEMINI.md(Gemini CLI). Codex does not readCLAUDE.md, and Gemini CLI readsAGENTS.mdonly if you list it incontext.fileName. If several clients work in the repo, add the block to each client's file.
Use one place or the other: the same block in both only costs tokens.
## Knowledge Hub (MCP `cardloom`) — required
**Before answering/implementing a task touching a known domain** (auth, rate-limiting,
third-party API contracts, infra gotchas, etc.): call `search_knowledge(query, context)` first,
with `context` read from `.knowledge-map.yaml` at this repo's root (`stack`, `versions`, and
`project` / `aliases` so results are labelled for this repo). A result with `match: related`,
or a response with `no_direct_match: true`, is a partial match: use it as a lead for another search, not as an answer.
**If that file doesn't exist yet**, generate a draft yourself before proceeding — inspect this
repo's manifest (package.json / pubspec.yaml / go.mod / requirements.txt, lockfiles) for the
real stack + versions, write it in this shape, then ask the human to review before you rely on it:
```yaml
# .knowledge-map.yaml — repo root, human-reviewed after you draft it
project: <owner/repo-name>
aliases: [] # optional: other names this project has had in existing cards
stack:
- <tech>@<version>
- <tech>@<version>
domain: <frontend|backend|infra|product|...>
```
Don't re-derive something a `verified` card already answers. When a returned card from another project helps, say which project and commit it came from (`get_card` shows its "source").
**After using a returned card — you MUST call `report_card_usage(id, outcome)`**
(`confirmed`/`refuted`/`neutral`). This is not optional — every search/get_card response carries
a `write_back_reminder`; skipping it lets trust scores and `needs_review` flags drift stale.
**Learned something new** (a decision, pattern, or gotcha with no existing card, or a refinement
of an existing one) → call `save_learning_draft`. It always lands as `draft` — never verify it
yourself. Put a bare commit sha in `source_commit` and the repo's GitHub `owner/name` in
`source_repo` whenever the learning comes from a commit: that is what lets merge promotion find
it. Free text there ("working tree", "local changes") means the card can only ever be approved by hand.
**Found a major mismatch between a `verified` card and current reality** (the card says A, the
code/logs/API actually do B — a real contradiction, not a nuance): **stop, don't silently trust
either side.** Lay out:
- which card, what it currently claims (`id` + summary)
- what you actually observed (specific file/log/response)
- the two possible resolutions: the card is stale/wrong → deprecate it + save a new card with
`supersedes`, or the code is the regression → fix the code and leave the card as-is
then ask for confirmation on which direction before calling `update_card_status` or
`save_learning_draft(supersedes=...)`. Don't decide alone when the mismatch affects an
architecture or security call.Set it up once for all projects
npx -y cardloom-mcp install --yes does everything in this section for the agent CLIs it finds on PATH
(--agent claude|codex|gemini limits it, and it can be repeated). Without --yes it prints the plan and changes
nothing.
It skips registering when a server named exactly
cardloomalready runscardloom-mcp(for Claude Code only a user-scope entry counts: a local or project-scope one is not global, socardloomis registered again at user scope), and writes the instructions anyway. Ifcardloomexists with another command (a dev checkout, say), it leaves that entry alone, says so, and writes no instructions for that agent. A server namedcardloom-devis not touched.The instruction block goes between
<!-- cardloom:start -->and<!-- cardloom:end -->; text outside the markers is never changed and a second run replaces the block instead of adding another. If a marker is unmatched or repeated, that agent fails and its file is left as it was. A file that already has the## Knowledge Hub (MCP `cardloom`)section pasted without markers is left alone too, with a note saying to wrap it in the markers or delete it so a later run can keep it current.Any agent that fails makes the command exit 1 with a summary; run it again to finish the rest.
Even without
--yesit runsclaude mcp get cardloomandgemini mcp list(andcodex mcp list --json) to see what is registered, and the first two may start the MCP servers you have configured. They run from an empty temporary directory, so only user-level entries are seen.
To do it by hand, register the server for every project and put the instruction block above in the client's global file:
Client | Register the server for all projects | Global instructions file |
Claude Code |
|
|
Codex (OpenAI's coding agent) |
|
|
Gemini CLI |
|
|
Scope matters.
claude mcp addandgemini mcp addregister the server for the current project only unless you pass--scope user, so the Quickstart command is project-scoped.codex mcp addwrites~/.codex/config.toml, which is already global.Codex. Use
~/.codex/AGENTS.override.mdfor a temporary global override without touching the base file. If you setCODEX_HOME, both files live there instead of~/.codex.Gemini CLI. You can also add the server by hand to
~/.gemini/settings.json(merge it with what is already there):{ "mcpServers": { "cardloom": { "command": "npx", "args": ["-y", "cardloom-mcp"] } } }To make Gemini CLI read an
AGENTS.mdas well, set"context": { "fileName": ["AGENTS.md", "GEMINI.md"] }in the same file.ChatGPT. The ChatGPT chat apps do not read these files; Codex is the OpenAI client covered here.
Check it worked. Run
claude mcp list,codex mcp listorgemini mcp listand look forcardloom, then ask the agent to list its MCP tools. In Gemini CLI,/memory showprints the instructions it loaded.
Approving knowledge in chat
Every card an agent saves via save_learning_draft starts in status: draft and stays out of default search
until it is verified. To promote or retire one:
Approve: tell the agent to approve a card; it calls
update_card_status(id, "verify"). Status flips toverified, and if the card declaredsupersedes: <old-id>, the old card is deprecated in the same operation (one commit). If that old card was already replaced by another card, the approval is refused withinvalid_transition(<old-id> is already superseded by <other-id>) and nothing changes; the draft stays a draft and can still be deprecated.Reject / retire: tell the agent to deprecate a card with a reason; it calls
update_card_status(id, "deprecate", reason). The file is kept (a retired card is never deleted) and disappears from default search, but stays readable viaget_card.Reject a draft: when the learning is wrong, a duplicate or not worth keeping, start the reason with
rejected:(for examplerejected: duplicate of pattern-foo). The web viewer's "Reject" button on a draft does this for you.distill_project_knowledgereads that prefix and tells the agent not to save the same learning again unless the new draft says what is different.
Re-confirming old cards
A verified card last verified more than STALE_THRESHOLD_DAYS ago is flagged stale. If you check it and it is
still right, re-confirm it instead of verifying a new card: update_card_status(id, "reconfirm") keeps the card
verified, sets last_verified to now and writes verification_method: reconfirmed:<previous method> (one
prefix, however many times). Nothing else changes: not the status, not verified_by, not the usage counters.
It is refused for a card that needs review (refuted REVIEW_FAILURE_THRESHOLD times or more): supersede it with
a corrected card instead. From the shell:
npx cardloom-mcp reconfirm --stale # list stale cards, oldest first, with id, title, age and a hash (--json for scripts)
npx cardloom-mcp reconfirm --confirm pattern-a@<hash>,gotcha-b@<hash> --by alice--confirm re-confirms each id@hash it is given and refuses an entry whose card file changed since it was listed
(the hash is checked under the write lock), has an unknown id, or needs review; the other entries are still applied,
each refusal is printed on stderr and the exit code is 1. --by defaults to REVIEWER_NAME and is recorded in
the git commit message (knowledge: reconfirm <id> (by <name>)), not in the card file; the name is trimmed to one line of at most 80 characters.
Through update_card_status, by is optional and defaults the same way. From a clone: npm run reconfirm -- --stale.
npm run doctor shows how review is going: drafts waiting (and the age of the oldest), cards approved by
a human, by merge promotion, rejected, and retired before review, and the human approval rate (of drafts a
human approved or rejected; merge promotion and retired drafts are listed beside it, not in it). A card counts
as merge promotion only when its verification_method is exactly what promote-merged writes in auto mode
(merged:<repo>@<sha> (<via> <date>)); the same evidence with +chat-approval after it, which is what you get
when you approve a candidate in chat, counts as a human approval. reconfirm does not change who first approved a card, so a re-confirmed auto-promoted card still counts as merge promotion. A draft's
age is counted from the commit that added the card when the store is a git repository, otherwise from the
card file's modification time.
deprecated is terminal — there's no un-deprecate. To bring a retired idea back, save a new card
with supersedes pointing at the old one and approve it.
Triaging drafts
npx cardloom-mcp triage (or npm run triage-drafts from a clone) lists every draft with the cards you may
want to look at before deciding: same type and a similar title (Jaccard overlap of the title words, 0.5 or
more) or overlapping facets, plus the card the draft supersedes (shown as this draft replaces it). Each line shows the card's status, title
similarity, whether the facets overlap and whether it is the same project. It also says when that card was
already replaced (superseded by <id>) or rejected. Drafts with nothing to compare are listed under "No
related card". The report is evidence only: it gives no verdict and changes nothing, and facet overlap does
not predict what verify will do (verify does not run the conflict check). --limit <n> examines only the
oldest n drafts; --json prints the report as JSON. It reads the card files, not index.db, so it works
without the server running.
Reading the report
npx cardloom-mcp report shows what the store did in the last 7 days (--days <n> for another window, up to 36500, --json for
scripts): how many times cards were reported confirmed, refuted and neutral, the five cards confirmed most
often, cards that now need a look, verified cards that go stale within 30 days, and how many drafts are waiting.
$ npx cardloom-mcp report
Last 7 days: 3 confirmed · 1 refuted · 1 neutral
Cards that helped most
pattern-retry-payments · Retry payment requests with backoff (3)
Cards that need a look
gotcha-old-config
Cards going stale within 30 days
gotcha-old-config
Drafts waiting: 1 (oldest 0 days)"Cards that need a look" lists cards whose total refutes reached REVIEW_FAILURE_THRESHOLD (default 2) and that
were refuted at least once inside the window. "Going stale" means the card's last verification is between
STALE_THRESHOLD_DAYS minus 30 days (exclusive) and STALE_THRESHOLD_DAYS (default 180, inclusive) old. With no
usage at all in the window it prints No activity in the last N days. instead of the counts. The numbers come from
the usage events in events/*.jsonl (the same ones that feed the trust counters); the report is read-only, never
creates the store and works without the server running.
Checking an upgrade
Before bumping a dependency, ask which verified cards it affects. Run this in a repo that has a
.knowledge-map.yaml whose stack lists the tech with a
version (nextjs@14.2.0), and pass the version you are moving to:
$ npx cardloom-mcp upgrade-check --to nextjs@15.0.0
nextjs 14.2.0 -> 15.0.0
Stop applying (1)
pattern-old · Old routing rule
Start applying (1)
pattern-new · New caching default
Apply to both (1)
pattern-both · Image config applies to bothCards are matched on the card's version_range with the same rule search uses for its drift flag. Only verified,
non-restricted cards that name the tech in their stack and have a version_range other than * are listed, sorted
by id, at most 20 per list (a list that reached 20 says so). --to can be repeated for several techs; a tech that
is not in the map, or that has no version there, is an error naming it. --json prints the result as an array of
{ tech, from, to, stopApplying, startApplying, stillApplying } with card ids. It reads the card files, changes
nothing, and works without the server running.
Knowledge gaps
gaps answers "what do agents ask that the store cannot answer?". It is built on opt-in local telemetry, which is
off by default: with CARDLOOM_TELEMETRY unset the server never creates or writes the file.
$ CARDLOOM_TELEMETRY=local CARDLOOM_TELEMETRY_SAMPLES=1 npx cardloom-mcp # in your agent's MCP config env
$ npx cardloom-mcp gaps
5 searches since 2026-11-20T09:12:00.000Z
answered: 2
related only: 1
empty: 2
Questions with no direct answer
how to rotate the signing key (2)
retry budget for webhooks (1)What is recorded, one JSON line per search_knowledge call: the time (UTC), the tool name, how many results came
back, the outcome (answered: at least one direct match; related_only: only partial matches; empty: nothing),
and the search time in milliseconds. That is all.
What is never recorded: card ids, results or their text, the context you pass, repo names. The search text is
recorded only when CARDLOOM_TELEMETRY_SAMPLES is 1 or true, only for searches that were not answered, cut to
200 characters, and left out when the secret scan flags it. The scan catches common credential formats only, and its
patterns are case-sensitive: a lower-case password: hunter2hunter2 line or a Slack-style xoxb-... token is not
caught. It does not remove customer names or internal terms either, which is why the text is a second opt-in.
Turn it on only if you are comfortable with questions typed by an agent being written to your disk.
Where the file lives: telemetry.jsonl next to the index (INDEX_DB_PATH's folder: ~/.cardloom with npx, the
cardloom-metadata volume in Docker), or exactly where CARDLOOM_TELEMETRY_PATH points (an absolute file path; a
relative value is ignored with a note on stderr). It is created with mode 0600 (owner read and write only). The
server refuses to write it inside the knowledge store, which is a git repository you might git add -A: if the
resolved path is the store or below it (symlinks are followed), nothing is created, one [telemetry] line goes to
stderr per process, and searches are unaffected. That is what happens when INDEX_DB_PATH is unset (the index then
sits in <store>/.metadata, as with npm start and npm run dev) and with the example .env, whose INDEX_DB_PATH
is under the store; set INDEX_DB_PATH or CARDLOOM_TELEMETRY_PATH outside the store to record. Nothing in trust, flags or ranking reads the file. Lines older than 90 days are
dropped, at most once per UTC day per server process. A failed write never changes a search response; it prints one
[telemetry] line on stderr per process at most. benchmark never records, even with the switch on.
npx cardloom-mcp gaps (or npm run gaps) reads the file. With Docker the file is in the named volume, which the
host cannot see, so npx cardloom-mcp gaps on the host says No telemetry yet; run
docker compose run --rm cardloom-mcp npm run gaps instead.
--json prints the report as JSON. It needs no index or
store and creates nothing. When the resolved path is inside the knowledge store it says Telemetry is not recorded while the index is inside the knowledge store. Set INDEX_DB_PATH or CARDLOOM_TELEMETRY_PATH outside it. Without the file it says No telemetry yet. Set CARDLOOM_TELEMETRY=local to start recording.
"Questions with no direct answer" lists the unanswered texts (lower-cased, whitespace collapsed, same text grouped)
by count, at most 10; when no line carries text it says search text is not recorded and how to turn it on.
Ingesting an existing project
Use the built-in prompt distill_project_knowledge to turn a repo's docs, architecture decisions, git
history and debug logs into draft cards:
Invoke it from any MCP client that supports prompts (Claude Code does), optionally with
project_path(defaults to the current directory), and let the agent run it.The prompt instructs the agent to enumerate sources exhaustively (not just CLAUDE.md's condensed summaries — the full numbered decision list a summary points at, every story file's Debug Log section, full git history, claude-mem if present), report a source survey with an estimate of how many lessons each source contains before saving anything, dedupe against existing verified cards via
search_knowledge(usingsupersedeswhere a lesson is refined rather than new), and present cards in small batches for you to approve.All cards still land in
draft— nothing getsverifyd without you approving in chat.
Merge promotion (npm run promote-merged)
promote-merged finds drafts whose source commit reached its repo's default branch after the draft was
written. By default it lists them for you to approve; in auto mode it verifies the eligible ones itself.
It runs on the host because it reads your other clones and calls gh, which the container cannot.
| What happens |
| Nothing. |
| Lists merged drafts as candidates. You approve in chat; the agent calls |
| Verifies the eligible ones itself, |
"Merged" means the commit entered the default branch AFTER the card was written (card date =
its knowledge: add commit in the store). A card about code already on main records main's
HEAD, which is trivially "merged"; counting that would verify every observation on save. How a
commit's arrival is dated: on the first-parent line → its own date; brought in by a merge → the
merge commit's date; not in the clone at all (squash merge) → the GitHub pull request's merged_at.
A commit pushed straight to the default branch also counts: that is evidence about the commit's history,
not proof that anyone reviewed the card.
auto never verifies, and always leaves as a candidate:
a type outside
PROMOTION_AUTO_TYPES(defaultdecision,pattern— a merge is evidence about the change itself, not about a third-party system a gotcha describes);a
restrictedcard;a card with
supersedes— verifying it deprecates the old card, and an unapproved draft must never kill a verified card.
Skipped outright: source_commit without a sha, a learning from uncommitted work on top of a sha,
a commit not merged yet, a repo that cannot be found.
Env | Default | Meaning |
|
|
|
| — |
|
|
| card types |
|
|
|
|
|
|
npm run build
npm run promote-merged -- --dry-run # auto mode prints would_verify, writes nothing
npm run promote-merged -- --mode=review --jsonNote: an auto-verified card can be undone only like any verified card —
deprecateit, orgit revertitsknowledge: verifycommit in the store andnpm run rebuild-index. There is no way back todraft.
Host sync (git push/pull)
The server only commits locally: it never pushes, pulls, or touches remotes or SSH keys, so
credentials never need to be inside the Docker container. To sync between machines, run
git pull --rebase and git push from your host. Use the path of your store: ~/.cardloom/knowledge-store
with npx, or <clone>/knowledge-store otherwise.
# ~/.zshrc or ~/.bashrc
alias ksync='git -C ~/.cardloom/knowledge-store pull --rebase && git -C ~/.cardloom/knowledge-store push'Run ksync whenever you switch machines, or automate it with cron/launchd:
# crontab -e — sync every 15 minutes
*/15 * * * * git -C /path/to/your/knowledge-store pull --rebase && git -C /path/to/your/knowledge-store pushSet up knowledge-store as its own git repo with a private remote (GitHub, etc.) from the
host, not from inside the container:
cd ~/.cardloom/knowledge-store # or <clone>/knowledge-store
git remote add origin git@github.com:you/your-private-knowledge.git
git push -u origin HEADDo not commit your real knowledge-store/ to this project repository. It can contain private
project names, decisions, error logs, source references, and SQLite runtime files. Keep it in a
separate private repo or local-only directory.
Web viewer
A local List and Graph view of your cards, served at http://127.0.0.1:3334. From a clone run
npm run web (with the same KNOWLEDGE_STORE_PATH and INDEX_DB_PATH as the server); with Docker run
docker compose up cardloom-web. The npx launcher starts only the MCP server.
Rebuilding the index
If index.db ever goes missing or looks wrong, rebuild it from scratch — cards/*.md and
events/*.jsonl are the only source of truth, the index is 100% derived and disposable:
npm run build && npm run rebuild-index
# or, in the container:
docker compose run --rm cardloom-mcp npm run rebuild-indexBenchmark
Your benchmark is benchmark/queries.yaml inside your store, committed alongside your cards. It is a
plain YAML list:
- query: "how do I retry a failed network request"
expected: pattern-retry-with-backoff # card id this query should return as top-1
context: # optional, same shape as search_knowledge's context
stack: [node]
- query: "TypeError: Cannot read property 'foo' of undefined"
expected: gotcha-foo-undefined-crashEach entry may also carry a kind (default known, so entries with just query + expected keep
working), an expected list, and forbidden ids:
- query: "retry policy for payments"
kind: project_decision # known | missing | project_decision | cross_project | superseded | stale | drift | wrong_scope
expected: decision-payments-retry
forbidden: [decision-billing-retry] # top-1 here counts as a wrong-project answer
context: { project: acme/payments-api, stack: [node] }
- query: "how do we shard the queue"
kind: cross_project
expected: [pattern-queue-sharding, gotcha-hot-partition] # recall@5 counts any of these
- query: "zqxv7000 error"
kind: missing # no card should answer this; no `expected`Per kind the report gives n plus: known / cross_project hit@1, MRR@5, recall@5 (any id in
expected); missing falseAnswerRate (share whose top-1 is not labelled related) and
anyResultRate (share returning at least one result); project_decision hit@1 and
wrongProjectTop1Rate (share whose top-1 is in forbidden). To compare ranking modes before changing
SEARCH_RANKING, look at wrongProjectTop1Rate (project_decision) and recall@5 (cross_project).
Four more kinds score the failures around old, outdated and out-of-scope answers, each as a separate metric so you can tell which part failed (the default-visibility top 5 is what a caller sees):
- query: "retry policy"
kind: superseded # a newer card replaced an older one
expected: decision-retry-v2
replaced: decision-retry-v1 # required: the card `expected` replaced
- query: "how do we invalidate the cache"
kind: stale # expected card is old; it should come back flagged stale
expected: pattern-cache-invalidation
- query: "api pagination"
kind: drift # expected card's version range misses the caller's versions
expected: pattern-api-pagination-v2
context: { stack: [node], versions: { node: "3.1.0" } } # `context.versions` is required
- query: "lookup cache"
kind: wrong_scope # another scope's card must not rank first
expected: pattern-python-cache
forbidden: [pattern-node-lookup-cache] # required, non-empty
context: { stack: [node] }visible(replacedVisibleRate, superseded): share of queries wherereplacedshows up anywhere in the top 5, with or without a label. It is a visibility failure: a retired card should not be returned at all. Superseded also reports hit@1 and MRR@5 onexpected.retrieved(retrievedRate, stale and drift): share of queries withexpectedin the top 5, which isolates retrieval from flagging.flag acc(flagAccuracy, stale and drift): among the retrieved cards, the share carryingflags.stale(stale) orflags.drift(drift). It is 0 when nothing was retrieved.wrong@1(wrongScopeTop1Rate, wrong_scope): share whose top-1 is aforbiddenid, flagged or not. It is a ranking failure. Wrong_scope also reports hit@1 andwrongTop1FlaggedRate(printedflagged@1), the share of those wrong top-1s that carryflags.drift; it is a diagnostic, not a pass/fail rate.
The text report prints these as visible=, retrieved=, flag acc= and wrong@1=, and --matrix
shows them as visible, retrieved, flag acc and wrong@1 cells.
--synthetic skips queries.yaml and derives a suite from the store (verified + normal cards
only): title (verbatim), title_nl (the first seven title words inside a question template), sig_noisy (a noisy pasted
error line, gotchas only) and 100 missing queries built from fabricated tokens, each checked to
have zero full-text hits. --matrix runs the same queries under baseline/off,
baseline/tiered, x/tiered and y/tiered (ranking/fallback) and prints one row per config:
npm run build && npm run benchmark -- --synthetic --matrixA plain run (no --limit) reports at the tool's default limit, 5, so its numbers describe what an agent gets
from search_knowledge without passing limit; --limit and --compare-limits are unchanged. --limit <n>
runs the benchmark with search_knowledge's limit set to n (the report then also shows
recall@10 when n is 10 or more). --compare-limits runs every query twice, once with limit 5 and once with
limit 10, for each ranking (baseline, x, y), and prints one table per ranking: recall@5 per kind for the
limit-5 run, recall@5 and recall@10 for the limit-10 run, hit@1 and each kind's own metric for both, and the
estimated response size of both runs (mean and p95 tokens). Both are real runs, never "run 10 and cut to 5",
because with the tiered fallback limit decides whether the OR tier runs at all: when the AND tier already
returns limit cards, the OR tier is skipped, so a card that only matches some terms can appear at 10 and
not at 5. Token figures are estimates (the JSON search_knowledge returns, characters divided by 4), not a
tokenizer count. The two flags cannot be combined, and an offline fixture to try them on lives in
tests/fixtures/benchmark-store:
npm run build && npm run benchmark -- --compare-limits
KNOWLEDGE_STORE_PATH=tests/fixtures/benchmark-store npm run benchmark -- --compare-limitsWrite queries the way you'd actually ask — real questions, real pasted error messages — each pointing at the card id you expect to come back first. Multiple queries can point at the same card.
Run it:
npm run build && npm run benchmark
# or, in the container:
docker compose run --rm cardloom-mcp npm run benchmarkEach run builds its own throwaway in-memory index from the card files in the store (it never
reads index.db, so a stale index cannot produce a false score), then prints a corpus fingerprint
line (card count, verified count, sha256 over id|status|file_mtime) before the report.
It runs every query through the exact same search_knowledge ranking path (no separate scoring
logic to drift out of sync) and reports top-1 hit rate, p50/p95 latency, and a list of misses. A
low hit rate is a signal to add facets or fix a card, not a failure. If any expected or forbidden card id in
benchmark/queries.yaml has no card in the store, the benchmark lists those ids and exits with
code 2 without scoring. Expected ids that exist but default search would never return (not
verified, or restricted) only print a warning. Other operational problems (corrupt YAML, unreadable store) exit 1. If
benchmark/queries.yaml doesn't exist yet, it says so and exits cleanly instead of erroring.
Evaluating
The benchmark above measures retrieval. Whether an agent actually answers tasks better with cardloom is a
separate question, and the repository carries a maintainer-run harness for it under
eval/README.md: three modes (top-5 search only,
search then get_card, all eligible cards in the prompt), a rubric per task, and a dry run by default because a real run
calls a paid model. It is not part of the npm package and never runs in CI. No number from its 8-task seed set is a claim
about cardloom; a number may be quoted only with its raw table and task count.
Commands
npm run build # tsc
npm run dev # tsx watch src/index.ts (runs on the host, no Docker)
npm test # vitest run
npm run rebuild-index # rebuild index.db from cards/ + events/
npm run benchmark # measure top-1 hit rate + latency against benchmark/queries.yaml
npm run doctor # read-only store health check (path, git, card counts by status)
npm run triage-drafts # read-only: drafts with the cards to compare them with
npm run upgrade-check -- --to nextjs@15.0.0 # read-only: cards affected by a version change (needs .knowledge-map.yaml in the cwd)
npm run report # read-only: what the store did in the last 7 days (--days <n>, --json)
npm run reconfirm -- --stale # list stale verified cards; --confirm <id>@<hash> re-confirms them
npm run gaps # read-only: how searches ended and what found no answer (needs CARDLOOM_TELEMETRY=local, --json)
npm run context # read-only: verified cards of the current project, for a SessionStart hook (see Session context)
npm run web # local web viewer (List / Graph view) on http://127.0.0.1:3334
npm run promote-merged # list or verify drafts whose source commit was merged
docker compose build && docker compose run --rm -i cardloom-mcpHow is cardloom different from other agent memory tools?
Memory tools such as mem0 and claude-mem let the agent write memories and read them back with no review step.
cardloom adds one: agents only save drafts, a human approves them by default, and a default search returns only approved
cards. Cards are markdown files in a git repository you own, and search runs locally without an LLM call.
Drafts, retired and restricted cards are filtered out unless you ask for them, and are labelled when returned.
Old cards are flagged stale, and get_card reports when a card has been replaced.
tests/integration/trust-guarantees.test.ts checks the search and
get_card behaviours above on the JSON the server returns. It does not test whether an agent uses them well.
Around that, upgrade-check lists the cards that stop or start applying when a dependency version changes, and report
shows what the store did in recent days. A human can re-confirm old cards in bulk with reconfirm, without re-reviewing
each one from scratch. An opt-in SessionStart hook can print a few verified cards at the start of a session.
Another tool fits better in two cases. Use mem0 or claude-mem if you want memory with no review step. Use a
plain CLAUDE.md if you have one small repository.
Contributing, security, license
Contributing: see CONTRIBUTING.md. Never commit a real
knowledge-store/, SQLite files or local agent settings; use synthetic cards in tests and examples.Security: report vulnerabilities privately as described in SECURITY.md. Treat unreviewed cards as untrusted content.
License: ISC.
Available Tools
5 toolsget_cardGet CardA
Read a single knowledge card by id — full metadata, body, trust, and status labels (draft -> untrusted, deprecated -> deprecated + reason, restricted -> restricted). Same content as the knowledge://card/{id} Resource (unless compact). "replacement.pending": a draft proposes to replace this card; it is still the current answer, tell the user. "replacement.superseded_by": read that card instead. The card carries "source" (repo, commit, approval date) — when a card from another project helps, tell the user which project and commit it came from. Every response carries a write_back_reminder: after using this card you MUST call report_card_usage(id, outcome). compact: true returns only the first 600 characters of the body (truncated: true when cut); call again without it for the full card.
Inputs: id (required), compact.
report_card_usageReport Card UsageA
Report the outcome of using a card you got from search_knowledge or get_card. This is mandatory: every card you use, you MUST report back with confirmed (it worked), refuted (it was wrong/outdated), or neutral (inconclusive). This is how trust scores and needs_review flags stay accurate.
Inputs: id (required), outcome (required), repo.
save_learning_draftSave Learning DraftA
Save a new knowledge card. Cards from an agent always start in status "draft" — verification is a separate, later action.
Inputs: body (required), type (required), scope (required), stack (required), +13 more.
search_knowledgeSearch KnowledgeA
Search knowledge cards by keyword or verbatim error message. Pass context (stack + versions read from your .knowledge-map.yaml) so results rank by facet relevance, not just text match; also pass project (and aliases) from the same file in context. Each result has a match label; match: "related" or no_direct_match: true means only partial matches were found, so use them as leads, not answers, and a hint appears when the store has no verified cards. Returns compact snippets only, never full card bodies. Every response carries a write_back_reminder: after using a returned card you MUST call report_card_usage(id, outcome).
Inputs: query (required), limit, context, include_drafts, +2 more.
update_card_statusUpdate Card StatusA
Change a card's status. action="verify" (draft -> verified, only after a human reviewer approves it) or action="deprecate" (draft/verified -> deprecated, requires reason; the file is kept, never deleted — FR3). action="reconfirm" (verified only: a human re-checked the card and it is still right; refreshes last_verified without changing status; refused for a card that needs review). deprecated is terminal, there is no un-deprecate. When deprecating a draft because the learning is wrong, a duplicate or not worth keeping, start the reason with "rejected:". Any other transition returns invalid_transition with the valid options.
Inputs: id (required), action (required), by, reason, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool maps to a clearly distinct operation: create a draft, read one card, search the store, report usage outcomes, and change card status. There is no meaningful overlap — save_learning_draft only creates (always draft) while update_card_status only transitions status, and the descriptions reinforce that boundary explicitly.
All five tools follow a consistent snake_case verb_noun pattern (save_learning_draft, get_card, search_knowledge, report_card_usage, update_card_status). The compound object in save_learning_draft is the only slight variation, but the verb-first convention holds throughout.
Five tools is a tight, well-scoped surface covering the full card lifecycle — write, read, find, validate, and moderate. Each tool earns its place and none appears redundant or vestigial.
The read/search/write/report/status loop is covered, but there is no way to revise a draft's body after saving and no listing tool for reviewing pending drafts — both notable gaps in the moderation workflow. Deletion being replaced by terminal deprecation is a deliberate design choice, not a gap.
Maintenance
Related MCP Connectors
Shared memory for coding agents. Stop re-explaining your codebase every session.
Project memory, documentation and controlled secret access for AI coding agents.
Persistent memory for AI agents. Search, store, and recall across sessions.
One memory for every AI you work with: your rules, notes and decisions in your own Git repo.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceGives AI coding agents persistent cross-session memory by storing atomic markdown knowledge cards with bidirectional wiki-links that agents recall before starting work. Syncs across clients and devices via git without any vector database or embeddings.9 npmISC
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to save insights from completed tasks as atomic markdown knowledge cards with bidirectional links, then recall relevant cards before starting new work so context carries across sessions. Cards live in a shared local directory readable and editable by humans, with optional git-based sync across devices and clients, and no vector database or embeddings required.9 npmISC
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to save and recall atomic markdown knowledge cards with bidirectional links across sessions, so learning persists and builds over time. Cards live as plain, git-syncable files readable by both agent and human, with no vector database or embeddings required.9 npmISC
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to save insights as atomic markdown knowledge cards with bidirectional links and recall relevant ones in later sessions, exposing search, read/write, backlink, and organize tools over a shared cards directory that syncs via git. No vector database or embeddings are required, and a local timeline/graph UI is included for browsing the memory network.9 npmISC