TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DeusData/codebase-memory-mcp/llms.txt
Use this file to discover all available pages before exploring further.
query_graph tool executes a read-only openCypher subset directly against the SQLite knowledge graph. It is the most powerful way to perform structural analysis — multi-hop traversals, aggregations, dead-code detection, hotspot ranking, inheritance queries, and cross-service HTTP call mapping — all in a single call that returns results in under 1ms for typical pattern queries. Anything that requires joining multiple pieces of structural information (callers + depth + file path, for instance) is best expressed as a Cypher query rather than a sequence of search_graph calls.
Supported Clauses
MATCH
The primary pattern-matching clause. MultipleMATCH clauses in one query act as joins.
OPTIONAL MATCH works like a left outer join — nodes with no match are returned with null properties:
WHERE
Filter expressions support:| Operator | Example |
|---|---|
| Equality / comparison | f.name = 'main', f.line > 100 |
| Not equal | f.name <> 'test' |
| Boolean logic | AND, OR, XOR, NOT |
| Set membership | f.name IN ['main', 'init'] |
| String predicates | CONTAINS, STARTS WITH, ENDS WITH |
| Null checks | IS NULL, IS NOT NULL |
| Regex match | f.name =~ '.*Handler.*' |
| Label test | n:Function |
| Existence subquery | EXISTS { (f)<-[:CALLS]-() } |
The
EXISTS { ... } subquery supports single-hop existence patterns. It is especially useful for dead-code detection: WHERE NOT EXISTS { (f)<-[:CALLS]-() } finds functions with zero callers.WITH
WITH pipes results between query stages and allows filtering mid-query:
RETURN, ORDER BY, SKIP, LIMIT, DISTINCT
Standard result control.DISTINCT deduplicates before returning:
UNWIND
Expands a list into individual rows:UNION / UNION ALL
Combine results from two queries.UNION deduplicates; UNION ALL keeps all rows:
CASE
Conditional expressions inRETURN or WITH:
Patterns
Node patterns
Relationship patterns
Variable-length paths
Aggregation Functions
| Function | Description |
|---|---|
count(n) | Count rows |
count(DISTINCT n.name) | Count distinct values |
sum(n.line) | Sum numeric property |
avg(n.cyclomatic) | Average |
min(n.line) | Minimum |
max(n.line) | Maximum |
collect(n.name) | Collect values into a list |
Scalar Functions
Graph metadata
labels(n), type(r), id(n), keys(n), properties(n)
Type conversion
toLower(s), toUpper(s), toString(v), toInteger(s), toFloat(s), toBoolean(s)
String manipulation
size(s), length(s), trim(s), ltrim(s), rtrim(s), reverse(s), substring(s, start, length), replace(s, search, replacement), left(s, n), right(s, n)
Utility
coalesce(a, b, ...) — returns first non-null value
Unsupported Features
The following are not supported and will fail with a clearunsupported … error (not silent empty results):
- Write clauses:
CREATE,SET,DELETE,MERGE CALL(stored procedures)CALL { ... } IN TRANSACTIONS- List literals:
[1, 2, 3] - Map literals:
{key: value} - List comprehensions:
[x IN list WHERE ...] - Path functions:
shortestPath(),allShortestPaths() - Query parameters:
$param
Example Queries
1. Find all functions calling a specific function
2. Dead code detection
Finds functions with zero inbound calls, excludingmain and entry points:
3. Inheritance hierarchy
4. Find all HTTP routes
5. Variable-length call traversal (depth 1–3)
6. Cross-service HTTP calls
7. Find classes implementing an interface
8. Top 10 most-called functions (hotspots)
9. High-complexity functions (cyclomatic > 10)
10. Functions with hidden O(n²) patterns
Using query_graph
Pass your Cypher string as the query parameter along with the project name:
max_rows to cap output:
query_graph has a hard ceiling of 100,000 rows. For broad queries, add LIMIT directly in the Cypher. For paginated browsing of large result sets, use search_graph with offset / limit instead.Multi-Project Stores
When multiple repositories are indexed under the same store, always include theproject parameter to scope your query. Omitting it will return an error. Use list_projects to find exact project names: