Context
Context assembly builds a subgraph around an entity — the entity itself, its relationships, and related entities within a configurable number of hops. This is the primary way to understand an entity in its full graph context.
How It Works
get_context starts from a root entity and traverses edges bidirectionally (both upstream and downstream) up to the specified depth. It returns:
- Entity — The root entity with all its properties
- Edges — All relationships discovered within the traversal depth
- Related — All entities connected via those edges
Depth
The depth parameter controls how many hops to traverse:
- Depth 1 (default) — Direct neighbors only
- Depth 2 — Neighbors of neighbors
- Depth 3+ — Wider graph context
Maximum depth is capped at 5. Results are bounded at 1000 edges to prevent runaway queries on dense graphs. Cycle detection prevents infinite loops.
CLI
# Direct neighbors
compass entity context urn:bigquery:orders
# 2-hop neighborhood
compass entity context urn:bigquery:orders --depth 2
# Downstream impact analysis
compass entity impact urn:kafka:events.orders --depth 3API
curl -X POST http://localhost:8080/raystack.compass.v1beta1.CompassService/GetEntityContext \
-H "Content-Type: application/json" \
-H "Compass-User-UUID: user@example.com" \
-d '{"urn": "urn:bigquery:orders", "depth": 2}'MCP
get_context(urn: "urn:bigquery:orders", depth: 2)Example
For a graph: Kafka Topic -> BigQuery Table -> Dashboard
Calling get_context on the BigQuery table with depth 1 returns the table, both edges, and both neighbors (Kafka Topic and Dashboard).
With depth 2, it would also include any entities connected to the Kafka Topic and Dashboard.
Impact Analysis
impact answers "if I change this, what breaks?" by tracing edges downstream from a root entity. Same depth mechanics and cycle detection as get_context, but follows relationships in one direction to map the blast radius. Available as entity impact in the CLI, GetEntityImpact in the API, and impact in MCP.
Context Assembly
For AI agents, assemble_context provides an intelligent, all-in-one context assembly. Instead of composing multiple tool calls, agents describe their task and intent, and Compass returns a curated context window:
assemble_context(
query: "debug the user sessions pipeline",
intent: "debug",
token_budget: 4000
)This combines search, graph traversal, document fetching, intent-aware ranking, and token-budget packing into a single call. See the MCP guide for full parameter reference.