get_repo_memory
Retrieve the repository's .ai-memory/ as Markdown to load prior work into the LLM context, avoiding redundant tasks. Call this before starting any task.
Instructions
Return the entire .ai-memory/ of the current repo as a Markdown document
ready to drop into your LLM context. Call this before starting any task
in this repo so you don't redo work other agents already verified.
Args: fact_limit: cap on number of facts (default 50, most recent first).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fact_limit | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/repo_memory/mcp_server.py:19-28 (handler)The tool handler function for 'get_repo_memory'. It is decorated with @mcp.tool() (registration) and calls store.render() to produce a Markdown document of the repo's .ai-memory/ contents.
@mcp.tool() def get_repo_memory(fact_limit: int = 50) -> str: """Return the entire `.ai-memory/` of the current repo as a Markdown document ready to drop into your LLM context. Call this **before** starting any task in this repo so you don't redo work other agents already verified. Args: fact_limit: cap on number of facts (default 50, most recent first). """ return store.render(_REPO_ROOT, fact_limit=fact_limit) - src/repo_memory/store.py:257-298 (helper)The store.render() function called by the handler. It gathers facts, decisions, and gotchas from .ai-memory/ and assembles them into a single Markdown string.
def render(root: Path, *, fact_limit: int | None = 50) -> str: """Render the whole .ai-memory/ as one markdown document for an LLM prompt.""" if not is_initialized(root): return "_(no .ai-memory yet — run `repo-memory init`)_" parts: list[str] = [] parts.append(f"# Memory snapshot for `{root.name}`\n") parts.append(f"_Rendered at {_now()}._\n") facts = list_facts(root, limit=fact_limit) parts.append(f"## Facts ({len(facts)})\n") if facts: for f in facts: ev = f.evidence or {} ev_str = "" if ev.get("file"): lines = ev.get("lines") ev_str = f" — `{ev['file']}`{':' + str(lines) if lines else ''}" if ev.get("verified_at"): ev_str += f" (verified {ev['verified_at']})" tags = " ".join(f"#{t}" for t in f.tags) parts.append(f"- **{f.claim}**{ev_str} {tags}".rstrip() + " _\\<{}>_".format(f.id)) else: parts.append("_(empty)_") parts.append("\n## Decisions\n") decs = list_decisions(root) if decs: for p in decs: parts.append(f"### {p.stem}\n") parts.append(p.read_text(encoding="utf-8").strip() + "\n") else: parts.append("_(none yet)_") parts.append("\n## Gotchas\n") gotchas_path = _memdir(root) / GOTCHAS_FILE if gotchas_path.exists(): parts.append(gotchas_path.read_text(encoding="utf-8").strip()) else: parts.append("_(none yet)_") return "\n".join(parts) + "\n" - src/repo_memory/mcp_server.py:19-19 (registration)The @mcp.tool() decorator registers 'get_repo_memory' as an MCP tool with the FastMCP server.
@mcp.tool() - src/repo_memory/mcp_server.py:20-26 (schema)The function signature and docstring define the schema: accepts an optional 'fact_limit' (int, default 50) and returns a string.
def get_repo_memory(fact_limit: int = 50) -> str: """Return the entire `.ai-memory/` of the current repo as a Markdown document ready to drop into your LLM context. Call this **before** starting any task in this repo so you don't redo work other agents already verified. Args: fact_limit: cap on number of facts (default 50, most recent first).