mcp-knowledge-graph 标志

mcp-knowledge-graph

社区
shaneholloman

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

发布者shaneholloman
代码仓库mcp-knowledge-graph
语言JavaScript
复刻数
101
星标数
889
可用工具
10
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    mcp-knowledge-graph 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 10 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 889 个 Star 和 101 个 Fork。

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)

json
{
  "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:

json
{
  "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:

bash
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:

json
// 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:

tree
/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:

tree
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:

json
{
  "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):

json
{
  "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

安装

TypingMind
{
  "mcpServers": {
    "mcp-knowledge-graph": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-knowledge-graph",
        "--memory-path",
        "{{config.MEMORY_PATH}}"
      ]
    }
  }
}

可用工具

  • aim_memory_store

    Store new memories. Use this to remember people, projects, concepts, or any information worth persisting.

    AIM (AI Memory) provides persistent memory for AI assistants. The 'aim_memory_' prefix groups all memory tools together.

    WHAT'S STORED: Memories have a name, type (person/project/concept/etc.), and observations (facts about them).

    DATABASES: Use the 'context' parameter to organize memories into separate graphs:

    • Leave blank: Uses the master database (default for general information)
    • Any name: Creates/uses a named database ('work', 'personal', 'health', 'research', etc.)
    • New databases are created automatically - no setup required
    • IMPORTANT: Use consistent, simple names - prefer 'work' over 'work-stuff'

    STORAGE LOCATIONS: Files are stored as JSONL (e.g., memory.jsonl, memory-work.jsonl):

    • Project-local: .aim directory in project root (auto-detected if exists)
    • Global: User's configured --memory-path directory
    • Use 'location' parameter to override: 'project' or 'global'
  • aim_memory_link

    Link two memories together with a relationship. Use this to connect related information.

    RELATION STRUCTURE: Each link has 'from' (subject), 'relationType' (verb), and 'to' (object).

    • Use active voice verbs: "manages", "works_at", "knows", "attended", "created"
    • Read as: "from relationType to" (e.g., "Alice manages Q4_Project")
    • Avoid passive: use "manages" not "is_managed_by"

    IMPORTANT: Both 'from' and 'to' entities must already exist in the same database.

    RETURNS: Array of created relations (duplicates are ignored).

    DATABASE: Relations are created in the specified 'context' database, or master database if not specified.

    EXAMPLES:

    • aim_memory_link({relations: [{from: "John", to: "TechConf2024", relationType: "attended"}]})
    • aim_memory_link({context: "work", relations: [{from: "Alice", to: "Q4_Project", relationType: "manages"}]})
    • Multiple: aim_memory_link({relations: [{from: "John", to: "Alice", relationType: "knows"}, {from: "John", to: "Acme_Corp", relationType: "works_a
  • aim_memory_add_facts

    Add new facts to an existing memory. Use this to append information to something already stored.

    IMPORTANT: Memory must already exist - use aim_memory_store first. Throws error if not found.

    RETURNS: Array of {entityName, addedObservations} showing what was added (duplicates are ignored).

    DATABASE: Adds to entities in the specified 'context' database, or master database if not specified.

    EXAMPLES:

    • aim_memory_add_facts({observations: [{entityName: "John", contents: ["Lives in Seattle", "Works in tech"]}]})
    • aim_memory_add_facts({context: "work", observations: [{entityName: "Q4_Project", contents: ["Behind schedule", "Need more resources"]}]})
  • aim_memory_forget

    Forget memories. Removes memories and their associated links.

    DATABASE SELECTION: Entities are deleted from the specified database's knowledge graph.

    LOCATION OVERRIDE: Use the 'location' parameter to force deletion from 'project' (.aim directory) or 'global' (configured directory). Leave blank for auto-detection.

    EXAMPLES:

    • Master database (default): aim_memory_forget({entityNames: ["OldProject"]})
    • Work database: aim_memory_forget({context: "work", entityNames: ["CompletedTask", "CancelledMeeting"]})
    • Master database in global location: aim_memory_forget({location: "global", entityNames: ["OldProject"]})
    • Personal database in project location: aim_memory_forget({context: "personal", location: "project", entityNames: ["ExpiredReminder"]})
  • aim_memory_remove_facts

    Remove specific facts from a memory. Keeps the memory but removes selected observations.

    DATABASE SELECTION: Observations are deleted from entities within the specified database's knowledge graph.

    LOCATION OVERRIDE: Use the 'location' parameter to force deletion from 'project' (.aim directory) or 'global' (configured directory). Leave blank for auto-detection.

    EXAMPLES:

    • Master database (default): aim_memory_remove_facts({deletions: [{entityName: "John", observations: ["Outdated info"]}]})
    • Work database: aim_memory_remove_facts({context: "work", deletions: [{entityName: "Project", observations: ["Old deadline"]}]})
    • Master database in global location: aim_memory_remove_facts({location: "global", deletions: [{entityName: "John", observations: ["Outdated info"]}]})
    • Health database in project location: aim_memory_remove_facts({context: "health", location: "project", deletions: [{entityName: "Exercise", observations: ["Injured knee"]}]})
  • aim_memory_unlink

    Remove links between memories. Keeps the memories but removes their connections.

    DATABASE SELECTION: Relations are deleted from the specified database's knowledge graph.

    LOCATION OVERRIDE: Use the 'location' parameter to force deletion from 'project' (.aim directory) or 'global' (configured directory). Leave blank for auto-detection.

    EXAMPLES:

    • Master database (default): aim_memory_unlink({relations: [{from: "John", to: "OldCompany", relationType: "worked_at"}]})
    • Work database: aim_memory_unlink({context: "work", relations: [{from: "Alice", to: "CancelledProject", relationType: "manages"}]})
    • Master database in global location: aim_memory_unlink({location: "global", relations: [{from: "John", to: "OldCompany", relationType: "worked_at"}]})
    • Personal database in project location: aim_memory_unlink({context: "personal", location: "project", relations: [{from: "Me", to: "OldHobby", relationType: "enjoys"}]})
  • aim_memory_read_all

    Read all memories in a database. Returns every stored memory and their links.

    FORMAT OPTIONS:

    • "json" (default): Structured JSON for programmatic use
    • "pretty": Human-readable text format

    DATABASE: Reads from the specified 'context' database, or master database if not specified.

    EXAMPLES:

    • aim_memory_read_all({}) - JSON format
    • aim_memory_read_all({format: "pretty"}) - Human-readable
    • aim_memory_read_all({context: "work", format: "pretty"}) - Work database, pretty
  • aim_memory_search

    Search memories by keyword. Use this when you don't know the exact name of what you're looking for.

    WHAT IT SEARCHES: Matches query (case-insensitive) against:

    • Memory names (e.g., "John" matches "John_Smith")
    • Memory types (e.g., "person" matches all person memories)
    • Facts/observations (e.g., "Seattle" matches memories mentioning Seattle)

    VS aim_memory_get: Use aim_memory_search for fuzzy matching. Use aim_memory_get when you know exact names.

    FORMAT OPTIONS:

    • "json" (default): Structured JSON for programmatic use
    • "pretty": Human-readable text format

    EXAMPLES:

    • aim_memory_search({query: "John"}) - JSON format
    • aim_memory_search({query: "project", format: "pretty"}) - Human-readable
    • aim_memory_search({context: "work", query: "Shane", format: "pretty"})
  • aim_memory_get

    Retrieve specific memories by exact name. Use this when you know exactly what you're looking for.

    VS aim_memory_search: Use aim_memory_get for exact name lookup. Use aim_memory_search for fuzzy matching or when you don't know exact names.

    RETURNS: Requested entities and relations between them. Non-existent names are silently ignored.

    FORMAT OPTIONS:

    • "json" (default): Structured JSON for programmatic use
    • "pretty": Human-readable text format

    EXAMPLES:

    • aim_memory_get({names: ["John", "TechConf2024"]}) - JSON format
    • aim_memory_get({names: ["Shane"], format: "pretty"}) - Human-readable
    • aim_memory_get({context: "work", names: ["Q4_Project"], format: "pretty"})
  • aim_memory_list_stores

    List all available memory databases and show current storage location.

    DATABASE TYPES:

    • "default": The master database (memory.jsonl) - used when no context is specified
    • Named databases: Created via context parameter (e.g., "work" -> memory-work.jsonl)

    RETURNS: {project_databases: [...], global_databases: [...], current_location: "..."}

    • project_databases: Databases in .aim directory (if project detected)
    • global_databases: Databases in global --memory-path directory
    • current_location: Where operations will default to

    Use this to discover what databases exist before querying them.

    EXAMPLES:

    • aim_memory_list_stores() - Shows all available databases and current storage location

将 mcp-knowledge-graph MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 mcp-knowledge-graph 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 mcp-knowledge-graph 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 mcp-knowledge-graph MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "mcp-knowledge-graph": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-knowledge-graph"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 mcp-knowledge-graph MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 mcp-knowledge-graph MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 mcp-knowledge-graph 帮我完成这项任务吗?
mcp-knowledge-graph
当然。我已阅读。
以下是我使用 mcp-knowledge-graph 得到的结果。

常见问题

mcp-knowledge-graph MCP 服务器有什么用途?

mcp-knowledge-graph 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 mcp-knowledge-graph MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 mcp-knowledge-graph,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 mcp-knowledge-graph MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 mcp-knowledge-graph 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 mcp-knowledge-graph MCP 连接到 TypingMind?

mcp-knowledge-graph 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

mcp-knowledge-graph MCP 在 TypingMind 中提供哪些工具?

mcp-knowledge-graph 提供 10 个 MCP 工具,您可以在 TypingMind 的插件页面启用这些工具,然后在聊天中使用,或将其分配给 AI 智能体。

使用 mcp-knowledge-graph MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 mcp-knowledge-graph 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇