# codebase-memory-mcp Examples and Sample Usage: A Complete Practical Guide

> Explore codebase-memory-mcp examples and sample usage with this practical guide. Discover one-line install scripts, JSON-RPC CLI commands, and build/test suites for 14 MCP tools.

- Repository: [Martin Vogel/codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)
- Tags: getting-started
- Published: 2026-07-14

---

**The codebase-memory-mcp repository ships with production-ready examples including one-line installation scripts, JSON-RPC CLI commands for 14 MCP tools, configuration templates, and automated build/test suites.**

The `codebase-memory-mcp` project demonstrates every feature through extensive runnable samples located in the repository root, `scripts/` directory, and `docs/` folder. These examples cover the full lifecycle from initial binary installation to advanced graph traversal queries, providing copy-paste commands that work immediately after setup according to the source code.

## Quick-Start Installation Examples

The repository provides platform-specific one-liners that download and install the binary. For **macOS** and **Linux**, the [`install.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/install.sh) script at the repository root handles the entire setup:

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

```

For **Windows** environments, the `install.ps1` script provides equivalent functionality:

```powershell
Invoke-WebRequest -Uri https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1 -OutFile install.ps1
notepad install.ps1   # optional inspection

Unblock-File .\install.ps1
.\install.ps1

```

These scripts automatically detect agent environments and set up necessary hooks, as implemented in the installation logic referenced in [`install.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/install.sh) and `install.ps1`.

## CLI Usage Examples for 14 MCP Tools

The **README** documents a complete catalogue of 14 MCP tools that accept **JSON-RPC** compatible arguments. Below are the most frequently used practical examples.

### Indexing a Repository with index_repository

To create a searchable graph of your codebase, use the **`index_repository`** tool with an absolute path:

```bash
codebase-memory-mcp cli index_repository '{"repo_path":"/absolute/path/to/your/project"}'

```

To enable automatic indexing for every new session, configure the setting persistently:

```bash
codebase-memory-mcp config set auto_index true

```

### Searching the Graph with search_graph

The **`search_graph`** tool allows pattern matching against symbol names. This example searches for functions containing "Handler":

```bash
codebase-memory-mcp cli search_graph '{"project":"my-project","name_pattern":".*Handler.*","label":"Function"}'

```

### Tracing Call Paths with trace_path

Analyze dependencies using **`trace_path`** to trace inbound, outbound, or bidirectional calls for a specific function:

```bash
codebase-memory-mcp cli trace_path '{"project":"my-project","function_name":"Search","direction":"both"}'

```

### Executing openCypher Queries with query_graph

Run read-only **openCypher** queries directly against the graph using **`query_graph`**. This example finds functions called by `main`:

```bash
codebase-memory-mcp cli query_graph '{"project":"my-project","query":"MATCH (f:Function)-[:CALLS]->(g) WHERE f.name=\"main\" RETURN g.name LIMIT 5"}'

```

### Retrieving Source Code with get_code_snippet

Extract the exact source of any indexed symbol using **`get_code_snippet`**:

```bash
codebase-memory-mcp cli get_code_snippet '{"project":"my-project","qualified_name":"myproject.utils.parse"}'

```

### Inspecting the Graph Schema

To view node and edge statistics for your project, use **`get_graph_schema`**:

```bash
codebase-memory-mcp cli get_graph_schema '{"project":"my-project"}'

```

## Configuration and Environment Setup

The [`docs/CONFIGURATION.md`](https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/CONFIGURATION.md) file provides exhaustive reference for the **`codebase-memory-mcp config`** sub-commands and environment variables. You can manage per-project settings via [`.codebase-memory.json`](https://github.com/DeusData/codebase-memory-mcp/blob/main/.codebase-memory.json) files located in repository roots.

For excluding files from indexing, [`docs/cbmignore.md`](https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/cbmignore.md) documents the `.cbmignore` syntax and precedence rules, showing exactly how the engine filters paths before parsing.

## Build and Development Examples

Source-based workflows are automated through scripts in the `scripts/` directory. The **[`scripts/build.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/build.sh)** file compiles the static binary, supporting a `--with-ui` flag for builds that include the visualization layer:

```bash
scripts/build.sh --with-ui

```

Continuous integration relies on **[`scripts/test.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/test.sh)** and **[`scripts/soak-test.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/soak-test.sh)** for end-to-end validation, demonstrating indexing, queries, and edge validation against real-world codebases.

Performance characteristics are documented in [`docs/BENCHMARK.md`](https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/BENCHMARK.md), which includes benchmark tables comparing traversal speeds against repositories like the Linux kernel and Django.

## Optional 3-D Visualization UI Usage

The repository includes an optional 3-D graph visualization interface. Launch it by passing the `--ui` flag:

```bash
codebase-memory-mcp --ui=true --port=9749

```

Then open `http://localhost:9749` in a browser. The UI source lives in [`graph-ui/vite.config.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/vite.config.ts) and the surrounding `graph-ui/src/` directory, providing a concrete example of how the tool integrates with modern frontend build systems.

## Core Engine Implementation Reference

For developers extending the tool, [`internal/cbm/zstd_store.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/internal/cbm/zstd_store.c) and adjacent files in `internal/cbm/*` demonstrate the **Hybrid LSP** type-resolution layer and tree-sitter integration that powers the 158 vendored grammars mentioned in the documentation.

## Summary

- **Installation**: One-line `curl` or PowerShell scripts in [`install.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/install.sh) and `install.ps1` provide immediate setup for all platforms.
- **CLI Tools**: 14 JSON-RPC tools including `index_repository`, `search_graph`, `trace_path`, and `query_graph` are demonstrated with copy-paste commands.
- **Configuration**: [`docs/CONFIGURATION.md`](https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/CONFIGURATION.md) and [`docs/cbmignore.md`](https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/cbmignore.md) supply templates for environment variables and exclusion patterns.
- **Automation**: [`scripts/build.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/build.sh), [`scripts/test.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/test.sh), and [`scripts/soak-test.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/soak-test.sh) automate builds, testing, and long-running validation.
- **Visualization**: The `--ui=true` flag launches a 3-D interface built from sources in `graph-ui/`.

## Frequently Asked Questions

### Where are the installation scripts located in the repository?

The [`install.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/install.sh) (macOS/Linux) and `install.ps1` (Windows) scripts reside at the repository root. These files contain the logic for downloading pre-built binaries, detecting agent environments, and configuring system hooks.

### How do I run a semantic search for function definitions after indexing?

Use the **`search_graph`** tool with a `name_pattern` regex and `label` set to `Function`. The command expects a JSON-RPC payload specifying the `project` name and returns matching nodes from the graph built by `index_repository`.

### What file controls which directories are excluded from indexing?

Exclusion rules are managed via `.cbmignore` files. The syntax and precedence rules are fully documented in [`docs/cbmignore.md`](https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/cbmignore.md), which explains how the engine filters paths before they reach the tree-sitter parsers or the **Hybrid LSP** layer.