← All code samples

Context Graph → inventory

Check whether the workspace graph actually has data and whether every connector’s last sync succeeded, list record types and connectors, and optionally search graph tools. Use this when wiring agents or operators to the workspace graph.

Step What the SDK does
1. Status getWorkspaceStatus
2. Inventory listRecordTypes / listConnectors
3. Optional search searchGraphTools with a query string

health and ready only return a bare {"status": ...} on purpose: they are open liveness/readiness probes that must not leak internal detail. getWorkspaceStatus combines ready, listRecordTypes, and listConnectorSources into one call that answers what you actually want to know: is the service reachable, how many records of each type does this workspace hold, and did each connector’s last sync succeed.

Default base URL is ${STACKGEN_URL}/context-graph. Pass contextGraphUrl / context_graph_url / ContextGraphURL (or CONTEXT_GRAPH_URL in the sample scripts) for a local or port-forward endpoint.

Minimal

from stackgen import StackgenClient, StackgenConfig

client = StackgenClient(
    StackgenConfig(
        base_url="https://app.stackgen.com",
        api_token="stackgen_…",
        workspace_id="<workspace-uuid>",
    )
)

print(client.context_graph.get_workspace_status())
print(client.context_graph.list_record_types())
print(client.context_graph.search_graph_tools("dashboard"))

getWorkspaceStatus returns something like:

{
  "ready": true,
  "ready_error": null,
  "record_count": 73,
  "record_types_with_data": 3,
  "record_types_total": 78,
  "last_synced_at": "2026-10-28T05:43:21.113027Z",
  "sources": [
    {
      "connector": "grafana",
      "source_id": "94365310-23ed-55c6-9f2b-2adeace1845d",
      "status": "completed",
      "last_synced_at": "2026-10-28T05:43:22.479984Z",
      "warnings": []
    }
  ],
  "degraded_sources": []
}

A connector in degraded_sources either has status: "failed" (check sources[].failure) or status: "never_synced" (configured but no sync has run yet).

Sync and wait

Start a connector sync and poll until it reaches completed, completed_with_gaps, or failed:

const sync = await client.contextGraph.syncAndWait({
  connector: "grafana",
  secret_ref_id: "<vault-secret-uuid>",
  initial_load: { mode: "full" },
});
console.log(sync.status, sync.sync_id);

Wire bodies use snake_case field names (secret_ref_id, initial_load).

Runnable scripts

  • TypeScript: examples/context-graph/inventory.ts
  • Python: examples/context-graph/inventory.py
  • Go: examples/go/context-graph/inventory.go

Change a schedule interval

Pass --schedule-id ID --every-seconds N (minimum 60) to retune one schedule without pausing it or stopping a running sync. The next run is one new interval from now, rounded up to the next whole minute.

await client.contextGraph.setConnectorScheduleInterval(scheduleId, 14400);
client.context_graph.set_connector_schedule_interval(schedule_id, 14400)
must(client.ContextGraph.SetConnectorScheduleInterval(ctx, scheduleID, 14400))