Codebase Memory MCP
Use a configured Codebase Memory graph as a discovery accelerator, confirm graph-derived conclusions against source snippets or local files, and fall back to normal repository exploration when the server, project, index, or capability is unavailable.
Use it for graph-backed discovery, natural-language exploration, and moderate-only index caveats.
When to invoke
- "Use Codebase Memory to understand this module."
- "Trace callers and callees with the code graph."
- "What depends on this symbol?"
- "Use the MCP graph for impact analysis."
- "Find the architecture clusters for this repo."
Procedure
- Discover the Codebase Memory tools exposed by the current MCP client; clients may prefix or rename tool namespaces.
- Call
list_projectswhen available and use the exact indexed project name. - If the repository is not indexed, continue with local exploration or ask before calling
index_repositorywhen graph access is important. - Before branch-sensitive or edit-sensitive conclusions, use
index_statusand verify the actual version-control state. - Use
detect_changesonly when its Git base and head are valid for the checkout; if it unexpectedly reports zero changes, or the checkout uses another VCS, inspect that VCS status or diff before claiming no impact. - Use
get_architectureonce for unfamiliar structure. Requestclustersto discover de-facto module seams. - Treat
cyclesas an opt-in whole-call-graph scan:pathdoes not scope cycle detection, so verify relevant cycles before making module-local claims. - Use
search_graphfor definitions, implementations, routes, classes, interfaces, and related symbols. Prefer natural language for discovery and name or qualified-name patterns for known symbols. Narrow by label or path and set a result limit. - For exhaustive claims, increase
offsetbylimitwhilehas_moreis true. - Use
search_codeor normal repository search for literal strings, configuration keys, test identifiers, error messages, and non-code files. - After graph search, use
get_code_snippetwith the returned qualified name. If source snippets are unavailable, open the local file before relying on the result. - Use
trace_pathfor callers, callees, dependency paths, data flow, cross-service paths, and impact analysis. Include tests when the claim covers them. Whiletruncatedis true, passnextback ascursorwith every other argument unchanged. - After identifying candidate files, call
check_index_coveragefor every cited path. - Before negative or exhaustive claims, also check relevant
scopes; advancescope_offsetto eachnext_offsetwhilehas_moreis true. - Use
get_graph_schemabefore customquery_graphcalls. Reserve custom queries for bounded multi-hop or aggregate questions, applyLIMITormax_rows, and usegraph="missed"to audit files the main graph did not fully index. - Complete every relevant result stream before an exhaustive claim. When graph and checked-out source disagree, treat source as current and report likely index drift.
Tool decision table
| Need | Preferred action | Avoid |
|---|---|---|
| Project discovery | list_projects, then exact project name. |
Guessing an indexed project name. |
| Staleness check | index_status plus VCS status when needed. |
Claiming no changes from graph metadata alone. |
| Architecture orientation | get_architecture with clusters; use cycles only when wanted. |
Treating path as a cycle-detection scope. |
| Symbol discovery | search_graph with labels, paths, limits, offset, and has_more. |
Using broad graph search for exact strings. |
| Literal search | search_code or local grep. |
Turning config keys or error text into semantic graph queries. |
| Source evidence | get_code_snippet, then local file if missing. |
Citing a graph node without source confirmation. |
| Impact tracing | trace_path with cursor handling for truncated results. |
Dropping later pages of a trace. |
| Coverage confidence | check_index_coverage and scoped pagination. |
Making exhaustive negative claims from partial indexes. |
| Custom graph query | get_graph_schema, then bounded query_graph with LIMIT or max_rows. |
Unbounded graph queries. |
Indexing modes
| Mode | Use when | Trade-off |
|---|---|---|
moderate |
Normal indexing. | Filters files while retaining similarity and semantic edges. |
fast |
User asks for a smoke index, or moderate is blocked and degraded fallback is useful. |
Similarity and semantic edges are absent; disclose this. |
full |
Moderate-only discovery filters omit relevant supported files and extra indexing cost is justified. | More expensive; still honors .gitignore, .cbmignore, and always-skip rules. |
Safety and fallbacks
- Do not install Codebase Memory or another third-party skill from this workflow.
- Do not call
delete_project, ingest traces, update ADRs, or index a repository unless the user explicitly requested or approved the action; announce it before execution. - Do not invent graph results. If the MCP server, project, index, or tool is unavailable, continue with normal repository exploration.
- Treat index coverage metadata as best-effort, not proof of completeness. Inspect local source for partial, skipped, excluded, stale, or otherwise uncovered paths.
Output template
## Codebase Memory result
**Status:** graph used | local fallback | blocked
**Project:** `<indexed project or not available>`
| Question | Tool or fallback | Evidence | Confidence |
| --- | --- | --- | --- |
| `<symbol/flow/module>` | `search_graph` / `trace_path` / local search | `<snippet, path, or result id>` | high/medium/low |
### Coverage and freshness
- `index_status`: `<result or not available>`
- `check_index_coverage`: `<paths/scopes checked or not available>`
- Source confirmation: `<files opened or snippets confirmed>`
### Limitations
- `<pagination, truncation, stale index, or fallback notes>`
Quality gate
- Graph conclusions are confirmed with source snippets or local files before edits or strong claims.
- Project, index freshness, and branch/change status are checked when relevant.
- Paginated
has_more,offset,scope_offset,next_offset,truncated, andcursorstreams are completed for exhaustive claims. - Literal strings and config keys use
search_codeor local repository search, not broad graph discovery. - Custom
query_graphcalls are schema-informed and bounded byLIMITormax_rows. - Unsafe actions such as
delete_project, trace ingestion, ADR updates, or indexing are not performed without explicit user request or approval. - Fallback behavior is reported when graph capability is unavailable or stale.