codebase-memory-mcp Examples and Sample Usage: A Complete Practical Guide
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 script at the repository root handles the entire setup:
curl -fsSL https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh | bash
For Windows environments, the install.ps1 script provides equivalent functionality:
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 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:
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:
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":
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:
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:
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:
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:
codebase-memory-mcp cli get_graph_schema '{"project":"my-project"}'
Configuration and Environment Setup
The 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 files located in repository roots.
For excluding files from indexing, 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 file compiles the static binary, supporting a --with-ui flag for builds that include the visualization layer:
scripts/build.sh --with-ui
Continuous integration relies on scripts/test.sh and 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, 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:
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 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 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
curlor PowerShell scripts ininstall.shandinstall.ps1provide immediate setup for all platforms. - CLI Tools: 14 JSON-RPC tools including
index_repository,search_graph,trace_path, andquery_graphare demonstrated with copy-paste commands. - Configuration:
docs/CONFIGURATION.mdanddocs/cbmignore.mdsupply templates for environment variables and exclusion patterns. - Automation:
scripts/build.sh,scripts/test.sh, andscripts/soak-test.shautomate builds, testing, and long-running validation. - Visualization: The
--ui=trueflag launches a 3-D interface built from sources ingraph-ui/.
Frequently Asked Questions
Where are the installation scripts located in the repository?
The 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, which explains how the engine filters paths before they reach the tree-sitter parsers or the Hybrid LSP layer.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →