AI agents · OpenClaw · self-hosting · automation

Quick Answer

How to Set Up Code Base Memory MCP for Coding Agents

Published:

The short answer

Install codebase-memory-mcp with its script, let it configure your agent, restart, and say “Index this project”. That is the whole setup for the most-used code base memory MCP server as of November 17, 2026 (DeusData/codebase-memory-mcp, MIT, v0.12.1 released October 16, 2026, 48,751 GitHub stars). It builds a persistent local knowledge graph of code, docs, configuration and infrastructure and exposes it to the agent through 17 MCP tools, with no API key or hosted service.

Choosing between servers? See codebase-memory-mcp vs Serena vs GitNexus vs Claude Context. This guide is the setup half.

Step 1: Install the binary and agent integrations

On macOS or Linux:

curl -fsSL https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh | bash

On Windows, download install.ps1, inspect it, run Unblock-File .\install.ps1, then run it. The installer detects your coding agents and writes their MCP configuration, plus skills, agent profiles and context hooks where a client supports them — the README lists 46 automatic or conditional client integrations. Useful options: --skip-config installs only the binary, --dir=<path> picks the location, and codebase-memory-mcp install --no-hooks removes its hooks while keeping MCP registration.

It is also on npm, PyPI, Homebrew, Scoop, the AUR and go install if you prefer a package manager.

Done when: codebase-memory-mcp runs from your shell.

Step 2: Connect your agent (if the installer did not)

Claude Code plugin route:

claude plugin marketplace add DeusData/codebase-memory-mcp
claude plugin install codebase-memory@codebase-memory

The plugin registers only the MCP server (started with npx -y codebase-memory-mcp@<version>); the skill, graph agents and hooks come from the native install command. Use the plugin or the installer, not both — otherwise the server runs twice under two tool namespaces.

Manual route — add this to ~/.claude.json or a project’s .mcp.json (the same mcpServers shape works in most MCP clients):

{
  "mcpServers": {
    "codebase-memory-mcp": {
      "command": "/path/to/codebase-memory-mcp",
      "args": []
    }
  }
}

Done when: after a restart, /mcp in Claude Code lists codebase-memory-mcp with 17 tools.

Step 3: Index the repository

Ask the agent to “Index this project”, or run it yourself:

codebase-memory-mcp cli index_repository --repo-path /path/to/repo

Index modes are full (default, with semantic analysis), moderate, fast (no semantic analysis) and cross-repo-intelligence for linking services across indexed projects. On very large repositories call index_repository with async: true and poll with status: true so the client does not hit its call deadline.

Done when: index_status reports the project as indexed and get_graph_schema returns node and edge counts.

Step 4: Keep the graph fresh

  • Watching: auto_watch is on by default, so projects registered by active MCP sessions re-index on file changes. The watcher follows git projects only unless you change it.
  • New projects: auto_index is off by default; enable it with codebase-memory-mcp config set auto_index true if you want first-connection indexing.
  • Worktrees: linked git worktrees are indexed as separate projects. If you run parallel agents in worktrees, set config set ignore_worktrees true to avoid a pile of throwaway indexes.
  • Team baseline: index_repository with persistence: true writes a compressed graph snapshot (.codebase-memory/graph.db.zst) that teammates can bootstrap from.

Step 5: Teach the agent to use it

The tools that pay off first: search_graph (structural, BM25 and semantic search), trace_path (callers, callees, data flow, cross-service paths), detect_changes (git diff to affected symbols and blast radius), get_code_snippet and get_architecture. Add a line to AGENTS.md or CLAUDE.md telling the agent to query the graph before opening files. The project’s preprint reports 10x lower token use and 2.1x fewer tool calls than file-by-file exploration; verify on your own repo by running the same task with the server on and off.

Security notes

  • Everything runs locally, but the installer writes to your agents’ config files — review what it changed.
  • Set CBM_ALLOWED_ROOT to stop index_repository from indexing paths outside one directory.
  • codebase-memory-mcp uninstall removes configs, skills, hooks and the binary; indexes are kept unless you pass --delete-indexes.

Last verified: November 17, 2026. Steps taken from the project’s README and release page; GitHub star counts change daily.

Sources