MarkTechPost@AI 04月27日 11:00
Implementing Persistent Memory Using a Local Knowledge Graph in Claude Desktop
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了如何利用本地知识图谱为 Claude Desktop 添加持久记忆功能,使其能够跨多个聊天会话记住用户信息,提供更个性化、更一致的回复。通过安装必要的依赖项(Node.js 和 Claude Desktop),配置 mcp.json 文件,以及在 Claude 设置中添加特定文本,Claude 可以自动识别用户、检索相关信息、更新记忆,并在对话中创建实体、建立关系、存储事实。这种集成显著提升了 Claude 的能力,使其成为更智能、更高效的助手。

💡**知识图谱记忆服务器**:Claude Desktop 通过知识图谱记忆服务器来记住和组织用户的跨会话信息,存储用户偏好、历史对话和个人详细信息,并理解信息间的关系。

⚙️**环境配置与连接**:通过配置 `mcp.json` 文件,并设置 Claude,使其能够利用知识图谱创建实体、建立关系并检索信息,实现 Claude 与本地知识图谱的连接。

🤖**对话流程自动化**:在 Claude 的个人偏好设置中添加文本,可以使 Claude 在每次交互时自动执行用户识别、记忆检索和记忆更新等步骤,无需手动操作。

🛠️**MCP工具集**:配置完成后,将有9个MCP工具可用于知识图谱服务器,允许创建、删除、读取和搜索实体、关系和观察结果,增强了Claude处理和管理知识的能力。

A Knowledge Graph Memory Server allows Claude Desktop to remember and organize information about a user across multiple chats. It can store things like user preferences, past conversations, and personal details. Because the information is saved as a knowledge graph, Claude can understand relationships between different pieces of information. This leads to more personalized responses and reduces repetition — you won’t have to explain the same things again and again.

In this tutorial, we will implement a simple persistent memory using a local knowledge graph in Claude Desktop, to help it remember user information across chats and provide more personalized, consistent responses.

Step 1: Installing the dependencies

Node.js Installation

We’ll be using npx to run the Knowledge Graph Memory Server, and for that, Node.js is required.

Claude Desktop Installation

You can download the latest version of Claude Desktop at https://claude.ai/download. Next, you’ll need to configure Claude to connect with your MCP server. To do this, open the claude_desktop_config.json file located in the Claude directory using any text editor. If the file doesn’t exist, go ahead and create it manually.

Step 2: Configuring the mcp.json file

In the mcp.json file, enter the following code:

{    "mcpServers": {      "memory": {        "command": "npx",        "args": [          "-y",          "@modelcontextprotocol/server-memory"        ],        "env": {            "MEMORY_PATH": "./memory.json"        }      }    }  }

Step 3: Configuring Claude settings

Now, we need to configure Claude so it can use the knowledge graph to create entities, build relationships, and retrieve relevant information.

(This preference will automatically apply to all conversations.)

Follow these steps for each interaction:1. User Identification:   - You should assume that you are interacting with default_user   - If you have not identified default_user, proactively try to do so.2. Memory Retrieval:   - Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph   - Always refer to your knowledge graph as your "memory"3. Memory   - While conversing with the user, be attentive to any new information that falls into these categories:     a) Basic Identity (age, gender, location, job title, education level, etc.)     b) Behaviors (interests, habits, etc.)     c) Preferences (communication style, preferred language, etc.)     d) Goals (goals, targets, aspirations, etc.)     e) Relationships (personal and professional relationships up to 3 degrees of separation)4. Memory Update:   - If any new information was gathered during the interaction, update your memory as follows:     a) Create entities for recurring organizations, people, and significant events     b) Connect them to the current entities using relations     b) Store facts about them as observations

Once everything is configured, you will see 9 MCP tools available for the Knowledge Graph Server. These tools allow you to: create entities, create relationships, add observations, delete entities, delete observations, delete relationships, read the graph, search nodes, and open nodes.

Additionally, the text we added in the preferences section enables Claude to automatically use these tools during conversations.

Even if we go to a new chat, Claude will remember the information from the previous chats via the knowledge graph. The integration of this MCP tool enhances Claude’s ability to create, modify, and utilize knowledge in real-time, making it a powerful assistant for tasks like database management and SQL query generation. With this memory system in place, Claude becomes a more intelligent, responsive, and consistent tool for all your future interactions. For more details on the knowledge memory server, you can visit this link, where you’ll find resources to help you build even more advanced applications.


Also, don’t forget to follow us on Twitter and join our Telegram Channel and LinkedIn Group. Don’t Forget to join our 90k+ ML SubReddit.

[Register Now] miniCON Virtual Conference on AGENTIC AI: FREE REGISTRATION + Certificate of Attendance + 4 Hour Short Event (May 21, 9 am- 1 pm PST) + Hands on Workshop

The post Implementing Persistent Memory Using a Local Knowledge Graph in Claude Desktop appeared first on MarkTechPost.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Claude Desktop 知识图谱 持久记忆 MCP
相关文章