Skip to main content
Glama

记忆网格

发布 铁匠徽章 TypeScript 许可证:MIT GitHub 星数

MemoryMesh 是一款专为 AI 模型设计的知识图谱服务器,专注于基于文本的角色扮演游戏 (RPG) 和交互式故事叙述。它帮助 AI 在对话过程中保持一致的结构化记忆,从而实现更丰富、更动态的交互。

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

重要的

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

Related MCP server: ainative-memory-mcp

快速链接

概述

MemoryMesh 是一个本地知识图谱服务器,可帮助您构建和管理 AI 模型的结构化信息。它尤其适用于基于文本的角色扮演游戏 (RPG),但其灵活的设计使其适用于各种应用,包括社交网络模拟、组织规划或任何涉及结构化数据的场景。

主要特点

  • **基于动态模式的工具:**使用模式定义数据结构,MemoryMesh 会自动生成用于添加、更新和删除数据的工具。

  • **直观的模式设计:**使用必填字段、枚举类型和关系定义创建指导 AI 生成和连接节点的模式。

  • **用于 AI 指导的元数据:**使用元数据提供上下文和结构,帮助 AI 理解数据中的含义和关系。

  • **关系处理:**在您的模式中定义关系以鼓励 AI 在相关数据点(节点)之间创建连接(边)。

  • **信息反馈:**向人工智能提供错误反馈,使其能够从错误中学习并改善其与知识图谱的交互。

  • **事件支持:**事件系统跟踪操作,提供有关知识图如何被修改的见解。

节点

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

  • name :唯一标识符。

  • nodeType :节点的类型(例如, npc 、 artifact 、 location ),由您的模式定义。

  • 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 :关系的类型(例如, owns 、 located_in )。

{
  "from": "Aragorn",
  "to": "Andúril",
  "edgeType": "owns"
}

模式

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

架构文件位置

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

模式结构

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

  • name - 内存中模式和节点类型的标识符。重要提示:模式名称必须以add_开头才能被识别。

  • description - 用于add_<name>工具的描述,为 AI 提供上下文。 ( delete和update工具有通用描述)

  • properties ——每个属性包括其类型、描述和附加约束。

    • property

      • type - 支持的值是string或array 。

      • description - 帮助指导 AI 实现实体的目的。

      • required - 布尔值。如果为true ,则AI 在创建节点时必须提供此属性。

      • enum - 字符串数组。如果存在, AI 必须从给定的选项中选择一个。

      • relationship - 定义与另一个节点的连接。如果某个属性是必需的且具有关系,则AI 将始终创建该节点及其对应的边。

        • edgeType - 要创建的关系类型。

        • description ——帮助引导 AI 了解关系的目的。

  • additionalProperties - 布尔值。如果为true ,则允许 AI 添加除必需或可选属性之外的额外属性。

示例架构(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
}

基于此模式,MemoryMesh 自动创建:

  • add_npc:添加新的NPC节点。

  • update_npc:修改现有的NPC节点。

  • delete_npc:删除NPC节点。

MemoryMesh 包含 11 个专为基于文本的 RPG 设计的预建模式,为游戏开发提供了可立即使用的基础。

SchemaManager工具

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

动态工具

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

**可以这样想:**您提供一个蓝图(模式),MemoryMesh 会根据该蓝图自动构建必要的工具来构建、修改和删除元素。

幕后是如何运作的?

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

  • **add_<entity> :**用于创建实体新实例的工具。

  • **update_<entity> :**用于修改现有实体的工具。

  • **delete_<entity> :**用于删除实体的工具。

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

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

内存文件

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

内存查看器

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

主要特点:
  • 图形可视化:将知识图谱视为交互式节点链接图。

  • 节点检查:选择节点以查看其节点类型、元数据和连接边。

  • 边缘探索:检查节点之间的关系,包括边缘类型和方向。

  • 搜索和过滤:快速查找特定节点或按类型过滤它们。

  • 表格视图:允许您轻松查找和检查特定节点和边,或一次查找和检查所有节点和边。

  • 原始 JSON 视图:允许您查看来自内存文件的原始 JSON 数据。

  • 统计面板:提供有关知识图谱的关键指标和信息:节点总数、边总数、节点类型和边类型。

  • 搜索和过滤:允许您按节点类型或边类型进行过滤,并过滤是否显示节点、边或两者。

访问内存查看器

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

使用内存查看器
  • 选择内存文件:在内存查看器中,单击“选择内存文件”按钮。

  • 选择文件:导航到您的 MemoryMesh 项目目录并选择memory.json文件(默认位于dist/data/memory.json )。

  • 探索:内存查看器将加载并显示您的知识图谱的内容。

记忆流

图像

迅速的

为了获得最佳效果,请结合使用 Claude 的“项目”功能和自定义指令。以下是您可以参考的提示示例:

You are a helpful AI assistant managing a knowledge graph for a text-based RPG. You have access to the following tools: add_npc, update_npc, delete_npc, add_location, update_location, delete_location, and other tools for managing the game world.

When the user provides input, first process it using your available tools to update the knowledge graph. Then, respond in a way that is appropriate for a text-based RPG.

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

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

例子

  1. 带有自定义指令的简单示例。

  2. 为了举例说明,并带有可视化功能(不属于功能的一部分)

添加几个城市、一些 NPC、城市周围几个可供探索的地点,在某处隐藏一两件文物

图像

安装

通过 Smithery 安装

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

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

先决条件

  • **Node.js:**版本 18 或更高版本。您可以从nodejs.org下载。

  • **npm:**通常包含在 Node.js 中。

  • **桌面版 Claude:**确保您已从claude.ai/download安装了最新版本。

安装步骤

  1. 克隆存储库:

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

    npm install
  3. 构建项目:

    npm run build

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

  4. 验证文件副本(可选):

    • 构建过程应自动将data文件夹复制到dist 。

    • 检查dist/data是否存在且包含.json文件。同时,验证dist/data/schemas是否存在且包含.schema.json文件。

  5. 配置Claude桌面:

    打开您的 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 插件图标。如果找到,则说明您的配置很可能正确。

  4. 点击图标。你应该会在已连接的服务器列表中看到“memorymesh”。

  5. 点击图标。如果你看到列出的工具(例如add_npc 、 update_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命令顺利完成。

    • 验证您的模式文件是否正确放置在dist/data/schemas中并遵循正确的命名约定( add_[entity].schema.json )。

    • 检查服务器的控制台输出或日志,查看初始化期间是否存在任何错误。

高级配置

除了基本设置之外,MemoryMesh 还提供了几种自定义其行为的方法:

变量

您可以使用/config/config.ts覆盖默认设置

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

  • SCHEMAS_DIR:架构文件目录的路径。(默认值: dist/data/schemas/memory.json )

限制

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

贡献

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

Available Tools

17 tools
add_edgesB

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

Inputs: edges (required).

add_locationB

Add a new location (a city, building, room, region...) to the knowledge graph

Inputs: location (required).

add_metadataB
Idempotent

Add new metadata to existing nodes in the knowledge graph

Inputs: metadata (required).

add_nodesC

Add multiple new nodes in the knowledge graph

Inputs: nodes (required).

add_npcC

Add a new character (NPC) to the knowledge graph

Inputs: npc (required).

delete_edgesC
DestructiveIdempotent

Delete multiple edges from the knowledge graph

Inputs: edges (required).

delete_locationC
DestructiveIdempotent

Delete an existing location from the knowledge graph

Inputs: delete_location (required).

delete_metadataC
DestructiveIdempotent

Delete specific metadata from nodes in the knowledge graph

Inputs: deletions (required).

delete_nodesA
DestructiveIdempotent

Delete multiple nodes and their associated edges from the knowledge graph

Inputs: nodeNames (required).

delete_npcC
DestructiveIdempotent

Delete an existing npc from the knowledge graph

Inputs: delete_npc (required).

open_nodesC
Read-only

Open specific nodes in the knowledge graph by their names

Inputs: names (required).

read_graphA
Read-only

Read the entire knowledge graph. On a large graph, prefer search_nodes or open_nodes to fetch only what is needed

Inputs: no named parameters.

search_nodesA
Read-only

Search for nodes in the knowledge graph. Returns the nodes that contain every word of the query in their name, type or metadata, plus their direct neighbours

Inputs: query (required).

update_edgesC
DestructiveIdempotent

Update existing edges in the knowledge graph

Inputs: edges (required).

update_locationC
DestructiveIdempotent

Update an existing location in the knowledge graph

Inputs: update_location (required).

update_nodesA
DestructiveIdempotent

Update existing nodes in the knowledge graph: rename them, change their type, or replace their metadata. Only the fields you pass are changed

Inputs: nodes (required).

update_npcC
DestructiveIdempotent

Update an existing npc in the knowledge graph

Inputs: update_npc (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 17 tools

    Disambiguation3/5

    Most tools target distinct resources, but the generic node tools overlap with the typed entity tools: add_nodes/update_nodes/delete_nodes can create or remove anything add_location, add_npc, add_edges evidently cover, and metadata can be replaced via update_nodes or mutated via add_metadata/delete_metadata. read_graph vs search_nodes vs open_nodes are reasonably distinct thanks to explicit guidance. The agent can mostly cope, but the node-vs-entity boundary is genuinely blurry.

    Naming Consistency4/5

    Nearly everything follows a clean verb_noun snake_case pattern (add_edges, update_location, delete_npc). Minor deviations: nouns are plural for nodes/edges but singular for npc, and read_graph/search_nodes/open_nodes mix verb styles (read/search/open) for the same read family. Still highly predictable overall.

    Tool Count4/5

    17 tools is slightly above the sweet spot but each earns a place given five resource families (nodes, edges, metadata, locations, NPCs) that each need create/update/delete. Nothing feels redundant enough to cut, though the typed-entity triples inflate the count.

    Completeness4/5

    Core lifecycle coverage exists for nodes (add/update/delete/read/search), edges (add/update/delete), metadata (add/delete), locations and NPCs (add/update/delete). Gaps are minor: no update_metadata convenience, no way to list or search edges independently, and no bulk-clear/graph-delete operation. Agents can work around these via read_graph and update_nodes metadata replacement.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      An enhanced fork of the official MCP memory server that enables persistent knowledge graph storage with automatic timestamps, tags, importance levels, date range search, comprehensive statistics, and multi-format export (JSON, CSV, GraphML).
      241
      44 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      A universal MCP server providing persistent, structured memory through a knowledge graph with graph storage, semantic vector search, and multi-hop traversal for AI agents and IDEs.
      37 PyPI
      1
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      Knowledge-graph memory server for MCP-compatible AI tools, providing persistent, connected memory with typed relationships and auto-consolidation.
      MIT