graph
Query relationships and source memories for entities in a knowledge graph to retrieve structured semantic information.
Instructions
Query the knowledge graph for an entity — returns relationships and source memories. Requires ENGRAM_GRAPH=1.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session identifier | |
| entity | Yes | Entity name to look up (case-insensitive) |
Implementation Reference
- src/index.ts:262-268 (handler)Handler for 'graph' tool - calls memory.graph(sessionId, entity) to query the knowledge graph for an entity and returns relationships and source memories
case 'graph': { const result = await memory.graph( args.sessionId as string, args.entity as string ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } - src/index.ts:117-128 (schema)Tool registration for 'graph' - defines input schema with sessionId (string) and entity (string) parameters, notes that ENGRAM_GRAPH=1 is required
{ name: 'graph', description: 'Query the knowledge graph for an entity — returns relationships and source memories. Requires ENGRAM_GRAPH=1.', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' }, entity: { type: 'string', description: 'Entity name to look up (case-insensitive)' }, }, required: ['sessionId', 'entity'], }, }, - src/index.ts:21-28 (helper)Engram instance initialization - creates the memory object with graphMemory enabled via ENGRAM_GRAPH=1 environment variable and GRAPH_MODEL configuration
const memory = new Engram({ dbPath: DB_PATH, embeddingUrl: EMBEDDING_URL, semanticSearch: true, graphMemory: process.env.ENGRAM_GRAPH === '1', graphModel: GRAPH_MODEL, consolidateModel: CONSOLIDATE_MODEL, });