# codebase-memory-mcp

> Tree-sitter knowledge graph of your codebase, served to agents over MCP

- Category: Retrieval & Knowledge (RAG) / Code Indexing & Search
- Language: C
- Licence: MIT
- Repository: https://github.com/DeusData/codebase-memory-mcp
- Canonical page: https://ai-tldr.dev/tools/codebase-memory-mcp/

## In short

codebase-memory-mcp is a code intelligence engine for AI coding agents. It sits in the Code Indexing & Search category of the Retrieval & Knowledge (RAG) tools and is open-source, written in C and licensed MIT. To get started: install on macOS or Linux.

## Overview

codebase-memory-mcp is a code intelligence engine for AI coding agents. It parses a repository into a persistent knowledge graph of functions, classes, call chains, HTTP routes and cross-service links, then exposes that graph to an agent through 15 MCP tools — search, trace, architecture, impact analysis, index-coverage checks, Cypher queries, dead-code detection, cross-service HTTP linking and ADR management among them.

The point is to replace file-by-file exploration. When an agent has to answer "what calls this function" by grepping and reading, it burns a large fraction of its context on files it will discard. Querying a precomputed graph collapses that into a structured answer: the project reports five structural queries costing roughly 3,400 tokens where file-by-file search costs about 412,000, and its preprint (arXiv:2603.27277, evaluated across 31 real-world repositories) reports 83% answer quality with 10x fewer tokens and 2.1x fewer tool calls than file-by-file exploration.

Parsing is tree-sitter AST analysis across 162 languages, with grammars vendored and compiled into the binary so there is nothing to install per language. For Python, TypeScript/JavaScript/JSX/TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust and Perl, a Hybrid LSP layer adds semantic type resolution on top. It ships as a pure-C native executable for macOS (arm64/amd64), Linux (arm64/amd64) and Windows (amd64) — no Docker, no language runtime, no API key — and the installer configures detected agent clients across 45 supported surfaces. All processing is local; a built-in 3D graph visualisation is served from the binary itself at localhost:9749. Because the tool reads your codebase and writes to your agent configuration files, review the repository's SECURITY.md before running the install script.

## What it does

- Persistent knowledge graph of functions, classes, call chains, HTTP routes and cross-service links
- 15 MCP tools covering search, trace, architecture, impact analysis, Cypher queries, dead-code detection and ADR management
- 162 languages via vendored tree-sitter grammars, plus Hybrid LSP semantic type resolution for 12 of them
- Fast full indexing — the project reports the Linux kernel (28M LOC, 75K files) in 3 minutes and sub-millisecond structural queries
- Native executable for macOS, Linux and Windows with no Docker, language runtime or API key; processing stays on your machine
- Installer configures detected agent clients across 45 supported surfaces, and a built-in 3D graph UI runs at localhost:9749
- Infrastructure-as-code indexing: Dockerfiles, Kubernetes manifests and Kustomize overlays become graph nodes with cross-references

## Getting started

Installation is a single script that fetches the release binary and wires up your detected agent clients. The script reads your codebase and writes to agent configuration files by design — the full source is on GitHub if you would rather audit it first.

1. Install on macOS or Linux

   Run the one-line installer from the repository.

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

2. Install on Windows

   Download the PowerShell installer, inspect it, unblock it (browsers and Invoke-WebRequest add a Mark-of-the-Web restriction), then run it.

```powershell
# 1. Download the installer
Invoke-WebRequest -Uri https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1 -OutFile install.ps1

# 2. (Optional but recommended) Inspect the script
notepad install.ps1

# 3. Unblock the downloaded file
Unblock-File .\install.ps1

# 4. Run it
.\install.ps1
```

3. Restart your agent and index

   The install step configures the agent clients it detects and activates conditional clients only when their documented platform, marker or existing config path is present. Restart the agent afterwards so it picks up the new MCP server and its tools.

4. Explore the graph

   The binary serves an interactive 3D visualisation of the knowledge graph so you can see what the agent is querying.

```text
http://localhost:9749
```

## When to use it

- Cut an agent's token spend on a large repository by answering structural questions from a graph instead of reading files
- Run impact analysis before a refactor — trace every caller and cross-service HTTP link that a change would touch
- Give a coding agent a working map of an unfamiliar polyglot codebase without per-language tooling setup
- Find dead code, or query the graph directly with Cypher, across a repository of any supported language
