memory

memory

3.5

The Knowledge Graph Memory Server is a custom MCP server implementation designed to provide persistent memory using a local knowledge graph, allowing Claude to remember user information across sessions.

Top Comments

The Knowledge Graph Memory Server is a robust implementation of the Model Context Protocol (MCP) designed to provide persistent memory through a local knowledge graph. This server allows for the storage and retrieval of user information across sessions, enabling efficient and recursive retrieval of project structures and related knowledge. It supports atomic observation storage, project hash tagging, and robust error handling, ensuring seamless integration with Claude and other MCP-compatible clients. The server's architecture is modular, consisting of components like MCPServer, KnowledgeGraphManager, Mutex, FileStorage, EnvironmentConfig, ProjectHashSystem, and RecursiveTraversal. These components work together to manage the knowledge graph data structure, handle CRUD operations, prevent race conditions, and ensure data consistency. The server also supports recursive retrieval of entity relationships, allowing users to obtain complete project structures with a single query.

Features

  • Persistent Memory: Utilizes a local knowledge graph to store and retrieve user information across sessions.
  • Atomic Observation Storage: Supports the storage of discrete pieces of information about entities.
  • Project Hash Tagging: Enables efficient retrieval of project-related entities and relations.
  • Robust Error Handling: Ensures seamless integration with MCP-compatible clients.
  • Recursive Retrieval: Allows for complete project structures to be obtained with a single query.

MCP Tools

  • {'create_entities': 'Create multiple new entities in the knowledge graph.'}
  • {'create_relations': 'Create multiple new relations between entities.'}
  • {'add_observations': 'Add new observations to existing entities.'}
  • {'delete_entities': 'Remove entities and their relations.'}
  • {'delete_observations': 'Remove specific observations from entities.'}
  • {'delete_relations': 'Remove specific relations from the graph.'}
  • {'open_nodes': 'Open specific nodes in the knowledge graph by their names.'}
  • {'search_nodes': 'Search for nodes in the knowledge graph based on a query.'}
  • {'get_project_by_hash': 'Retrieve a project and all its related entities and relations by project hash.'}
  • {'read_graph': 'Read the entire knowledge graph.'}

Usage with Different Platforms

Claude Desktop

{'setup': 'bash\ngit clone https://github.com/htooayelwinict/memory.git\ncd memory\nnpm run build\n', 'node': '\n{\n  "mcpServers": {\n    "memory": {\n      "command": "node",\n      "args": [\n        "your_memory_path/memory/dist/index.js"\n      ],\n      "env": {\n        "MEMORY_FILE": "your_memory_path/memory/mcp_memory.json"\n      }\n    }\n  }\n}\n', 'node_with_custom_setting': '\n{\n  "mcpServers": {\n    "memory": {\n      "command": "node",\n      "args": [\n        "your_memory_path/memory/dist/index.js"\n      ],\n      "env": {\n        "MEMORY_FILE": "your_memory_path/memory/mcp_memory.json"\n      }\n    }\n  }\n}\n', 'windsurf_global_rules': 'markdown\nMemory Rules:\n   - When running any `read_graph` MCP tool, always provide a dummy parameter (e.g., `{ dummy: null }`) to prevent errors.\n   - Always include `projectHash` in every entity variable for proper tracking.\n   - Always retrieve and associate the user-provided project name together with its `projectHash`.\n', 'system_prompt': '\nFollow these steps for each interaction:\n\n1. User Identification:\n   - You should assume that you are interacting with default_user\n   - If you have not identified default_user, proactively try to do so.\n\n2. Memory Retrieval:\n   - Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph\n   - Always refer to your knowledge graph as your "memory"\n\n3. Memory\n   - While conversing with the user, be attentive to any new information that falls into these categories:\n     a) Basic Identity (age, gender, location, job title, education level, etc.)\n     b) Behaviors (interests, habits, etc.)\n     c) Preferences (communication style, preferred language, etc.)\n     d) Goals (goals, targets, aspirations, etc.)\n     e) Relationships (personal and professional relationships up to 3 degrees of separation)\n\n4. Memory Update:\n   - If any new information was gathered during the interaction, update your memory as follows:\n     a) Create entities for recurring organizations, people, and significant events\n     b) Connect them to the current entities using relations\n     b) Store facts about them as observations\n'}