Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Tests](https://img.shields.io/badge/tests-5604_passing-brightgreen)](https://github.com/DeusData/codebase-memory-mcp)
[![Languages](https://img.shields.io/badge/languages-158-orange)](https://github.com/DeusData/codebase-memory-mcp)
[![Hybrid LSP](https://img.shields.io/badge/Hybrid_LSP-9_languages-blue)](#hybrid-lsp)
[![Agents](https://img.shields.io/badge/agents-11-purple)](https://github.com/DeusData/codebase-memory-mcp)
[![Agents](https://img.shields.io/badge/agents-12-purple)](https://github.com/DeusData/codebase-memory-mcp)
[![Pure C](https://img.shields.io/badge/pure_C-zero_dependencies-blue)](https://github.com/DeusData/codebase-memory-mcp)
[![Platform](https://img.shields.io/badge/macOS_%7C_Linux_%7C_Windows-supported-lightgrey)](https://github.com/DeusData/codebase-memory-mcp/releases/latest)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/DeusData/codebase-memory-mcp/badge)](https://scorecard.dev/viewer/?uri=github.com/DeusData/codebase-memory-mcp)
Expand All @@ -16,7 +16,7 @@

**The fastest and most efficient code intelligence engine for AI coding agents.** Full-indexes an average repository in milliseconds, the Linux kernel (28M LOC, 75K files) in 3 minutes. Answers structural queries in under 1ms. Ships as a single static binary for macOS, Linux, and Windows — download, run `install`, done.

High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 158 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, and Rust — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 14 MCP tools. Zero dependencies. Plug and play across 11 coding agents.
High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 158 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, and Rust — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 14 MCP tools. Zero dependencies. Plug and play across 12 coding agents.

> **Research** — The design and benchmarks behind this project are described in the preprint [*Codebase-Memory: Tree-Sitter-Based Knowledge Graphs for LLM Code Exploration via MCP*](https://arxiv.org/abs/2603.27277) (arXiv:2603.27277). Evaluated across 31 real-world repositories: 83% answer quality, 10× fewer tokens, 2.1× fewer tool calls vs. file-by-file exploration.

Expand All @@ -34,7 +34,7 @@ High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-si
- **Plug and play** — single static binary for macOS (arm64/amd64), Linux (arm64/amd64), and Windows (amd64). No Docker, no runtime dependencies, no API keys. Download → `install` → restart agent → done.
- **158 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks.
- **120x fewer tokens** — 5 structural queries: ~3,400 tokens vs ~412,000 via file-by-file search. One graph query replaces dozens of grep/read cycles.
- **11 agents, one command** — `install` auto-detects Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, OpenClaw, and Kiro — configures MCP entries, instruction files, and pre-tool hooks for each.
- **12 agents, one command** — `install` auto-detects Claude Code, CodeBuddy, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, OpenClaw, and Kiro — configures MCP entries, instruction files, and pre-tool hooks for each.
- **Built-in graph visualization** — 3D interactive UI at `localhost:9749` (optional UI binary variant).
- **Infrastructure-as-code indexing** — Dockerfiles, Kubernetes manifests, and Kustomize overlays indexed as graph nodes with cross-references. `Resource` nodes for K8s kinds, `Module` nodes for Kustomize overlays with `IMPORTS` edges to referenced resources.
- **14 MCP tools** — search, trace, architecture, impact analysis, Cypher queries, dead code detection, cross-service HTTP linking, ADR management, and more.
Expand Down Expand Up @@ -199,7 +199,7 @@ The result is similar in spirit to graphify's `graphify-out/` directory, but as

## How It Works

codebase-memory-mcp is a **structural analysis backend** — it builds and queries the knowledge graph. It does **not** include an LLM. Instead, it relies on your MCP client (Claude Code, or any MCP-compatible agent) to be the intelligence layer.
codebase-memory-mcp is a **structural analysis backend** — it builds and queries the knowledge graph. It does **not** include an LLM. Instead, it relies on your MCP client (Claude Code, CodeBuddy, or any MCP-compatible agent) to be the intelligence layer.

```
You: "what calls ProcessOrder?"
Expand Down Expand Up @@ -335,6 +335,7 @@ Restart your agent. Verify with `/mcp` — you should see `codebase-memory-mcp`
| Agent | MCP Config | Instructions | Hooks |
|-------|-----------|-------------|-------|
| Claude Code | `.claude/.mcp.json` | 4 Skills | PreToolUse (Grep/Glob graph augment, non-blocking) |
| CodeBuddy | `~/.codebuddy/.mcp.json` | 4 Skills | PreToolUse (Grep/Glob graph augment, non-blocking) |
| Codex CLI | `.codex/config.toml` | `.codex/AGENTS.md` | SessionStart reminder |
| Gemini CLI | `.gemini/settings.json` | `.gemini/GEMINI.md` | BeforeTool (grep reminder) + SessionStart reminder |
| Zed | `settings.json` (JSONC) | — | — |
Expand Down
10 changes: 5 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>codebase-memory-mcp — Code Intelligence Knowledge Graph for AI Coding Agents</title>
<meta name="description" content="codebase-memory-mcp is an open-source MCP server that indexes any codebase into a persistent knowledge graph so AI coding agents answer structural questions with ~120x fewer tokens. 158 languages, Hybrid LSP type resolution, local semantic vector search, code-clone detection, sub-1ms queries, Linux kernel indexed in 3 minutes. Single static C binary, zero dependencies. Works with 11 agents including Claude Code, Codex CLI, Gemini CLI, Cursor, and Zed.">
<meta name="keywords" content="MCP server, code intelligence, knowledge graph, tree-sitter, Hybrid LSP, semantic code search, code embeddings, code clone detection, cross-repo analysis, data-flow analysis, Claude Code, Codex CLI, Gemini CLI, Cursor, Zed, code exploration, token reduction, call graph, dead code detection">
<meta name="description" content="codebase-memory-mcp is an open-source MCP server that indexes any codebase into a persistent knowledge graph so AI coding agents answer structural questions with ~120x fewer tokens. 158 languages, Hybrid LSP type resolution, local semantic vector search, code-clone detection, sub-1ms queries, Linux kernel indexed in 3 minutes. Single static C binary, zero dependencies. Works with 12 agents including Claude Code, CodeBuddy, Codex CLI, Gemini CLI, Cursor, and Zed.">
<meta name="keywords" content="MCP server, code intelligence, knowledge graph, tree-sitter, Hybrid LSP, semantic code search, code embeddings, code clone detection, cross-repo analysis, data-flow analysis, Claude Code, CodeBuddy, Codex CLI, Gemini CLI, Cursor, Zed, code exploration, token reduction, call graph, dead code detection">
<meta name="author" content="DeusData">
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
<meta name="theme-color" content="#0d1117">
Expand Down Expand Up @@ -157,7 +157,7 @@
"name": "Which AI coding agents work with codebase-memory-mcp?",
"acceptedAnswer": {
"@type": "Answer",
"text": "A single install command configures 11 agents: Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, OpenClaw, and Kiro. Any MCP-compatible client can use the server."
"text": "A single install command configures 12 agents: Claude Code, CodeBuddy, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, OpenClaw, and Kiro. Any MCP-compatible client can use the server."
}
},
{
Expand Down Expand Up @@ -487,7 +487,7 @@ <h2>What is codebase-memory-mcp?</h2>
</p>
<p class="muted">
It is a structural-analysis backend, not a chatbot: there is no embedded LLM and no API key. Your
MCP client (Claude Code, or any MCP-compatible agent) is the intelligence layer; codebase-memory-mcp
MCP client (Claude Code, CodeBuddy, or any MCP-compatible agent) is the intelligence layer; codebase-memory-mcp
builds and serves the graph. All processing happens locally — your code never leaves your machine.
</p>
</section>
Expand Down Expand Up @@ -526,7 +526,7 @@ <h2>How do I install codebase-memory-mcp?</h2>
<span class="cmd">"Index this project"</span>
</div>
<p class="muted">
One command configures all 11 supported agents: Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode,
One command configures all 12 supported agents: Claude Code, CodeBuddy, Codex CLI, Gemini CLI, Zed, OpenCode,
Antigravity, Aider, KiloCode, VS Code, OpenClaw, and Kiro — with MCP entries, instruction files, and
pre-tool hooks for each. Windows users run <code>install.ps1</code>. Also available via
<code>npm</code>, <code>pip</code>, Homebrew, Scoop, Winget, Chocolatey, AUR, and <code>go install</code>.
Expand Down
42 changes: 37 additions & 5 deletions scripts/setup-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ $InstallDir = Join-Path $env:LOCALAPPDATA "codebase-memory-mcp"
# --- Helpers ---

function Write-Ok($msg) { Write-Host " $msg" -ForegroundColor Green }
function Write-Fail($msg) { Write-Host " $msg" -ForegroundColor Red }
function Write-Warn($msg) { Write-Host " $msg" -ForegroundColor Yellow }
function Write-Fail($msg) { Write-Host " $msg" -ForegroundColor Red }
function Write-Warn($msg) { Write-Host " $msg" -ForegroundColor Yellow }

function Read-SettingsJson($Path) {
# PS5.1-compatible: ConvertFrom-Json returns PSCustomObject, not Hashtable.
Expand Down Expand Up @@ -83,6 +83,36 @@ function Configure-ClaudeCode($McpConfig) {
}
}

function Configure-CodeBuddy($McpConfig) {
Write-Host ""
$answer = Read-Host "Configure CodeBuddy to use codebase-memory-mcp? [y/N]"
$codebuddyDir = if ($env:CODEBUDDY_CONFIG_DIR) { $env:CODEBUDDY_CONFIG_DIR } else { Join-Path $env:USERPROFILE ".codebuddy" }
$mcpPath = Join-Path $codebuddyDir ".mcp.json"
$mcpDir = Split-Path $mcpPath -Parent

if ($answer -match '^[Yy]$') {
if (-not (Test-Path $mcpDir)) {
New-Item -ItemType Directory -Path $mcpDir -Force | Out-Null
}

$settings = Read-SettingsJson $mcpPath

if (-not $settings.Contains("mcpServers")) {
$settings["mcpServers"] = [ordered]@{}
}

$settings["mcpServers"]["codebase-memory-mcp"] = $McpConfig
Write-SettingsJson $mcpPath $settings
Write-Ok "Updated $mcpPath"
} else {
Write-Host ""
Write-Host " Add this to $mcpPath:" -ForegroundColor White
Write-Host ""
$snippet = @{ mcpServers = @{ "codebase-memory-mcp" = $McpConfig } }
$snippet | ConvertTo-Json -Depth 10 | Write-Host
}
}

function Test-WSL {
try {
$null = wsl.exe --status 2>&1
Expand Down Expand Up @@ -233,9 +263,10 @@ if ($FromSource) {
}

Configure-ClaudeCode $mcpConfig
Configure-CodeBuddy $mcpConfig

Write-Host ""
Write-Ok "Done! Restart Claude Code and verify with /mcp"
Write-Ok "Done! Restart Claude Code or CodeBuddy and verify with /mcp"
Write-Host ""
Write-Host " To uninstall:" -ForegroundColor White
Write-Host " wsl.exe -- rm $wslBinaryPath"
Expand Down Expand Up @@ -309,16 +340,17 @@ if ($FromSource) {
}
}

# Configure Claude Code
# Configure Claude Code / CodeBuddy
$mcpConfig = [ordered]@{
type = "stdio"
command = $binaryPath
}

Configure-ClaudeCode $mcpConfig
Configure-CodeBuddy $mcpConfig

Write-Host ""
Write-Ok "Done! Restart Claude Code and verify with /mcp"
Write-Ok "Done! Restart Claude Code or CodeBuddy and verify with /mcp"
Write-Host ""
Write-Host " To uninstall:" -ForegroundColor White
Write-Host " Remove-Item -Recurse -Force '$InstallDir'"
Expand Down
70 changes: 70 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,75 @@ print()
fi
}

configure_codebuddy() {
echo ""
local binary_path="${INSTALL_DIR}/${BINARY_NAME}"
local codebuddy_config_dir="${CODEBUDDY_CONFIG_DIR:-$HOME/.codebuddy}"
local mcp_file="${codebuddy_config_dir}/.mcp.json"

printf "%s" "${BOLD}Configure CodeBuddy to use codebase-memory-mcp? [y/N] ${RESET}"
read -r answer
if [[ ! "$answer" =~ ^[Yy]$ ]]; then
echo ""
info "Add this to ${mcp_file}:"
echo ""
echo ' {'
echo ' "mcpServers": {'
echo ' "codebase-memory-mcp": {'
echo ' "type": "stdio",'
echo " \"command\": \"${binary_path}\""
echo ' }'
echo ' }'
echo ' }'
return
fi

local mcp_entry
mcp_entry=$(cat <<JSONEOF
{"type":"stdio","command":"${binary_path}"}
JSONEOF
)

mkdir -p "$(dirname "$mcp_file")"

if command -v jq &>/dev/null; then
if [ -f "$mcp_file" ]; then
local tmp
tmp=$(mktemp)
jq --argjson entry "$mcp_entry" '.mcpServers["codebase-memory-mcp"] = $entry' "$mcp_file" > "$tmp"
mv "$tmp" "$mcp_file"
else
echo "{}" | jq --argjson entry "$mcp_entry" '.mcpServers["codebase-memory-mcp"] = $entry' > "$mcp_file"
fi
ok "Updated ${mcp_file}"
elif command -v python3 &>/dev/null; then
python3 -c "
import json, os
path = os.path.expanduser('$mcp_file')
data = {}
if os.path.exists(path):
with open(path) as f:
data = json.load(f)
data.setdefault('mcpServers', {})['codebase-memory-mcp'] = json.loads('$mcp_entry')
with open(path, 'w') as f:
json.dump(data, f, indent=2)
print()
"
ok "Updated ${mcp_file}"
else
warn "Neither jq nor python3 found — cannot auto-configure."
echo ""
info "Add this to ${mcp_file} manually:"
echo ""
echo ' "mcpServers": {'
echo ' "codebase-memory-mcp": {'
echo ' "type": "stdio",'
echo " \"command\": \"${binary_path}\""
echo ' }'
echo ' }'
fi
}

# --- PATH check ---

check_path() {
Expand Down Expand Up @@ -317,6 +386,7 @@ else
fi

configure_claude
configure_codebuddy
check_path

# --- Git hooks ---
Expand Down
Loading
Loading