Mindroot README

The full upstream README, mirrored for reference. Install config, tool schemas, adoption signals and our own overview live on the Mindroot listing page.

Mindroot

AI agents that never forget.

Mindroot persistent AI agent memory system

Mindroot is a tiny Node.js service that gives your AI agents project-scoped hybrid-searched memories over human-editable markdown notes, and reusable skills for recurring work. It exposes a local HTTP service with an MCP interface, a REST API, and a built-in dashboard. Everything runs on your machine — offline embeddings, SQLite, plain markdown files you own. No cloud, no API keys, no per-query cost.

How it works

  • Notes (Layer 2): human-editable markdown files under ~/.mindroot/notes/<project>/, parsed into heading-addressable sections such as Overview::API. The unit of storage.
  • Memories (Layer 1): short, retrieval-optimized texts that stand alone or point into a note or section via target_path. The unit of retrieval.
  • Search: memories are the semantic index — one search call returns the top matching skills and then memories, each ranked by cosine similarity (0.75) over local embeddings plus BM25 keyword search (0.25) through SQLite FTS5. Note sections are read through the sections memories point at. All content search is strictly project-scoped; project discovery uses its own fuzzy slug search with slug embeddings and token overlap.
  • Skills: project-specific Markdown procedures stored in SQLite with stable names and revision history. Skill names and descriptions have their own hybrid search index; agents load the full instructions only when a match is relevant. Saving a skill indexes it automatically, without creating memories or embedding the full procedure.

Features

  • Two-layer memory — markdown notes for depth, short memories for recall, linked via heading paths.
  • Local embeddings — 768-dimensional q8 embeddings from onnx-community/embeddinggemma-300m-ONNX via transformers.js, computed fully offline and cached under ~/.mindroot/models.
  • Hybrid search — semantic + BM25 ranking over memories and skill summaries in one call, fuzzy project-name matching across projects.
  • Project skills — agents discover and apply saved procedures, then automatically capture or improve verified procedures through the skills policy below.
  • MCP server — JSON-RPC endpoint at /mcp with 15 project/memory/note/skill tools for agents.
  • REST API — the same operations over POST/GET/PUT/DELETE /api/* for scripts and integrations.
  • Dashboard — web UI at / for browsing notes, memories, and skills, editing Markdown, and inspecting skill revisions.
  • CLI — call runs any tool exactly as a model does, tools prints the catalog models receive, plus service management.
  • Background service — mindroot start daemonizes, writes a pidfile, and waits until healthy; stop and restart manage it.
  • Self-healing reads — note reads verify a stored content hash and silently re-index files edited externally.
  • Surgical edits — update_section replaces exact text inside one section (old_string → new_string, unique unless replace_all); a miss writes nothing and reports the closest current lines.
  • Context budget — MCP results carry only what an agent can act on: writes return a receipt instead of the note, whole-note reads over 8,000 characters come back as an outline with section sizes, and oversize listings drop detail. The REST API returns full records.
  • Errors that point forward — every not-found or misuse names what exists instead (did-you-mean for projects, notes, sections, and skills) and which call to make next.
  • Link cleanup — deleting a note unlinks memories that pointed at its path or one of its sections, and reports how many.
  • Auto-created projects — any write to a new project slug creates it; no cwd detection, no disk scanning, no cross-project content search.
  • Local-first storage — one SQLite database (node:sqlite, WAL mode, FTS5) plus plain markdown files you own.
  • Security — constant-time Bearer API-key auth for every /api and /mcp request, server-side path-traversal and slug validation, localhost-only by default.

Install

Requires Node.js >= 22.

Terminal
npm install -g @sksoftofficial/mindroot   # or: npm link from a clone
mindroot init                              # creates store, schema, api key; caches the embedding model (~316MB)
mindroot start                             # daemonizes and waits until healthy

Service management

sh
mindroot start            # start in the background, wait for /health
mindroot start --foreground  # run attached for debugging
mindroot stop             # stop the pidfile process (escalates when needed)
mindroot restart          # stop + start
mindroot status           # pidfile, health endpoint, and key consistency check
mindroot dashboard        # open the dashboard in your browser

The default address is 127.0.0.1:7620, configurable in ~/.mindroot/config.json. There is no crash auto-restart.

Quick start (MCP)

For OpenCode, Claude Code, or Codex, use the one-command setup instead of manually running init and start:

sh
mindroot install opencode   # ~/.config/opencode
mindroot install claude     # ~/.claude.json + ~/.claude/CLAUDE.md
mindroot install codex      # ~/.codex/config.toml + ~/.codex/AGENTS.md

This initializes Mindroot (including the model cache), starts the background service if needed, and configures the client's global mindroot MCP entry with the local service URL and API key. It also installs the bundled INSTRUCTIONS.md policy into the client's global instructions file.

Rerunning refreshes the MCP entry and replaces the policy between <!-- mindroot:start --> and <!-- mindroot:end -->, rather than appending duplicates. Other MCP servers, configuration settings, comments, and instructions outside the marked blocks are preserved. Unbalanced policy markers or malformed configuration cause an error rather than an overwrite.

Default locations, honoring each client's directory override:

  • OpenCode: ~/.config/opencode, honoring XDG_CONFIG_HOME and OPENCODE_CONFIG_DIR. An existing opencode.jsonc takes precedence; otherwise the command updates or creates opencode.json.
  • Claude Code: ~/.claude.json and ~/.claude/CLAUDE.md, honoring CLAUDE_CONFIG_DIR (both files then live inside that directory).
  • Codex: ~/.codex/config.toml and ~/.codex/AGENTS.md, honoring CODEX_HOME. A non-empty AGENTS.override.md takes precedence and is updated instead; an empty override falls back to AGENTS.md.

Quit and restart the client afterward to load the changes. The command configures the client; it does not launch it.

Other MCP clients

Point your MCP client at the service:

config.json
{
  "mcpServers": {
    "mindroot": {
      "type": "remote",
      "url": "http://127.0.0.1:7620/mcp",
      "headers": { "Authorization": "Bearer <apiKey>" }
    }
  }
}

The API key is generated by mindroot init and stored in ~/.mindroot/config.json (never printed). Tool failures return isError: true content instead of crashing the call.

Agent memory policy

Add this policy to your agent's instructions:

markdown
<!-- mindroot:start -->
# Agent memory policy (mindroot)

Mindroot holds what earlier sessions learned about the user and each project. Keep it compact: it is memory, not a scratchpad.

## Look up first

- On any non-trivial task or new topic, `search` before you explore the source, then follow only the hits that matter: a skill, or the note section behind a memory.
- Reuse what is already in context. When memory lacks the answer or has gone stale, read the source and correct what was wrong.
- Writing to a new project slug creates the project.

## Save what cost you context

Save a fact when a later session would otherwise have to find it again:

- A file you had to search for: save its path and what lives in it, so the next session opens it directly.
- An understanding pieced together from several files: save the summary, so the next session reads one section instead of five files.
- A command, config value, convention or gotcha you had to discover, above all one that cost a failed attempt.

Never save what only matters to this task: task history, reasoning trails, rejected alternatives, dated recaps, logs, speculation, secrets.

## Notes and memories

- Search covers memories and skill summaries only; notes are found through the memories that point at them. After writing a note section, save 1–3 memories restating its key facts, each pointing at it.
- Notes are index cards: one sentence on what the feature is, then the files, entry points and data flow needed to work on it without re-reading the source. One feature per note, under keyword-rich headings (`## Model`, `## API`, `## Gotchas`), plus `overview.md`, `conventions.md`, `commands.md` and `gotchas.md`.
- Bullets are standalone present-tense facts with file anchors (`models/AuditLog.jsx` defines model `AuditLog` in collection `auditlog`), not "we decided X today".

## Keep it current

- Before your final response, write back anything durable you learned or changed: update the smallest relevant section, then its memories. No confirmation needed.
- Search before saving; update or delete a near-copy or a stale fact instead of adding beside it.
- A multi-step procedure you verified and may repeat becomes a skill: the reusable steps, not a recap of this task.
<!-- mindroot:end -->

Using skills

Automatic skill management is driven by the agent policy: the agent searches once when a task or topic starts and captures verified procedures after finishing them. Mindroot stores and retrieves procedures; it does not watch conversations or execute skills itself. Copy the policy above (also available in INSTRUCTIONS.md) into your agent's instructions.

For example, an agent can create a skill with save_skill:

config.json
{
  "project": "my-project",
  "name": "add-api-route",
  "description": "Use when adding an API route with the project's existing handler and error conventions.",
  "content": "## When to use\nAdding an API route.\n\n## Prerequisites\nRead conventions.md::API and identify the existing router.\n\n## Procedure\n1. Follow a neighboring handler's registration and error handling.\n2. Implement the requested behavior.\n3. Update the API documentation.\n\n## Success criteria\nThe route is registered and satisfies the requested behavior; follow the task's authorized validation requirements.\n\n## Pitfalls\nDo not copy credentials or request-specific data into examples.",
  "expected_revision": 0
}

When a saved procedure would help with a later API task, call search with { "project": "my-project", "query": "add an API endpoint" }, then read_skill with a relevant returned name. Skill hits carry names, descriptions, timestamps, and scores.

To improve a skill, read its latest version and save under the same name with that expected_revision. Each changed save preserves a revision; identical saves are a no-op. A stale or concurrent save returns a conflict so the agent can reread and reconcile. Use read_skill with revision to inspect an older version; to restore it, save that content using the latest revision as expected_revision. Deleting a skill removes all its revisions and index entries.

Skills are available through MCP, REST, and the dashboard. The dashboard lists saved skills and supports reading, editing, viewing revision history, and deletion. CLI content commands cover notes, memories, and search. After updating an existing installation, restart mindroot to create the skill tables and reconnect your MCP client to refresh its tool list.

CLI

The CLI drives the same tools a model does. mindroot call sends one tool call to the running service over its MCP endpoint, with the arguments object exactly as you write it, and prints the text the model receives; a failed call prints the model's error message on stderr and exits 1. mindroot tools prints the catalog the service sends to models, fetched from the service itself so it cannot drift.

CommandDescription
mindroot initInitialize store + model cache (idempotent)
mindroot install <opencode|claude|codex>Initialize, start, and configure a coding agent globally
mindroot start [--foreground]Daemonize the service (or run foreground for debugging)
mindroot stopStop the running service
mindroot restartRestart the service (stop + start)
mindroot statusShow whether the service is running
mindroot dashboardOpen the dashboard in your browser
mindroot call <tool> ['<json arguments>' | -]Call a tool with the same arguments a model would pass; - reads them from stdin
mindroot tools [<name>] [--pretty]Print the tool catalog exactly as the service sends it
sh
mindroot call search '{"project":"my-project","query":"add an API endpoint"}'
mindroot call update_section - <<'JSON'
{ "project": "my-project", "path": "conventions.md", "heading_path": "Code",
  "old_string": "the exact text to replace", "new_string": "the replacement" }
JSON
mindroot tools update_section --pretty

MCP tools

Tool names on the wire are unprefixed; MCP clients may display them with a mindroot_ prefix.

ToolParamsPurpose
list_projects—List projects with note/memory/skill counts
search_projectsqueryFuzzy-find a project by name (semantic + token overlap); at most 8 slugs
rename_projectproject*, new_slug*Rename a project; moves notes and preserves memories and indexes
searchproject*, query, skills?, memories?Hybrid search over skill summaries and memories in one call: top skills first, then memories (defaults 3 and 6)
save_memoryproject*, text, target_path?Save a memory, optionally linked to a note/section
delete_memoryproject*, idDelete a memory by id
list_notesproject*, path?List notes with section paths; with path, one note's sections with their sizes
read_noteproject*, path, section?One section's body via section, or the whole note (hash-verified, auto-reindexed); notes over 8,000 characters return an outline instead
save_noteproject*, path, content, old_content?Create a note, or overwrite one when old_content matches its current content; returns a receipt
update_sectionproject*, path, heading_path, old_string+new_string, replace_all? or content, old_content?Search/replace exact text inside one section (unique unless replace_all), or set/add the whole section body; returns a receipt
delete_noteproject*, pathDelete a note; unlinks its memories and reports how many
list_skillsproject*List a project's skills with names, descriptions, and revisions
read_skillproject*, name, revision?Read current instructions or a historical revision
save_skillproject*, name, description, content, expected_revision?Create/update and index a skill; preserve history; use revision 0 for create-only
delete_skillproject*, nameDelete a skill, its history, and its index

MCP results are trimmed for context: no timestamps, scores, or internal ids, and a write never echoes what was written. Errors say what to call instead, with did-you-mean for a misspelt project, note, section, or skill.

REST API

Same operations as MCP, for scripts and integrations. All /api/* routes (and /mcp) require Authorization: Bearer <apiKey>; /health does not.

MethodPathPurpose
GET/healthLiveness probe
GET/api/projectsList projects
POST/api/projectsCreate project { slug }
GET/api/projects/:slugProject detail with docs, memories, and skill summaries
DELETE/api/projects/:slugDelete a project
GET/api/projects/:slug/docsList notes; with ?path=, one note's sections with their sizes
GET/PUT/DELETE/api/projects/:slug/doc?path=Read (optionally &section=), write, or delete one note. Reads return the full record with section sizes; writes return a receipt
POST/api/projects/:slug/sectionsEdit one section: { path, heading_path, old_string, new_string, replace_all? } for search/replace, or { path, heading_path, content, old_content? } for the whole body
GET/POST/api/projects/:slug/memoriesList or add memories { text, target_path? }
DELETE/api/projects/:slug/memories/:idDelete a memory
GET/api/projects/:slug/skillsList skill summaries
GET/PUT/DELETE/api/projects/:slug/skills/:nameRead (?revision= optional), save { description, content, expected_revision? }, or delete a skill
POST/api/searchSearch { project, query, skills?, memories? }; returns skills, then memories
POST/mcpJSON-RPC MCP endpoint

Dashboard

The dashboard at http://127.0.0.1:7620/ stores its key in localStorage and offers:

  • Notes view with a markdown editor in Write / Split / Read modes and rendered preview.
  • Memories view for browsing saved memories, following note links, and deleting entries.
  • Skills view for browsing saved procedures, editing descriptions and Markdown in Write / Split / Read modes, inspecting older revisions, and deleting skills. Saves detect conflicting updates and preserve your draft on failure; historical revisions are read-only.

Memory creation and search are available through MCP and REST; the dashboard has no add-memory form or Search tab.

Configuration

Everything lives under ~/.mindroot/:

  • config.json — port (default 7620) and apiKey
  • notes/<project>/ — your markdown notes
  • models/ — cached ONNX embedding model
  • mindroot.db — SQLite index, skill Markdown content, and skill revisions (WAL mode)
  • mindroot.pid / mindroot.log — written by start/stop

Set MINDROOT_DIR to relocate the whole store.

Development

sh
node --test    # runs the test suite in test/

License

ISC