From 4fe5682eb9f2506c2763d2e5933bfcb86c96041a Mon Sep 17 00:00:00 2001 From: Barry Zhang Date: Thu, 21 Nov 2024 11:57:59 -0500 Subject: [PATCH] MORE MD improvements --- src/memory/README.md | 105 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 21 deletions(-) diff --git a/src/memory/README.md b/src/memory/README.md index 14c67d20..40bd7b07 100644 --- a/src/memory/README.md +++ b/src/memory/README.md @@ -1,11 +1,9 @@ # Knowledge Graph Memory Server -A basic MCP server that provides persistent memory using a knowledge graph. The server manages entities, observations of them, and the relationships among them using a JSON-based file system. +A basic implementation of persistent memory using a local knowledge graph. This lets Claude remember information about the user across chats. -This lets Claude remember information about the user across chats, and lets them bypass the issues of having super long chats. +## Core Concepts -# Core Concepts - -## Entities +### Entities Entities are the primary nodes in the knowledge graph. Each entity has: - A unique name (identifier) - An entity type (e.g., "person", "organization", "event") @@ -20,7 +18,7 @@ Example: } ``` -## Relations +### Relations Relations define directed connections between entities. They are always stored in active voice and describe how entities interact or relate to each other. Example: @@ -31,7 +29,7 @@ Example: "relationType": "works_at" } ``` -## Observations +### Observations Observations are discrete pieces of information about an entity. They are: - Stored as strings @@ -51,29 +49,94 @@ Example: } ``` -# Tools +## API -## Entity Management +### Tools +- **create_entities** + - Create multiple new entities in the knowledge graph + - Input: `entities` (array of objects) + - Each object contains: + - `name` (string): Entity identifier + - `entityType` (string): Type classification + - `observations` (string[]): Associated observations + - Ignores entities with existing names -- create_entities: Create new entities in the knowledge graph with names, types, and observations -- delete_entities: Remove entities and their associated relations from the graph -- add_observations: Add new observations to existing entities -- delete_observations: Remove specific observations from entities +- **create_relations** + - Create multiple new relations between entities + - Input: `relations` (array of objects) + - Each object contains: + - `from` (string): Source entity name + - `to` (string): Target entity name + - `relationType` (string): Relationship type in active voice + - Skips duplicate relations +- **add_observations** + - Add new observations to existing entities + - Input: `observations` (array of objects) + - Each object contains: + - `entityName` (string): Target entity + - `contents` (string[]): New observations to add + - Returns added observations per entity + - Fails if entity doesn't exist -## Relation Management +- **delete_entities** + - Remove entities and their relations + - Input: `entityNames` (string[]) + - Cascading deletion of associated relations + - Silent operation if entity doesn't exist -- create_relations: Establish relationships between entities in active voice -- delete_relations: Remove specific relationships between entities +- **delete_observations** + - Remove specific observations from entities + - Input: `deletions` (array of objects) + - Each object contains: + - `entityName` (string): Target entity + - `observations` (string[]): Observations to remove + - Silent operation if observation doesn't exist +- **delete_relations** + - Remove specific relations from the graph + - Input: `relations` (array of objects) + - Each object contains: + - `from` (string): Source entity name + - `to` (string): Target entity name + - `relationType` (string): Relationship type + - Silent operation if relation doesn't exist -## Query Tools +- **read_graph** + - Read the entire knowledge graph + - No input required + - Returns complete graph structure with all entities and relations -- read_graph: Retrieve the entire knowledge graph -- search_nodes: Search for nodes based on names, types, and observation content -- open_nodes: Access specific nodes by their names +- **search_nodes** + - Search for nodes based on query + - Input: `query` (string) + - Searches across: + - Entity names + - Entity types + - Observation content + - Returns matching entities and their relations -# Prompt +- **open_nodes** + - Retrieve specific nodes by name + - Input: `names` (string[]) + - Returns: + - Requested entities + - Relations between requested entities + - Silently skips non-existent nodes + +# Usage with Claude Desktop + +### Setup +Add this to your claude_desktop_config.json: +```json +{ + "mcp-server-memory": { + "command": "mcp-server-memory" + } +} +``` + +### System Prompt The prompt for utilizing memory depends on the use case. Changing the prompt will help the model determine the frequency and types of memories created.