/memgraph:memgraph-run-mage-algorithmsfrom memgraph
Runs MAGE graph algorithms from Cypher including BFS, DFS, shortest paths, PageRank, community detection, centrality, node embeddings, and LLM integration on Memgraph databases.
Ships in memgraph. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
MAGE is Memgraph's graph algorithm library. Algorithms are exposed as query
modules - each module has one or more procedures (via CALL) or
functions (via RETURN).
MAGE is pre-installed in Docker images memgraph/memgraph-mage and
memgraph/memgraph-platform.
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:3.14.0
For GPU algorithms, add --gpus all and use a -cuda image tag.
CALL module.procedure(arg1, arg2, ...) YIELD col1, col2;
CALL module.procedure() YIELD *;
Rules:
Graph from project() to run on a subgraphYIELD selects output columns; use YIELD * for allMATCH ... CALL ... YIELD ... RETURN ...CALL can only be followed by YIELD and/or RETURNAS if column names conflict with outer variablesCALL pagerank.get() YIELD node, rank; -- procedure
RETURN llm.complete("Summarize this."); -- function
RETURN collections.sort([3, 1, 2]); -- function in expression
Run algorithms on a subset of the graph using project():
MATCH p=(n:Person)-[r:KNOWS]->(m:Person)
WITH project(p) AS subgraph
CALL pagerank.get(subgraph) YIELD node, rank
RETURN node.name, rank ORDER BY rank DESC;
Alternative with explicit lists:
MATCH (a)-[e]-(b)
WITH collect(a) AS nodes, collect(e) AS rels
CALL community_detection.get_subgraph(nodes, rels) YIELD node, community_id
RETURN node, community_id;
Projection cannot be used with built-in deep path traversal (BFS/DFS/WSP/ASP/KSP).
Default: 100 MB per procedure.
CALL module.procedure() PROCEDURE MEMORY LIMIT 500 MB YIELD *;
CALL module.procedure() PROCEDURE MEMORY UNLIMITED YIELD *;
CALL mg.procedures() YIELD name, signature;
CALL mg.load_all();
CALL node2vec.help() YIELD name, value;
These use relationship expansion syntax directly in MATCH.
MATCH p=(a {name: "A"})-[*BFS]->(b {name: "E"}) RETURN p;
MATCH p=(a)-[r:ROAD *BFS]->(b) RETURN p;
MATCH p=(a)-[*]->(b) RETURN p;
MATCH p=(a)-[*WSHORTEST (r, n | r.weight) total_weight]->(b)
RETURN p, total_weight;
Combined node + edge weight:
MATCH p=(a)-[*WSHORTEST (r, n | n.cost + coalesce(r.weight, 0)) total]->(b)
RETURN p, total;
MATCH p=(a)-[*ALLSHORTEST (r, n | r.weight)]->(b) RETURN p;
Must match source/target first, pass via WITH:
MATCH (a:Node {name: "A"}), (b:Node {name: "E"})
WITH a, b
MATCH p=(a)-[*KSHORTEST|3]->(b) RETURN p;
2-arg (r, n | predicate):
MATCH p=(a)-[*BFS (r, n | n.active = true AND r.weight < 10)]->(b) RETURN p;
3-arg (r, n, p | predicate) - p is the path so far:
MATCH p=(a)-[* (r, n, p | type(last(relationships(p))) != "BLOCKED")]->(b) RETURN p;
4-arg WSP/ASP filter (r, n, p, w | predicate) - w is accumulated weight:
MATCH p=(a)-[*WSHORTEST (r, n | r.w) total (r, n, p, w | w < 1000)]->(b) RETURN p, total;
MATCH p=(a)-[*BFS ..5]->(b) RETURN p;
USING HOPS LIMIT 3 MATCH p=(a)-[*BFS]->(b) RETURN p;
For the complete module list with signatures, see reference.md.
| Module | Description |
|---|---|
pagerank | PageRank influence ranking |
betweenness_centrality | Brandes betweenness |
degree_centrality | In/out/undirected degree |
katz_centrality | Katz influence |
| Module | Description |
|---|---|
community_detection | Louvain modularity maximization |
leiden_community_detection | Leiden (improved Louvain) |
weakly_connected_components | WCC |
| Module | Description |
|---|---|
| Built-in BFS/DFS/WSP/ASP/KSP | Expansion syntax |
algo | General traversal utilities |
path | Path navigation/analysis |
cycles | Cycle detection |
bridges | Bridge edge detection |
biconnected_components | Maximal biconnected subgraphs |
| Module | Description |
|---|---|
node2vec | Node embeddings via biased random walks |
gnn_link_prediction | GNN link prediction |
gnn_node_classification | GNN node classification |
tgn | Temporal Graph Networks |
embeddings | Sentence embeddings (local or remote) |
knn | K-nearest neighbors |
| Module | Description |
|---|---|
collections | List operations (sort, union, partition) |
map | Map operations |
text | String manipulation |
llm | LLM completions via LiteLLM |
json_util | JSON load from file/URL |
export_util | Graph export (JSON) |
import_util | Data import (JSON) |
periodic | Periodic query execution |
uuid_generator | UUID generation |
migrate | MySQL/SQL Server/Oracle access |
| Module | Description |
|---|---|
pagerank_online | Streaming PageRank |
community_detection_online | Streaming LabelRankT |
betweenness_centrality_online | Streaming betweenness |
katz_centrality_online | Streaming Katz |
node2vec_online | Incremental node2vec |
| Module | Description |
|---|---|
nxalg | 70+ NetworkX algorithm wrappers |
igraphalg | igraph wrappers |
cugraph | NVIDIA GPU algorithms |
CALL pagerank.get() YIELD node, rank;
CALL pagerank.get({max_iterations: 100, damping_factor: 0.85, stop_epsilon: 1e-5})
YIELD node, rank SET node.rank = rank;
Parameters: max_iterations (100), damping_factor (0.85), stop_epsilon (1e-5),
num_of_threads (1).
CALL community_detection.get() YIELD node, community_id;
Parameters: weight ("weight"), coloring (false), min_graph_shrink (100000),
community_alg_threshold (0.000001), num_of_threads (half HW threads).
Weighted graphs require --storage-properties-on-edges=true.
CALL leiden_community_detection.get() YIELD node, community_id;
Parameters: weight_property ("weight"), gamma (1.0), theta (0.01),
resolution_parameter (0.01), max_iterations (inf).
CALL betweenness_centrality.get() YIELD node, betweenness_centrality;
CALL betweenness_centrality.get(true, true) YIELD node, betweenness_centrality;
Parameters: directed (true), normalized (true), threads (half HW threads).
CALL degree_centrality.get() YIELD node, degree;
CALL degree_centrality.get("in") YIELD node, degree;
Parameters: type ("undirected" | "in" | "out").
CALL node2vec.set_embeddings(false, 2.0, 0.5, 4, 5, 128) YIELD nodes, embeddings;
MATCH (n) RETURN n.id, n.embedding;
Key parameters: is_directed, p (return param), q (in-out param),
num_walks, walk_length, vector_size.
Low p → structural equivalence (BFS-like). Low q → homophily (DFS-like).
RETURN llm.complete("Summarize: Memgraph is a graph database.");
RETURN llm.complete("Hello", {model: "ollama/llama2", api_base: "http://localhost:11434"});
Config: model, api_base, system_prompt. Uses LiteLLM (requires
pip install litellm + provider API keys).
With graph data:
MATCH (n:Article)
WITH collect(n.title + ": " + n.abstract) AS texts
WITH reduce(s = "", t IN texts | s + t + "\n") AS combined
RETURN llm.complete(combined, {system_prompt: "Summarize in 2 sentences."});
Initialize with set():
CALL pagerank_online.set(100, 0.2) YIELD node, rank;
Create a trigger with update():
CREATE TRIGGER pagerankTrigger BEFORE COMMIT EXECUTE
CALL pagerank_online.update(createdVertices, createdEdges, deletedVertices, deletedEdges)
YIELD node, rank SET node.rank = rank;
Read cached results with get():
CALL pagerank_online.get() YIELD node, rank;
Reset with reset():
CALL pagerank_online.reset();
CALL pagerank.get() YIELD node, rank SET node.rank = rank;
CALL community_detection.get() YIELD node, community_id SET node.community = community_id;
MATCH p=(n:User)-[r:FOLLOWS]->(m:User)
WITH project(p) AS subgraph
CALL pagerank.get(subgraph) YIELD node, rank
RETURN node.name, rank ORDER BY rank DESC;
CALL community_detection.get() YIELD node, community_id
WITH community_id, collect(node) AS members
WHERE size(members) > 5
RETURN community_id, size(members) AS size
ORDER BY size DESC;
-[*BFS]->-[*WSHORTEST (r,n|r.w)]->-[*ALLSHORTEST (r,n|r.w)]->-[*KSHORTEST|K]->pagerank.get() or betweenness_centrality.get()community_detection.get() or leiden_community_detection.get()node2vec.set_embeddings() or embeddings.node_sentence()*_online modules with triggersnxalg.* (70+ procedures; prefer native C++ for perf)llm.complete() functionWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
memgraph@memgraph is listed by memgraph/marketplace — review the source before installing
npx claudepluginhub memgraph/marketplace --plugin memgraph14 skills in this plugin
/memgraph-brand-uiGenerate apps, demos, dashboards, diagrams, landing pages, and any visual output that looks like it belongs in the Memgraph product family. Use whenever producing UI, visual artifacts (Mermaid, SVGs, charts), Lab-style admin tools, internal dashboards, feature splash pages, or embeddable widgets for Memgraph engineers./memgraph-cpp-query-modulesDevelop custom query modules in C++ for Memgraph graph database. Use when creating high-performance graph algorithms, procedures (ProcedureType::Read/Write), or functions using the mgp.hpp C++ API. Covers compilation, memory management, graph traversal, and module deployment./memgraph-cypher-syntaxWrite Cypher queries for Memgraph, including Memgraph-specific extensions like deep path traversals (BFS, DFS, WSP, ASP, KSP with filter/weight lambdas), text and vector search, parallel execution, and CALL subqueries. Use when the user asks to write, fix, or optimize a Cypher query for Memgraph, or asks about Cypher syntax differences between Memgraph and Neo4j.Other plugins' skills for the same job