Product Memory

Product Memory

Provides a memory server for coding agents over MCP, capturing and retrieving the meaning and rationale behind code decisions down to the function level. It enables agents to search product memory, get task context, and propose new memories to avoid re-deriving or re-breaking past decisions.

Category
访问服务器

README

Product Memory

A what/why memory server for coding agents, over MCP. It answers what a piece of a system means and why it was built that way — down to the function level — so an agent (or you) stops re-deriving or re-breaking a decision someone already made. The current code stays the source of truth for how; this store never tries to replace it.

This repo ships with a small synthetic demo store (memory-store/) — two fictional services, orbitcart (checkout/payments) and beacon (notification dispatch) — so pm eval, the tests, and the MCP tools all run out of the box without pointing at anyone's real codebase. Point projects.yaml at your own repos to use it for real.

Get it running — no coding experience needed

1. Download it. Pick whichever is easier:

  • If you have Git: open Terminal and run git clone <this repo's URL>
  • If you don't: on the GitHub page, click the green Code button → Download ZIP, then unzip it.

2. Open a terminal inside the folder you just downloaded.

  • Mac: find the folder in Finder, right-click it, choose New Terminal at Folder (or open Terminal and type cd followed by dragging the folder in, then press Enter).
  • Windows: open the folder in File Explorer, hold Shift and right-click inside it, choose Open PowerShell window here.
  • Linux: right-click inside the folder in your file manager, choose Open Terminal Here (varies by desktop).

3. Run the setup script.

  • Mac / Linux: type bash setup.sh and press Enter.
  • Windows: type .\setup.ps1 and press Enter. If it says the script is blocked, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once first, then try again.

That's it — it installs everything this project needs (nothing system-wide, no admin password), builds the included demo, and runs a real search to prove it works. You'll see something like:

✓ Python 3 found (3.13.5)
✓ uv found
✓ Dependencies installed
✓ Demo memory store indexed

Trying a real search against the demo store...
  8.75  [adr/verified] adr-0004-idempotency-keys-generated-client-side
        ADR-0004: idempotency keys are generated client-side, not server-side

If Claude Code is already on your machine, the script will offer to connect Product Memory to it — say yes, restart Claude Code, and it's live for every project. If not, or if you use a different coding agent, see MCP tools below and point your agent's MCP config at uv run --directory <this folder> python -m product_memory.server.

Once it's running, try:

uv run pm serve             # a local web page to browse the memory
uv run pm search "your question here"

When you're ready to use it for real (not the demo), open projects.yaml and point it at your own repositories instead.

The two design bets

Nothing an agent writes is trusted on arrival. Every fact proposed via propose_memory gets status: proposed — never verified — until a human runs pm review. Trusting a wrong memory costs more than missing a right one, so the default is "written," not "true."

Ranking is measured, not assumed. pm eval scores keyword search (BM25 over SQLite FTS5) against a semantic vector index on a fixed set of real questions with known answers, and re-checks it on every run rather than settling it once. Whichever ranks better this run is the one that ranks — in the author's private corpus (1,192 items) that's keyword at 0.785 MRR vs. 0.436 for semantic-only — with the vector index only appended below it as extra recall, never reordering keyword's result. On this repo's small 12-question demo set, keyword alone already finds all 12 (pm eval → 0.819 MRR, 12/12); run pm embed first if you want the semantic/fusion rows in the comparison too. See eval/queries.json and product_memory/evaluate.py.

How memory gets populated

Never a full backfill — it would be stale before it finished. Four channels:

# Channel When What lands
1 Docs import once per repo pointers/summaries of CLAUDE.md, CONVENTIONS.md, planning docs — never forked copies
1b Doc-tree import once per large docs tree bulk import with hard filtering (drops vendored docs, stubs, duplicates, "✅ Fixed!" session reports)
2 Change-time capture every finished agent task agent calls propose_memory → lands as proposed → promoted with pm review
3 Ask-time backfill whenever you ask "why does X work like this?" the agent researches once, answers you, and proposes the answer as a memory

Layout

memory-store/           canonical store — markdown files in git, one fact each
  _inbox/               agent proposals awaiting human promotion (or auto-approved, see below)
  <project>/<repo>/     verified + promoted items
demo-repos/             tiny stub repos the demo store's code_symbol entries point at
projects.yaml           registry: project -> repos -> disk paths
product_memory/
  models.py             data contracts (MemoryItem, TaskContext, WhyCard, ...)
  store.py              parse/iterate/propose store files
  index.py              SQLite FTS5 build + ranked search (disposable index)
  semantic.py           chunking + vector index, used for recall only
  evaluate.py           `pm eval` — MRR per retrieval mode, the ranking gate
  conventions.py        derive a repo's house style (declared + observed)
  retrieval.py          packet assembly (deterministic, no LLM)
  staleness.py           flags memories whose source code/doc changed since
  server.py             FastMCP stdio server — the MCP tools
  webapp.py             FastAPI local server (`pm serve`), loopback only
  dashboard.py          the review queue UI
  ingest/                importers + secret redaction
  cli.py                `pm` — the commands below
eval/queries.json       retrieval cases with known answers
tests/

Commands

pm serve                 # live local server: real search, feedback, persisted marks
pm dashboard --open      # generate the standalone review-queue file
pm search "query"        # ranked search from the terminal
pm eval                  # score retrieval against eval/queries.json — run before ranking changes
pm conventions --project beacon --repo beacon   # derive a repo's house style
pm review                # the only path from proposed to verified
pm index && pm embed     # rebuild the keyword index and the chunked vector index
pm stale                 # notes whose source moved on

MCP tools

get_task_context · search_product_memory · get_project_overview · get_domain_rules · get_related_decisions · why_code(file, symbol) · get_recent_work · propose_memory (writes proposed, or auto-approves with redaction — see PM_REVIEW=1 to force quarantine instead)

Setup

New to this and just want it running? Use bash setup.sh (.\setup.ps1 on Windows) instead — see Get it running above. The manual steps below are the same thing, spelled out:

git clone <this repo>
cd product-memory
uv sync
uv run pytest
uv run python -m product_memory.cli eval   # or: pm eval, once installed

# register for ALL repos (user scope):
claude mcp add --scope user product-memory -- \
  uv run --directory "$PWD" python -m product_memory.server

Then point projects.yaml at your own repositories, delete or keep the demo orbitcart/beacon entries, and start capturing real memories with propose_memory as you work.

Secrets

Anything written into the store is passed through redact_secrets — a known-literals list (secret-literals.txt, gitignored, or PM_SECRET_LITERALS) plus a generic credential-shape heuristic (label + high-entropy value in proximity). The demo store ships with nothing to redact; pm eval's test suite includes a CI guard (test_demo_store_is_clean) asserting exactly that.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选