MemoryMesh

MemoryMesh

这个项目基于 MCP 服务器仓库中的知识图谱内存服务器,并保留了其核心功能。

数字笔记管理
高级AI推理
AI记忆系统
数据库交互
AI内容生成
Git管理工具
数据与应用分析
访问服务器

Tools

search_nodes

Search for nodes in the knowledge graph based on a query

add_nodes

Add multiple new nodes in the knowledge graph

update_nodes

Update existing nodes in the knowledge graph

add_edges

Add multiple new edges between nodes in the knowledge graph. Edges should be in active voice

update_edges

Update existing edges in the knowledge graph

delete_nodes

Delete multiple nodes and their associated edges from the knowledge graph

delete_edges

Delete multiple edges from the knowledge graph

read_graph

Read the entire knowledge graph

open_nodes

Open specific nodes in the knowledge graph by their names

add_metadata

Add new metadata to existing nodes in the knowledge graph

delete_metadata

Delete specific metadata from nodes in the knowledge graph

add_artifact

Add a new artifact or unique item to the knowledge graph

update_artifact

Update an existing artifact in the knowledge graph

delete_artifact

Delete an existing artifact from the knowledge graph

add_currency

Represents a type of currency in the game world.

update_currency

Update an existing currency in the knowledge graph

delete_currency

Delete an existing currency from the knowledge graph

add_faction

A faction or organization operating within the game world.

update_faction

Update an existing faction in the knowledge graph

delete_faction

Delete an existing faction from the knowledge graph

add_inventory

A collection of items or equipment belonging to a character, entity, or location.

update_inventory

Update an existing inventory in the knowledge graph

delete_inventory

Delete an existing inventory from the knowledge graph

add_location

Add a new location to the knowledge graph

update_player_character

Update an existing player_character in the knowledge graph

delete_player_character

Delete an existing player_character from the knowledge graph

update_location

Update an existing location in the knowledge graph

delete_location

Delete an existing location from the knowledge graph

add_npc

Add a new Non-Player Character (NPC) to the knowledge graph

update_skills

Update an existing skills in the knowledge graph

delete_skills

Delete an existing skills from the knowledge graph

add_temporal

Represents a specific point in time and its associated environmental conditions.

update_temporal

Update an existing temporal in the knowledge graph

delete_temporal

Delete an existing temporal from the knowledge graph

update_npc

Update an existing npc in the knowledge graph

delete_npc

Delete an existing npc from the knowledge graph

add_player_character

Add a new Player Character to the knowledge graph

add_quest

Add a new Quest to the knowledge graph

update_quest

Update an existing quest in the knowledge graph

delete_quest

Delete an existing quest from the knowledge graph

add_skills

Defines list of skills or abilities a character can possess.

add_transportation

Represents a transportation owned or used by a character or entity.

update_transportation

Update an existing transportation in the knowledge graph

delete_transportation

Delete an existing transportation from the knowledge graph

README

MemoryMesh

Release smithery badge TypeScript License: MIT GitHub Stars

MemoryMesh 是一个为 AI 模型设计的知识图谱服务器,专注于基于文本的 RPG 和互动故事讲述。它帮助 AI 在对话中保持一致的、结构化的记忆,从而实现更丰富和更动态的互动。

该项目基于 MCP 服务器仓库中的 Knowledge Graph Memory Server,并保留其核心功能。

<a href="https://glama.ai/mcp/servers/kf6n6221pd"><img width="380" height="200" src="https://glama.ai/mcp/servers/kf6n6221pd/badge" alt="MemoryMesh MCP server" /></a>

重要提示

v0.2.7 版本起,schema 的默认位置已更改为 dist/data/schemas。 预计此位置在未来不会更改,但如果您是从以前的版本更新,请确保将您的 schema 文件移动到新位置。

快速链接

概述

MemoryMesh 是一个本地知识图谱服务器,使您能够为 AI 模型构建和管理结构化信息。虽然它特别适合基于文本的 RPG,但其适应性强的设计使其可用于各种应用,包括社交网络模拟、组织规划或任何涉及结构化数据的场景。

主要特性

  • 动态的基于 Schema 的工具: 使用 schema 定义您的数据结构,MemoryMesh 会自动生成用于添加、更新和删除数据的工具。
  • 直观的 Schema 设计: 创建 schema 来指导 AI 生成和连接节点,使用必填字段、枚举类型和关系定义。
  • 用于 AI 指导的元数据: 使用元数据来提供上下文和结构,帮助 AI 理解数据中的含义和关系。
  • 关系处理: 在您的 schema 中定义关系,以鼓励 AI 在相关数据点(节点)之间创建连接(边)。
  • 信息丰富的反馈: 向 AI 提供错误反馈,使其能够从错误中学习并改进与知识图谱的交互。
  • 事件支持: 事件系统跟踪操作,提供有关知识图谱如何被修改的见解。

节点

节点代表知识图谱中的实体或概念。每个节点都有:

  • name:一个唯一的标识符。
  • nodeType:节点的类型(例如,npcartifactlocation),由您的 schema 定义。
  • metadata:一个字符串数组,提供有关节点的描述性细节。
  • weight:(可选)一个介于 0 和 1 之间的数值,表示关系的强度,默认为 1。

节点示例:

    {
      "name": "Aragorn",
      "nodeType": "player_character",
      "metadata": [
        "Race: Human",
        "Class: Ranger",
        "Skills: Tracking, Swordsmanship",
        "Affiliation: Fellowship of the Ring"
      ]
    }

边代表节点之间的关系。每条边都有:

  • from:源节点的名称。
  • to:目标节点的名称。
  • edgeType:关系的类型(例如,ownslocated_in)。
{
  "from": "Aragorn",
  "to": "Andúril",
  "edgeType": "owns"
}

Schema

Schema 是 MemoryMesh 的核心。它们定义了数据的结构并驱动工具的自动生成。

Schema 文件位置

将您的 schema 文件 (.schema.json) 放置在已构建的 MemoryMesh 项目的 dist/data/schemas 目录中。MemoryMesh 将在启动时自动检测并处理这些文件。

Schema 结构

文件名:[name].schema.json。例如,对于定义 'npc' 的 schema,文件名将为 add_npc.schema.json

  • name - 内存中 schema 和节点类型的标识符。重要提示:schema 的名称必须add_ 开头才能被识别。
  • description - 用作 add_<name> 工具的描述,为 AI 提供上下文。deleteupdate 工具具有通用描述)
  • properties - 每个属性都包含其类型、描述和其他约束。
    • property
      • type - 支持的值为 stringarray
      • description - 帮助指导 AI 了解实体的用途。
      • required - 布尔值。如果为 true,则AI 必须在创建节点时提供此属性。
      • enum - 一个字符串数组。如果存在,则 AI 必须选择给定的选项之一。
      • relationship - 定义与另一个节点的连接。如果属性是必需的并且具有关系,则 AI 将始终创建节点和相应的边。
        • edgeType - 要创建的关系的类型。
        • description - 帮助指导 AI 了解关系的用途。
  • additionalProperties - 布尔值。如果为 true,则允许 AI 添加超出定义为必需或可选的额外属性。
Schema 示例 (add_npc.schema.json):
{
  "name": "add_npc",
  "description": "Schema for adding an NPC to the memory" ,
  "properties": {
    "name": {
      "type": "string",
      "description": "A unique identifier for the NPC",
      "required": true
    },
    "race": {
      "type": "string",
      "description": "The species or race of the NPC",
      "required": true,
      "enum": [
        "Human",
        "Elf",
        "Dwarf",
        "Orc",
        "Goblin"
      ]
    },
    "currentLocation": {
      "type": "string",
      "description": "The current location of the NPC",
      "required": true,
      "relationship": {
        "edgeType": "located_in",
        "description": "The current location of the NPC"
      }
    }
  },
  "additionalProperties": true
}

基于此 schema,MemoryMesh 会自动创建:

  • add_npc:用于添加新的 NPC 节点。
  • update_npc:用于修改现有的 NPC 节点。
  • delete_npc:用于删除 NPC 节点。

MemoryMesh 包含 11 个为基于文本的 RPG 设计的预构建 schema,为游戏开发提供了一个随时可用的基础。

SchemaManager 工具

MemoryMesh 包含一个 SchemaManager 工具,以简化 schema 的创建和编辑。它提供了一个可视化界面,使您可以轻松地定义数据结构,而无需直接编写 JSON。

<img width="370" alt="image" src="https://github.com/user-attachments/assets/e8f0c808-2ff6-48da-ac7c-cf51aebde7b8">

动态工具

MemoryMesh 通过动态工具简化了与知识图谱的交互。这些工具不是手动编码的,而是自动生成的,直接来自您的 schema 定义。这意味着当您使用 schema 定义数据的结构时,MemoryMesh 会智能地创建一组专门用于处理该特定数据结构的工具。

可以这样理解: 您提供一个蓝图(schema),MemoryMesh 会自动构建必要的工具来基于该蓝图构建、修改和删除元素。

幕后是如何工作的?

MemoryMesh 有一个智能系统,可以读取您的 schema 定义。它分析您定义的结构,包括实体的属性及其关系。基于此分析,它会自动为每种实体类型创建一组工具:

  • add_<entity> 用于创建实体新实例的工具。
  • update_<entity> 用于修改现有实体的工具。
  • delete_<entity> 用于删除实体的工具。

然后,这些工具通过 MemoryMesh 中的一个中央枢纽提供,确保任何连接的客户端或 AI 都可以轻松访问和使用它们。

本质上,MemoryMesh 的动态工具系统提供了一种强大而有效的方式来管理您的知识图谱,使您可以专注于应用程序的内容和逻辑,而不是底层的数据操作机制。

内存文件

默认情况下,数据存储在 dist/data/memory.json 中的 JSON 文件中。

内存查看器

内存查看器是一个独立的工具,旨在帮助您可视化和检查由 MemoryMesh 管理的知识图谱的内容。它提供了一个用户友好的界面,用于浏览节点、边及其属性。

主要特性:
  • 图形可视化:将知识图谱视为交互式节点链接图。
  • 节点检查:选择节点以查看其 nodeType、元数据和连接的边。
  • 边探索:检查节点之间的关系,包括 edgeType 和方向。
  • 搜索和过滤:快速查找特定节点或按类型过滤它们。
  • 表格视图:允许您轻松查找和检查特定节点和边,或一次性检查所有节点和边。
  • 原始 JSON 视图:允许您查看内存文件中的原始 JSON 数据。
  • 统计面板:提供有关知识图谱的关键指标和信息:总节点数、总边数、节点类型和边类型。
  • 搜索和过滤:允许您按节点类型或边类型进行过滤,并过滤是否显示节点、边或两者都显示。
访问内存查看器

内存查看器是一个独立的 Web 应用程序。内存查看器讨论

使用内存查看器
  • 选择内存文件:在内存查看器中,单击“选择内存文件”按钮。
  • 选择文件:导航到您的 MemoryMesh 项目目录并选择 memory.json 文件(默认情况下位于 dist/data/memory.json 中)。
  • 探索:内存查看器将加载并显示您的知识图谱的内容。

内存流

image

提示

为了获得最佳结果,请将 Claude 的“Projects”功能与自定义指令一起使用。这是一个您可以开始使用的提示示例:

你是一个有用的 AI 助手,负责管理基于文本的 RPG 的知识图谱。你可以使用以下工具:add_npc、update_npc、delete_npc、add_location、update_location、delete_location 以及其他用于管理游戏世界的工具。

当用户提供输入时,首先使用你可用的工具处理它,以更新知识图谱。然后,以适合基于文本的 RPG 的方式做出回应。

您还可以指示 AI 直接在聊天中执行特定操作。

尝试不同的提示,找到最适合您用例的提示!

示例

  1. 一个带有自定义指令的简单示例
  2. 一个为了示例而示例的示例,带有可视化效果 (不是功能的一部分)

添加几个城市,一些 npc,城市周围的一些地点供探索,在某个地方隐藏一两个神器

image

安装

通过 Smithery 安装

要通过 Smithery 为 Claude Desktop 自动安装 MemoryMesh:

npx -y @smithery/cli install memorymesh --client claude

前提条件

  • Node.js: 18 或更高版本。您可以从 nodejs.org 下载它。
  • npm: 通常包含在 Node.js 中。
  • Claude for Desktop: 确保您已安装来自 claude.ai/download 的最新版本。

安装步骤

  1. 克隆存储库:

    git clone https://github.com/CheMiguel23/memorymesh.git
    cd memorymesh
    
  2. 安装依赖项:

    npm install
    
  3. 构建项目:

    npm run build
    

    此命令将 TypeScript 代码编译为 dist 目录中的 JavaScript,并将示例 schema 和数据文件也复制到其中。

  4. 验证文件复制(可选):

    • 构建过程应自动将 data 文件夹复制到 dist
    • 检查 dist/data 是否存在并包含 .json 文件。另请验证 dist/data/schemas 是否存在并包含 .schema.json 文件。
  5. 配置 Claude Desktop:

    打开您的 Claude Desktop 配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • mcpServers 部分中为 memorymesh 添加一个条目。您可以选择以下一个配置选项:
    "mcpServers": {
      "memorymesh": {
        "command": "node", 
        "args": ["/ABSOLUTE/PATH/TO/YOUR/PROJECT/memorymesh/dist/index.js"]
      }
    }
    
    • /ABSOLUTE/PATH/TO/YOUR/PROJECT/ 替换为您的 memorymesh 项目目录的实际绝对路径
    • 示例 (macOS):
      "command": "node",
      "args": ["/Users/yourusername/Projects/memorymesh/dist/index.js"]
      
    • 示例 (Windows):
      "command": "node",
      "args": ["C:\\Projects\\memorymesh\\dist\\index.js"]
      
  6. 重启 Claude Desktop: 完全重启 Claude Desktop 以使更改生效。

验证安装

  1. 启动 Claude Desktop。
  2. 打开一个新的聊天。
  3. 在右上角查找 MCP 插件图标 <img src="https://mintlify.s3.us-west-1.amazonaws.com/mcp/images/claude-desktop-mcp-plug-icon.svg"/>。如果它在那里,您的配置可能正确。
  4. 单击 <img src="https://mintlify.s3.us-west-1.amazonaws.com/mcp/images/claude-desktop-mcp-plug-icon.svg"/> 图标。您应该在连接的服务器列表中看到“memorymesh”。
  5. 单击 <img src="https://mintlify.s3.us-west-1.amazonaws.com/mcp/images/claude-desktop-mcp-hammer-icon.svg"/> 图标。如果您看到列出的工具(例如,add_npcupdate_npc 等),则您的服务器正在工作并正确公开工具。

更新

在更新之前,请务必备份您的 dist/data 目录,以避免丢失您的内存数据。

故障排除

  • 服务器未出现在 Claude 中:

    • 仔细检查您的 claude_desktop_config.json 中的路径。确保它们是绝对路径并且正确。
    • 验证 dist 目录是否存在并包含已编译的 JavaScript 文件,包括 index.js
    • 检查 Claude Desktop 日志中是否有错误:
      • macOS: ~/Library/Logs/Claude/mcp-server-memorymesh.log(和 mcp.log
      • Windows:(可能在 %AppData%\Claude 下的 Logs 文件夹中)
  • 工具未显示:

    • 确保您的 npm run build 命令已完成且没有错误。
    • 验证您的 schema 文件是否正确放置在 dist/data/schemas 中,并遵循正确的命名约定 (add_[entity].schema.json)。
    • 检查服务器的控制台输出或日志中是否有初始化期间的任何错误。

高级配置

MemoryMesh 提供了几种方法来自定义其行为,而不仅仅是基本设置:

变量

您可以使用 /config/config.ts 中的变量覆盖默认设置

  • MEMORY_FILE:指定用于存储知识图谱数据的 JSON 文件的路径。(默认:dist/data/memory.json
  • SCHEMAS_DIR:schema 文件目录的路径。(默认:dist/data/schemas/memory.json

局限性

  1. 节点删除: AI 可能不愿从知识图谱中删除节点。如果需要,可以通过提示鼓励它。

贡献

欢迎贡献、反馈和想法! 该项目是对将结构化数据与 AI 推理能力相结合的个人探索。欢迎贡献、反馈和想法,以进一步推进它或激发新项目。

推荐服务器

VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
mult-fetch-mcp-server

mult-fetch-mcp-server

一个多功能的、符合 MCP 规范的网页内容抓取工具,支持多种模式(浏览器/Node)、格式(HTML/JSON/Markdown/文本)和智能代理检测,并提供双语界面(英语/中文)。

精选
本地
AIO-MCP Server

AIO-MCP Server

🚀 集成了 AI 搜索、RAG 和多服务(GitLab/Jira/Confluence/YouTube)的一体化 MCP 服务器,旨在增强 AI 驱动的开发工作流程。来自 Folk。

精选
本地
Knowledge Graph Memory Server

Knowledge Graph Memory Server

为 Claude 实现持久性记忆,使用本地知识图谱,允许 AI 记住用户的信息,并可在自定义位置存储,跨对话保持记忆。

精选
本地
Hyperbrowser

Hyperbrowser

欢迎来到 Hyperbrowser,人工智能的互联网。Hyperbrowser 是下一代平台,旨在增强人工智能代理的能力,并实现轻松、可扩展的浏览器自动化。它专为人工智能开发者打造,消除了本地基础设施和性能瓶颈带来的麻烦,让您能够:

精选
本地
https://github.com/Streen9/react-mcp

https://github.com/Streen9/react-mcp

react-mcp 与 Claude Desktop 集成,能够根据用户提示创建和修改 React 应用程序。

精选
本地
any-chat-completions-mcp

any-chat-completions-mcp

将 Claude 与任何 OpenAI SDK 兼容的聊天完成 API 集成 - OpenAI、Perplexity、Groq、xAI、PyroPrompts 等。

精选