mcp-knowledge-graph

shanehollomanMIT更新放缓

给 Claude 加一个本地知识图谱记忆服务,通过 MCP 协议把对话中的实体和关系持久化到本地,解决 AI 跨会话记不住上下文的问题。

MCP server enabling persistent memory for Claude through a local knowledge graph - fork focused on local development

v1.3.2发布于 2025-12-22 21:49 UTC888star102fork同步于 2026-11-07 07:31 UTC

怎么上手

由 README 提炼,执行前请确认
mkdir .aim
npx -y mcp-knowledge-graph --memory-path /Users/yourusername/.aim
硬件要求按 README 说明

README 未说明,仅要求 Node.js 22+ 和兼容 MCP 的 AI 平台,无 GPU 或显存要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

给 Claude 等 MCP 客户端加持久记忆的本地知识图谱服务,用实体、关系和观察跨会话存取信息

给 Claude 加一个本地知识图谱记忆服务,通过 MCP 协议把对话中的实体和关系持久化到本地,解决 AI 跨会话记不住上下文的问题。

核心能力

  • 用实体、关系、观察三类元素构建本地知识图谱
  • 以 JSONL 文件存储,支持项目内 .aim 目录与全局目录
  • 按 context 参数拆分 work、personal 等多个命名数据库
  • 用 _aim 文件头标记防止误覆盖无关 JSONL 文件
  • 提供存储、加事实、关联、搜索、遗忘等十个 aim_ 工具

容易踩的坑

需 Node.js 22 及以上版本,低版本无法运行;项目内目录必须精确命名为 .aim 才会被识别为项目本地存储;手动创建的 JSONL 文件首行须有 _aim 安全标记,否则系统拒绝写入

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.3.2
  1. v1.3.2最新正式版2025-12-22 · 2025-12-22 21:49 UTC

    What's Changed

    Documentation Update

    The README now reflects the new aim_memory_* tool names and includes better configuration examples.

    Tool name updates:

    • All references updated from aim_* to aim_memory_* pattern
    • Clearer tool descriptions focused on memory operations

    Configuration examples:

    • Option 1: Default .aim directory (simple setup)
    • Option 2: Dropbox/cloud sync (portable across machines)
    • Note: The author uses Dropbox for his own memories

    Full Changelog: https://github.com/shaneholloman/mcp-knowledge-graph/compare/v1.3.1...v1.3.2

  2. v1.3.12025-12-22 · 2025-12-22 21:36 UTC
    查看更新说明

    What's Changed

    Bug Fixes

    • Fixed aim_memory_search and aim_memory_get descriptions that still referenced old tool names (open_nodes, search_nodes)

    Improved Descriptions

    Tool descriptions now use memory-friendly language instead of graph database jargon:

    BeforeAfter
    "Create multiple new entities in the knowledge graph""Store new memories"
    "Fuzzy search for entities in the knowledge graph""Search memories by keyword"
    "Delete multiple entities and their associated relations""Forget memories"
    "Create relations (edges) between entities""Link two memories together"

    This makes the tools more intuitive for both AI agents and human users.

    Full Changelog: https://github.com/shaneholloman/mcp-knowledge-graph/compare/v1.3.0...v1.3.1

  3. v1.3.02025-12-22 · 2025-12-22 21:18 UTC
    查看更新说明

    What's Changed

    Renamed Tools for Better AI Discoverability

    All tools now use the aim_memory_* naming pattern, making it immediately clear these are memory operations:

    Old NameNew Name
    aim_create_entitiesaim_memory_store
    aim_add_observationsaim_memory_add_facts
    aim_create_relationsaim_memory_link
    aim_search_nodesaim_memory_search
    aim_open_nodesaim_memory_get
    aim_read_graphaim_memory_read_all
    aim_delete_entitiesaim_memory_forget
    aim_delete_observationsaim_memory_remove_facts
    aim_delete_relationsaim_memory_unlink
    aim_list_databasesaim_memory_list_stores

    Why This Change?

    When an AI has many tools available and a user says "remember this", the tool name should make it obvious which tool to use. aim_memory_store is immediately recognizable as a memory operation, while aim_create_entities required reading the description.

    Compatibility

    No data format changes - existing .aim databases and memory files remain fully compatible.

    Full Changelog: https://github.com/shaneholloman/mcp-knowledge-graph/compare/v1.2.3...v1.3.0

  4. v1.2.32025-12-22 · 2025-12-22 20:52 UTC
    查看更新说明

    What's Changed

    New Feature: Pretty Output Format

    Query tools now support a format parameter for human-readable output:

    • aim_read_graph({format: "pretty"})
    • aim_search_nodes({query: "...", format: "pretty"})
    • aim_open_nodes({names: [...], format: "pretty"})

    Example pretty output:

    === work database ===
    
    ENTITIES (2):
      John [person]
        - Met at conference
        - Works in tech
      ProjectAlpha [project]
        - Due Q1 2025
    
    RELATIONS (1):
      John --works_on--> ProjectAlpha
    

    Use format: "json" (default) for programmatic use, format: "pretty" for human-readable output.

    Full Changelog: https://github.com/shaneholloman/mcp-knowledge-graph/compare/v1.2.2...v1.2.3

  5. v1.2.22025-12-22 · 2025-12-22 20:42 UTC
    查看更新说明

    What's Changed

    Improved Documentation

    • Added AIM (AI Memory) acronym expansion to tool descriptions
    • Clarified search_nodes vs open_nodes distinction
    • Documented what search_nodes matches (entity names, types, and observation content)
    • Explained active voice convention for relations with examples
    • Added RETURNS sections showing what each tool returns
    • Fixed context/database terminology consistency

    Bug Fixes

    • Added .aim as a project marker for detection (fixes #17)
      • Users no longer need .git or language-specific files
      • Simply creating a .aim folder is sufficient for project-local storage
    • Version now read from package.json instead of being hardcoded

    Full Changelog: https://github.com/shaneholloman/mcp-knowledge-graph/compare/v1.2.0...v1.2.2

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    MCP Knowledge Graph

    Persistent memory for AI models through a local knowledge graph.

    Store and retrieve information across conversations using entities, relations, and observations. Works with Claude Code/Desktop and any MCP-compatible AI platform.

    Why ".aim" and "aim_" prefixes?

    AIM stands for AI Memory - the core concept of this system. The three AIM elements provide clear organization and safety:

    • .aim directories: Keep AI memory files organized and easily identifiable
    • aim_ tool prefixes: Group related memory functions together in multi-tool setups
    • _aim safety markers: Each memory file starts with {"type":"_aim","source":"mcp-knowledge-graph"} to prevent accidental overwrites of unrelated JSONL files

    This consistent AIM naming makes it obvious which directories, tools, and files belong to the AI memory system.

    CRITICAL: Understanding .aim dir vs _aim file marker

    Two different things with similar names:

    • .aim = Project-local directory name (MUST be named exactly .aim for project detection to work)
    • _aim = File safety marker (appears inside JSONL files: {"type":"_aim","source":"mcp-knowledge-graph"})

    For project-local storage:

    • Directory MUST be named .aim in your project root
    • Example: my-project/.aim/memory.jsonl
    • The system specifically looks for this exact name

    For global storage (--memory-path):

    • Can be ANY directory you want
    • Examples: ~/yourusername/.aim/, ~/memories/, ~/Dropbox/ai-memory/, ~/Documents/ai-data/
    • Complete flexibility - choose whatever location works for you

    Storage Logic

    File Location Priority:

    1. Project with .aim - Uses .aim/memory.jsonl (project-local)
    2. No project/no .aim - Uses configured global directory
    3. Contexts - Adds suffix: memory-work.jsonl, memory-personal.jsonl

    Safety System:

    • Every memory file starts with {"type":"_aim","source":"mcp-knowledge-graph"}
    • System refuses to write to files without this marker
    • Prevents accidental overwrite of unrelated JSONL files

    Master Database Concept

    The master database is your primary memory store - used by default when no specific database is requested. It's always named default in listings and stored as memory.jsonl.

    • Default Behavior: All memory operations use the master database unless you specify a different one
    • Always Available: Exists in both project-local and global locations
    • Primary Storage: Your main knowledge graph that persists across all conversations
    • Named Databases: Optional additional databases (work, personal, health) for organizing specific topics

    Key Features

    • Master Database: Primary memory store used by default for all operations
    • Multiple Databases: Optional named databases for organizing memories by topic
    • Project Detection: Automatic project-local memory using .aim directories
    • Location Override: Force operations to use project or global storage
    • Safe Operations: Built-in protection against overwriting unrelated files
    • Database Discovery: List all available databases in both locations

    Quick Start

    Global Memory (Recommended)

    Add to your claude_desktop_config.json or .claude.json. Two common approaches:

    Option 1: Default .aim directory (simple)

    {
      "mcpServers": {
        "Aim-Memory-Bank": {
          "command": "npx",
          "args": [
            "-y",
            "mcp-knowledge-graph",
            "--memory-path",
            "/Users/yourusername/.aim"
          ]
        }
      }
    }
    

    Option 2: Dropbox/cloud sync (portable)

    For accessing memories across multiple machines, use a synced folder. This is how the author of this MCP server keeps his own memories:

    {
      "mcpServers": {
        "Aim-Memory-Bank": {
          "command": "npx",
          "args": [
            "-y",
            "mcp-knowledge-graph",
            "--memory-path",
            "/Users/yourusername/Dropbox/ai-memory"
          ]
        }
      }
    }
    

    This creates memory files in your specified directory:

    • memory.jsonl - Master Database (default for all operations)
    • memory-work.jsonl - Work database
    • memory-personal.jsonl - Personal database
    • etc.

    Project-Local Memory

    In any project, create a .aim directory:

    mkdir .aim
    

    Now memory tools automatically use .aim/memory.jsonl (project-local master database) instead of global storage when run from this project.

    How AI Uses Databases

    Once configured, AI models use the master database by default or can specify named databases with a context parameter. New databases are created automatically - no setup required:

    // Master Database (default - no context needed)
    aim_memory_store({
      entities: [{
        name: "John_Doe",
        entityType: "person",
        observations: ["Met at conference"]
      }]
    })
    
    // Work database
    aim_memory_store({
      context: "work",
      entities: [{
        name: "Q4_Project",
        entityType: "project",
        observations: ["Due December 2024"]
      }]
    })
    
    // Personal database
    aim_memory_store({
      context: "personal",
      entities: [{
        name: "Mom",
        entityType: "person",
        observations: ["Birthday March 15th"]
      }]
    })
    
    // Master database in specific location
    aim_memory_store({
      location: "global",
      entities: [{
        name: "Important_Info",
        entityType: "reference",
        observations: ["Stored in global master database"]
      }]
    })
    

    File Organization

    Global Setup:

    /Users/yourusername/.aim/
    ├── memory.jsonl           # Master Database (default)
    ├── memory-work.jsonl      # Work database
    ├── memory-personal.jsonl  # Personal database
    └── memory-health.jsonl    # Health database
    

    Project Setup:

    my-project/
    ├── .aim/
    │   ├── memory.jsonl       # Project Master Database (default)
    │   └── memory-work.jsonl  # Project Work database
    └── src/
    

    Available Tools

    • aim_memory_store - Store new memories (people, projects, concepts)
    • aim_memory_add_facts - Add facts to existing memories
    • aim_memory_link - Link two memories together
    • aim_memory_search - Search memories by keyword
    • aim_memory_get - Retrieve specific memories by exact name
    • aim_memory_read_all - Read all memories in a database
    • aim_memory_list_stores - List available databases
    • aim_memory_forget - Forget memories
    • aim_memory_remove_facts - Remove specific facts from a memory
    • aim_memory_unlink - Remove links between memories

    Parameters

    • context (optional) - Specify named database (work, personal, etc.). Defaults to master database
    • location (optional) - Force project or global storage location. Defaults to auto-detection

    Database Discovery

    Use aim_memory_list_stores to see all available databases:

    {
      "project_databases": [
        "default",      // Master Database (project-local)
        "project-work"  // Named database
      ],
      "global_databases": [
        "default",      // Master Database (global)
        "work",
        "personal",
        "health"
      ],
      "current_location": "project (.aim directory detected)"
    }
    

    Key Points:

    • "default" = Master Database in both locations
    • Current location shows whether you're using project or global storage
    • Master database exists everywhere - it's your primary memory store
    • Named databases are optional additions for specific topics

    Configuration Examples

    Important: Always specify --memory-path to control where your memory files are stored.

    Auto-approve read operations (recommended):

    {
      "mcpServers": {
        "Aim-Memory-Bank": {
          "command": "npx",
          "args": [
            "-y",
            "mcp-knowledge-graph",
            "--memory-path",
            "/Users/yourusername/.aim"
          ],
          "autoapprove": [
            "aim_memory_search",
            "aim_memory_get",
            "aim_memory_read_all",
            "aim_memory_list_stores"
          ]
        }
      }
    }
    

    Troubleshooting

    "File does not contain required _aim safety marker" error:

    • The file may not belong to this system
    • Manual JSONL files need {"type":"_aim","source":"mcp-knowledge-graph"} as first line
    • If you created the file manually, add the _aim marker or delete and let the system recreate it

    Memories going to unexpected locations:

    • Check if you're in a project directory with .aim folder (uses project-local storage)
    • Otherwise uses the configured global --memory-path directory
    • Use aim_memory_list_stores to see all available databases and current location
    • Use ls .aim/ or ls /Users/yourusername/.aim/ to see your memory files

    Too many similar databases:

    • AI models try to use consistent names, but may create variations
    • Manually delete unwanted database files if needed
    • Encourage AI to use simple, consistent database names
    • Remember: Master database is always available as the default - named databases are optional

    Requirements

    • Node.js 22+
    • MCP-compatible AI platform

    License

    MIT