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 in
error_signature), pattern, playbook or snippet, 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/*.md and events/*.jsonl are 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 / deprecated in
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:
Tools
| Tool |
What it does |
search_knowledge |
Find cards by keywords or a pasted error message; returns compact results with a match label. |
get_card |
Read one card in full (also available as the resource knowledge://card/{id}). |
save_learning_draft |
Save a new card as a draft. |
update_card_status |
Verify or deprecate a card; agents should call it only when you tell them to. |
report_card_usage |
Report whether a card helped: confirmed, refuted or neutral. |
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 with Claude Code:
claude mcp add cardloom -- npx -y cardloom-mcp
-
Run npx cardloom-mcp doctor to 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 calls
save_learning_draft; the card lands as draft.
-
Approve it in chat: "Verify that card." The agent calls update_card_status with action
verify. 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_knowledge with the exact error_signature text you
saved. With default settings the card comes back with match: "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: backend
To 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 status
claude 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 build
-
Build the container image:
docker compose build
-
Register 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 find docker-compose.yml regardless.
Claude Code:
claude mcp add cardloom -- /absolute/path/to/cardloom-mcp/bin/cardloom-mcp.sh
Cursor (~/.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): Name cardloom, Type STDIO, 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 build
Register 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 |
KNOWLEDGE_STORE_PATH |
~/.cardloom/knowledge-store with npx, ./knowledge-store otherwise |
Where cards (cards/), usage events (events/) and your benchmark live. It is its own git repository. |
INDEX_DB_PATH |
~/.cardloom/index.db with npx, <store>/.metadata/index.db otherwise |
The SQLite index. Derived data, safe to delete. |
SEARCH_FALLBACK |
tiered |
tiered: when exact-word search finds fewer than limit cards, add partial matches labelled related. off: exact-word search only. |
SEARCH_RANKING |
baseline |
Result order: baseline or the opt-in x / y. See How search works. |
STALE_THRESHOLD_DAYS |
180 |
A verified card older than this is flagged stale. |
REVIEW_FAILURE_THRESHOLD |
2 |
A card with this many refuted reports is flagged needs_review. |
REVIEWER_NAME |
human-reviewer |
Recorded as verified_by when a card is approved. |
KNOWLEDGE_MACHINE_ID |
the host name |
Names this machine's usage log (events/<id>.jsonl) so two machines never write the same file. |
PROMOTION_MODE and the other PROMOTION_* |
see Merge promotion |
Control npm run promote-merged. |
PORT |
3334 |
Web viewer port. |
GRAPH_GENERIC_STACK_TAGS, MAX_SHARED_STACK_GROUP_SIZE, MAX_SHARED_STACK_EDGES |
empty, 50, 5000 |
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:
match |
Meaning |
exact_signature |
The card's error_signature appears in your query. It is checked on the stored text, so ERR-42 does not match ERR_42. |
exact_identifier |
Your query contains an identifier from the card's error_signature, such as ITMS-90683 or AccessDeniedException. |
exact_title |
Your query is the card's whole title. |
all_terms |
Every word of your query is in the card. |
related |
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.
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.
.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: backend
project: 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: