MCP ServerTools
Cypher Query
Execute graph queries against the knowledge graph
Query your code knowledge graph using Cypher. Read-only operations only.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
repository | string | Yes | Repository name (e.g., "owner/repo") |
cypher | string | Yes | Cypher query (read-only) |
max_results | number | No | Safety limit for results (default: 10000, 0 = unlimited) |
Supported Operations
| Supported | Not Supported |
|---|---|
MATCH, RETURN, WHERE, WITH | CREATE, DELETE, SET |
ORDER BY, LIMIT, SKIP | MERGE, DROP, ALTER |
=, <>, <, >, <=, >= | STARTS WITH, ENDS WITH |
AND, OR, NOT, CONTAINS | IN, =~ (regex), IS NULL |
Write operations (CREATE, DELETE, SET, MERGE) are blocked for safety.
Common Queries
Find functions by name
MATCH (s:CODE_SYMBOL)
WHERE s.kind = "Function"
AND s.name CONTAINS "user"
RETURN s.name, s.file_path
LIMIT 20Find callers of a function
MATCH (caller:CODE_SYMBOL)-[:CALLS]->(target:CODE_SYMBOL)
WHERE target.name = "authenticateUser"
RETURN caller.name, caller.file_pathTrace call chains
MATCH path = (start:CODE_SYMBOL)-[:CALLS*1..3]->(end:CODE_SYMBOL)
WHERE start.name = "handleRequest"
RETURN path
LIMIT 10Find cross-community calls
MATCH (s1:CODE_SYMBOL)-[:MEMBER_OF]->(c1:COMMUNITY),
(s2:CODE_SYMBOL)-[:MEMBER_OF]->(c2:COMMUNITY),
(s1)-[:CALLS]->(s2)
WHERE c1 <> c2
RETURN c1.label, c2.label, count(*) as calls
ORDER BY calls DESCList communities by size
MATCH (c:COMMUNITY)
RETURN c.label, c.size
ORDER BY c.size DESC
LIMIT 20Find symbols in a file
MATCH (s:CODE_SYMBOL)
WHERE s.file_path CONTAINS "/auth/"
RETURN s.name, s.kind, s.file_pathWorkarounds for Unsupported Operators
| Instead of... | Use... |
|---|---|
WHERE s.name STARTS WITH "get" | WHERE s.name CONTAINS "get" |
WHERE s.kind IN ["Function", "Class"] | WHERE s.kind = "Function" OR s.kind = "Class" |
WHERE s.name =~ ".*User.*" | WHERE s.name CONTAINS "User" |
Query Patterns
| To get... | Query pattern |
|---|---|
| Symbols only | MATCH (s:CODE_SYMBOL) RETURN s.name, s.content |
| Symbols + callers | MATCH (caller)-[:CALLS]->(s:CODE_SYMBOL) RETURN s, caller |
| Symbols + callees | MATCH (s:CODE_SYMBOL)-[:CALLS]->(callee) RETURN s, callee |
| Full relationships | MATCH (s:CODE_SYMBOL)-[r]->(target) RETURN s, r, target |
Tips
- Always use
LIMITto avoid large result sets - Filter early with
WHEREfor better performance - Specify node labels:
CODE_SYMBOL,FILE,COMMUNITY,PROCESS - Use
max_resultsas a safety net (the query'sLIMITtakes precedence)
Related
- Database Schema - Node types and properties
- Context Search - Natural language search