Knowledge Graphs
Decisions, code, and docs in one queryable graph.
Connect decisions, code, and documentation in a queryable graph. Understand how your project's knowledge is interconnected.
Graph tiers by plan
Pick the depth you need.
Pro · Graph-Lite
Module-level import graph
Supports dependencies and 1-hop impact for files/modules. No call/dataflow/type layers.
Elite / Team · Full Graph
Full multi-layer graph
Module + call + dataflow + type with deeper impact analysis and graph ingestion via graph(action="ingest").
Search + graph workflow
Find a target with search, then traverse.
Use search to identify the best target, then graph queries to answer dependency and impact questions. Keeps prompts small and avoids unnecessary local scans.
search(mode="hybrid", query="token refresh flow", limit=3)
graph(action="impact", target={ "type": "module", "path": "src/auth.rs" }, max_depth=2)What are knowledge graphs?
Nodes + edges, queryable.
Knowledge graphs represent information as nodes (entities) connected by edges (relationships). In ContextStream, knowledge graphs help you:
Track Dependencies
See how decisions affect other parts of your system.
Connect Context
Link related memories, code, and documentation.
Trace Impact
Understand what changes when you modify something.
Discover Insights
Find non-obvious connections in your knowledge base.
Creating knowledge nodes
Capture durable context first.
Knowledge graph nodes come from the same durable context you already store in ContextStream: decisions, lessons, docs, tasks, todos, and facts. Use the MCP tools to create those records, then query the graph relationships around them.
memory(action="create_node",
node_type="decision",
title="Use PostgreSQL for primary database",
content="Chose PostgreSQL for JSON support and operational maturity.",
project_id="<project-id>")Connecting nodes
Edges express relationships.
ContextStream derives useful relationships from stored context and indexed code. Query those links directly instead of manually assembling raw request payloads.
graph(action="related",
query="PostgreSQL database decision and schema design",
max_depth=2)Common relation types:
influencesdepends_onsupersedesrelated_toimplementsQuerying the graph
Traverse, filter, and walk paths.
Find related knowledge nodes:
graph(action="related",
query="PostgreSQL decision",
max_depth=2,
relation_types=["influences", "depends_on"])Get all decisions in a workspace:
memory(action="decisions", query="database architecture")Code graph analysis
Files, functions, types, variables.
Code graph endpoints analyze indexed code entities. They are separate from knowledge graph endpoints; memory node types like decision or fact are not valid here. Use /api/v1/graph/knowledge/path with UUID node IDs (no type) for knowledge graph queries.
Pro Graph-Lite supports module-level targets only (files/paths) and 1-hop impact. Elite/Team unlocks function/type/variable layers and deeper impact analysis.
Accepted code entity types (v0.4.x consolidated graph tool):
graph(action="dependencies") target.type: module (file/path), function (method), type (struct/enum/trait/class), variable (data/const/constant)graph(action="call_path") source.type/target.type: function (method) only (type optional; ids are function IDs)graph(action="impact") target.type: module (file/path), function (method), type (struct/enum/trait/class), variable (data/const/constant)Type payload examples (code graph only):
module/file/path: {"target":{"type":"module","path":"src/auth.rs"}}function/method: {"target":{"type":"function","id":"fn_login"}}type/struct/enum/trait/class: {"target":{"type":"type","id":"User"}}variable/data/const/constant: {"target":{"type":"variable","id":"API_KEY"}}Dependencies example:
graph(action="dependencies",
target={ "type": "module", "path": "src/auth.rs" },
max_depth=3)Call path example:
graph(action="call_path",
source={ "id": "fn_login", "type": "function" },
target={ "id": "fn_verify_token", "type": "function" },
max_depth=5)Impact analysis example:
graph(action="impact",
change_type="modify_signature",
target={ "id": "User", "type": "type" })Graph ingestion (Elite/Team full graph):
graph(action="ingest", project_id="<project-id>", wait=true)Knowledge graph path example (memory node UUIDs):
graph(action="path",
source={ "id": "7e3b0b5e-2c76-4f49-8e5a-2f2bfe7eb7f3" },
target={ "id": "5c3a6b1a-0f89-4ddc-bb29-0a2a9a3c2c4e" },
max_depth=5)Next steps