Directed Graphs
LocalData MCP parses graph files into a directed multigraph backed by SQLite. Nodes carry labels and typed metadata properties. Edges carry labels, optional weights, and metadata. The full graph is then available for path finding, structural analysis, and export.
Supported formats
Format |
Extension |
Notes |
|---|---|---|
DOT (Graphviz) |
|
Directed and undirected graphs |
GML |
|
Graph Modelling Language with nested attributes |
GraphML |
|
XML-based with typed node/edge properties |
Mermaid |
|
Flowchart syntax with subgraphs and shapes |
connect_database("kg", "graphml", "./knowledge_graph.graphml")
connect_database("flow", "dot", "./pipeline.dot")
connect_database("arch", "mermaid", "./architecture.mmd")
Graph tools
Node operations
Tool |
Description |
|---|---|
|
Create or update a node |
|
Remove a node, cascading its edges and properties |
|
Inspect a node’s label and properties |
|
List adjacent nodes — |
Edge operations
Tool |
Description |
|---|---|
|
Create a directed edge; endpoint nodes are created automatically if absent |
|
Remove an edge |
|
List edges for a node |
Property operations
Nodes carry typed key-value metadata. Types are inferred automatically from the value.
Tool |
Description |
|---|---|
|
Read a property |
|
Set a property |
|
Remove a property |
|
List all properties on a node |
Analysis
Tool |
Description |
|---|---|
|
|
|
Node/edge counts, density, DAG check, connected components, and degree statistics |
Export
export_graph("kg", "graphml") # full metadata preserved
export_graph("kg", "dot")
export_graph("kg", "gml")
export_graph("kg", "mermaid")
export_graph("kg", "mermaid", node_id="root") # subgraph around a node
All node and edge metadata properties are included in the export. Output is capped at 100 KB; larger graphs receive a truncation notice in the response.
Validation warnings
Import and edit operations automatically check for structural and semantic issues. Warnings are returned in the "warnings" key of the response and never block the operation.
Structural checks
Code |
Description |
|---|---|
|
Edge where source equals target (A→A) |
|
Same source, target, and label appearing more than once |
|
Nodes with no edges |
|
Edges without a relationship label |
|
Circular paths (A→B→C→A), which break the DAG property |
|
Subgraphs unreachable from the main component |
Semantic checks
Code |
Description |
|---|---|
|
A→B and B→A with the same label |
|
Multiple labeled edges between the same pair (e.g., both |
Property checks
Code |
Description |
|---|---|
|
Node IDs differing only in case ( |
|
Nodes missing a property that more than 50% of other nodes carry |
|
Node labels with 80% or greater string similarity |
DAG-specific checks
Code |
Description |
|---|---|
|
Edge A→C when A→B→C already exists, detected via transitive reduction |
|
Node with multiple parents, which may indicate unintended polyhierarchy |
When checks run
Full validation (all 13 checks) runs after every file import. Mutations trigger a targeted subset:
add_edge— self-loop, duplicate edge, missing label, contradictory edgesremove_edge— orphan node detectionset_node— casing conflict detection
Cycle detection, transitive reduction, and near-duplicate name checks are skipped automatically for graphs with more than 10,000 nodes.
Example warning response
{
"node_count": 42,
"edge_count": 58,
"warnings": [
{
"code": "orphan_nodes",
"message": "3 orphan node(s): X, Y, Z",
"details": {"nodes": ["X", "Y", "Z"]}
},
{
"code": "cycle",
"message": "Cycle detected: A → B → C → A",
"details": {"nodes": ["A", "B", "C"]}
}
]
}