Skip to main content
Glama

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
NameRequiredDescriptionDefault
sessionIdYesSession identifier
entityYesEntity name to look up (case-insensitive)

Implementation Reference

  • 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) }] };
    }
  • 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'],
      },
    },
  • 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,
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Cartisien/engram-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server