Skip to main content
Glama

许可证:AGPL v3 PyPI 版本 Python 3.12+ 测试 拉夫 铁匠徽章

基本记忆

基本记忆 (Basic Memory) 可让您通过与 Claude 等大型语言模型 (LLM) 进行自然对话来构建持久知识,同时将所有内容保存在计算机上的简单 Markdown 文件中。它使用模型上下文协议 (MCP),使任何兼容的 LLM 都能读取和写入您的本地知识库。

从上次中断的地方继续对话

  • AI 助手可以在新对话中从本地文件加载上下文

  • 笔记实时保存为本地 Markdown 文件

  • 无需项目知识或特殊提示

https://github.com/user-attachments/assets/a55d8238-8dd0-454a-be4c-8860dbbd0ddc

Related MCP server: memora

快速入门

# Install with uv (recommended)
uv tool install basic-memory

# Configure Claude Desktop (edit ~/Library/Application Support/Claude/claude_desktop_config.json)
# Add this to your config:
{
  "mcpServers": {
    "basic-memory": {
      "command": "uvx",
      "args": [
        "basic-memory",
        "mcp"
      ]
    }
  }
}
# Now in Claude Desktop, you can:
# - Write notes with "Create a note about coffee brewing methods"
# - Read notes with "What do I know about pour over coffee?"
# - Search with "Find information about Ethiopian beans"

您可以通过~/basic-memory (默认目录位置)中的文件查看共享上下文。

通过 Smithery 进行替代安装

您可以使用Smithery为 Claude Desktop 自动配置基本内存:

npx -y @smithery/cli install @basicmachines-co/basic-memory --client claude

这将安装并配置 Basic Memory,无需手动编辑 Claude Desktop 配置文件。Smithery 服务器托管 MCP 服务器组件,而您的数据仍以 Markdown 文件的形式存储在本地。

Glama.ai

为什么是基本记忆?

大多数LLM互动都是短暂的——你提出一个问题,得到一个答案,然后一切都被遗忘了。每次对话都是全新的,没有之前对话的背景或知识。目前的解决方法存在局限性:

  • 聊天记录记录了对话,但不是结构化的知识

  • RAG 系统可以查询文档,但不允许 LLM 写回

  • 矢量数据库需要复杂的设置,并且通常位于云端

  • 知识图谱通常需要专门的工具来维护

Basic Memory 用一种简单的方法解决了这些问题:结构化的 Markdown 文件,人类和 LLM 都可以读写。其主要优势如下:

  • **本地优先:**所有知识都保留在你控制的文件中

  • **双向:**您和 LLM 都可以读取和写入相同的文件

  • **结构化且简单:**使用熟悉的 Markdown 和语义模式

  • 可遍历知识图谱: LLM 可以追踪主题之间的链接

  • **标准格式:**可与 Obsidian 等现有编辑器配合使用

  • **轻量级基础设施:**仅在本地 SQLite 数据库中索引的本地文件

使用基本记忆,您可以:

  • 进行基于先前知识的对话

  • 在自然对话中创建结构化笔记

  • 与法学硕士进行对话,让他们记住你之前讨论过的内容

  • 语义导航你的知识图谱

  • 让一切都保持本地化并处于您的控制之下

  • 使用熟悉的工具(如 Obsidian)查看和编辑笔记

  • 建立随时间增长的个人知识库

实践操作

假设你正在探索咖啡冲泡方法,并想记录你的知识。具体操作如下:

  1. 开始正常聊天:

I've been experimenting with different coffee brewing methods. Key things I've learned:

- Pour over gives more clarity in flavor than French press
- Water temperature is critical - around 205°F seems best
- Freshly ground beans make a huge difference

...继续对话。

  1. 请法学硕士 (LLM) 帮助构建这些知识:

"Let's write a note about coffee brewing methods."

LLM 在您的系统上创建一个新的 Markdown 文件(您可以在 Obsidian 或编辑器中立即看到它):

---
title: Coffee Brewing Methods
permalink: coffee-brewing-methods
tags:
- coffee
- brewing
---

# Coffee Brewing Methods

## Observations

- [method] Pour over provides more clarity and highlights subtle flavors
- [technique] Water temperature at 205°F (96°C) extracts optimal compounds
- [principle] Freshly ground beans preserve aromatics and flavor

## Relations

- relates_to [[Coffee Bean Origins]]
- requires [[Proper Grinding Technique]]
- affects [[Flavor Extraction]]

该笔记通过简单的 Markdown 格式嵌入语义内容并链接到其他主题。

  1. 您可以在计算机上的当前项目目录(默认~/$HOME/basic-memory )中实时看到此文件。

  • 从 v0.12.0 版本开始,实时同步默认启用

  1. 在与LLM聊天时,你可以参考一个话题:

Look at `coffee-brewing-methods` for context about pour over coffee

LLM 现在可以从知识图谱中构建丰富的上下文。例如:

Following relation 'relates_to [[Coffee Bean Origins]]':
- Found information about Ethiopian Yirgacheffe
- Notes on Colombian beans' nutty profile
- Altitude effects on bean characteristics

Following relation 'requires [[Proper Grinding Technique]]':
- Burr vs. blade grinder comparisons
- Grind size recommendations for different methods
- Impact of consistent particle size on extraction

每个相关文档都可以提供更多的背景信息,从而为您的知识库构建丰富的语义理解。

这会形成双向流动:

  • 人类编写和编辑 Markdown 文件

  • LLM通过MCP协议进行读写

  • 同步使一切保持一致

  • 所有知识都保存在本地文件中。

技术实现

基本内存的底层:

  1. 将所有内容存储在 Markdown 文件中

  2. 使用 SQLite 数据库进行搜索和索引

  3. 从简单的 Markdown 模式中提取语义

    • 文件成为Entity对象

    • 每个Entity可以有与其相关的Observations或事实

    • Relations将实体连接在一起形成知识图谱

  4. 维护从文件中提取的本地知识图谱

  5. 提供文件和知识图谱之间的双向同步

  6. 实现用于 AI 集成的模型上下文协议 (MCP)

  7. 公开允许人工智能助手遍历和操作知识图谱的工具

  8. 使用memory:// URL来跨工具和对话引用实体

文件格式只是带有一些简单标记的 Markdown:

每个 Markdown 文件都有:

前言

title: <Entity title>
type: <The type of Entity> (e.g. note)
permalink: <a uri slug>

- <optional metadata> (such as tags) 

观察

观察是关于某个主题的事实。它们可以通过创建 Markdown 列表来添加,该列表具有特殊的格式,可以引用category 、使用“#”字符的tags以及可选的context 。

观察 Markdown 格式:

- [category] content #tag (optional context)

观察示例:

- [method] Pour over extracts more floral notes than French press
- [tip] Grind size should be medium-fine for pour over #brewing
- [preference] Ethiopian beans have bright, fruity flavors (especially from Yirgacheffe)
- [fact] Lighter roasts generally contain more caffeine than dark roasts
- [experiment] Tried 1:15 coffee-to-water ratio with good results
- [resource] James Hoffman's V60 technique on YouTube is excellent
- [question] Does water temperature affect extraction of different compounds differently?
- [note] My favorite local shop uses a 30-second bloom time

关系

关系是指向其他主题的链接。它们定义了实体在知识图谱中的连接方式。

Markdown 格式:

- relation_type [[WikiLink]] (optional context)

关系示例:

- pairs_well_with [[Chocolate Desserts]]
- grown_in [[Ethiopia]]
- contrasts_with [[Tea Brewing Methods]]
- requires [[Burr Grinder]]
- improves_with [[Fresh Beans]]
- relates_to [[Morning Routine]]
- inspired_by [[Japanese Coffee Culture]]
- documented_in [[Coffee Journal]]

与 VS Code 一起使用

对于一键安装,请单击下面的安装按钮之一...

在 VS Code 中使用 UV 安装 在 VS Code Insiders 中使用 UV 安装

您可以将 Basic Memory 与 VS Code 结合使用,以便在编码时轻松检索和存储信息。点击上方的安装按钮进行一键安装,或按照下方的手动安装说明进行操作。

手动安装

将以下 JSON 块添加到 VS Code 中的“用户设置 (JSON)”文件中。您可以按下Ctrl + Shift + P并输入Preferences: Open User Settings (JSON)来执行此操作。

{
  "mcp": {
    "servers": {
      "basic-memory": {
        "command": "uvx",
        "args": ["basic-memory", "mcp"]
      }
    }
  }
}

或者,您可以将其添加到工作区中名为.vscode/mcp.json的文件中。这样您就可以与其他人共享该配置。

{
  "servers": {
    "basic-memory": {
      "command": "uvx",
      "args": ["basic-memory", "mcp"]
    }
  }
}

与 Claude Desktop 一起使用

基本内存是使用 MCP(模型上下文协议)构建的,并与 Claude 桌面应用程序( https://claude.ai/ )配合使用:

  1. 配置 Claude Desktop 使用基本内存:

编辑您的 MCP 配置文件(对于 OS X,通常位于~/Library/Application Support/Claude/claude_desktop_config.json ):

{
  "mcpServers": {
    "basic-memory": {
      "command": "uvx",
      "args": [
        "basic-memory",
        "mcp"
      ]
    }
  }
}

如果您想使用特定项目(请参阅多个项目),请更新您的 Claude Desktop 配置:

{
  "mcpServers": {
    "basic-memory": {
      "command": "uvx",
      "args": [
        "basic-memory",
        "--project",
        "your-project-name",
        "mcp"
      ]
    }
  }
}
  1. 同步您的知识:

如果您进行手动编辑,基本内存将实时同步项目中的文件。

  1. 在 Claude Desktop 中,法学硕士现在可以使用以下工具:

write_note(title, content, folder, tags) - Create or update notes
read_note(identifier, page, page_size) - Read notes by title or permalink
build_context(url, depth, timeframe) - Navigate knowledge graph via memory:// URLs
search_notes(query, page, page_size) - Search across your knowledge base
recent_activity(type, depth, timeframe) - Find recently updated information
canvas(nodes, edges, title, folder) - Generate knowledge visualizations
  1. 尝试的示例提示:

"Create a note about our project architecture decisions"
"Find information about JWT authentication in my notes"
"Create a canvas visualization of my project components"
"Read my notes on the authentication system"
"What have I been working on in the past week?"

更多信息

请参阅文档以了解更多信息,包括:

执照

AGPL-3.0

欢迎贡献。请参阅贡献指南,了解如何在本地设置项目并提交 PR。

星史

由 Basic Machines 倾情打造

Available Tools

12 tools
bm_contextBuild contextA
Read-onlyIdempotent

Follow the Basic Memory knowledge graph from a note: the note, its observations, and the notes its relations reach, up to depth hops (1-5). identifier is a path, permalink, memory:// URL, or a pattern such as 'specs/*'. since limits related results to recent changes. compact returns the graph without note bodies; read chosen notes with bm_read.

Inputs: project (required), identifier (required), page, depth, +5 more. Returns: result

bm_deleteDelete noteA
DestructiveIdempotent

Delete a Basic Memory note (identifier) or a directory (path). A directory delete removes every file under it and needs recursive=true. Pass expected_checksum (from bm_read) to delete a note only if it is still the revision you read. A note that does not exist is an error. This cannot be undone.

Inputs: project (required), path, recursive, identifier, +2 more. Returns: result

bm_editEdit noteA
Destructive

Change part of an existing Basic Memory note. command: append or prepend content; find_replace find_text with content (exact text, which must occur expected_replacements times, default 1); replace_section, insert_before_section or insert_after_section for a section heading ('Decisions', 'Auth/Decisions', 'Decisions[1]', as bm_read takes it); set_metadata to merge metadata into the frontmatter without touching the body. metadata also merges with any other command. Pass expected_checksum (from bm_read) to edit only the revision you read. A missing note is an error; create notes with bm_write.

Inputs: command (required), project (required), identifier (required), content, +7 more. Returns: result

bm_findFind filesA
Read-onlyIdempotent

Find files in a Basic Memory project, recursively. With name, match file names against a glob ('meeting'). With filters, match notes by frontmatter, e.g. {"status": "active"} or {"priority": {"$in": ["high"]}}, and with fields return just those frontmatter values per note. path limits the search to a folder. For ranked text or meaning search, use bm_search.

Inputs: project (required), name, page, path, +5 more. Returns: result

bm_listList folderA
Read-onlyIdempotent

List one folder of a Basic Memory project: its subfolders, then its files with title, date and id. project is required; '/' lists its root. Discover projects with bm_project(command='list'). Filter files with glob and order them with sort. For a recursive search by name or frontmatter, use bm_find.

Inputs: project (required), glob, page, path, +3 more. Returns: result

bm_manManualA
Read-onlyIdempotent

Read the Basic Memory manual. With no arguments, the index of every page. page reads one page: 'bm-search(3)' for an MCP tool, 'grep(1)' for a shell command; a tool name such as 'bm_search' works too. query lists the pages that mention every word given, like man -k.

Inputs: page, query, output_format. Returns: result

bm_moveMove noteA

Move or rename a Basic Memory note (identifier) or a directory (path) within its project. destination is the new project-relative path; ending it with '/' moves into that folder under the current name ('archive/'). A note keeps its file extension ('.markdown' may become '.md'). Pass expected_checksum (from bm_read) to move a note only if it is still the revision you read. Moving into another project is refused: bm_read, bm_write there, then bm_delete.

Inputs: project (required), destination (required), path, identifier, +2 more. Returns: result

bm_projectProjectsB

Basic Memory projects. command: list (projects, grouped by workspace); create (name, path, optional set_default, workspace); recent (what changed lately in the required project: since, items, paging).

Inputs: command (required), name, page, path, +7 more. Returns: result

bm_readRead noteA
Read-onlyIdempotent

Read a Basic Memory note or file by path, permalink, memory:// URL or exact title. Slice a long note with section (a heading), start_line/end_line or max_tokens; line numbers count the whole file, frontmatter included. A text file such as .txt takes start_line/end_line too. include_content=false returns only the metadata and the checksum that bm_write and bm_edit take as expected_checksum. Images come back as images and other binary files as documents. A missing note is an error: find notes with bm_search.

Inputs: project (required), identifier (required), section, end_line, +5 more.

bm_schemaNote schemasA
Read-onlyIdempotent

Basic Memory note schemas (Picoschema). command: validate notes against their schema (one note_type, one note by identifier, or every type that has a schema); infer a schema from the notes of a note_type; diff a note_type's notes against its schema to find drift. A schema is a note with type: schema whose entity field names the note type it describes.

Inputs: command (required), project (required), note_type, threshold, +2 more. Returns: result

bm_writeWrite noteA
Destructive

Create or replace a Basic Memory note. Give a file path as identifier ('notes/plan.md'), or title plus directory. With a path the file lands exactly there and the title comes from the content's frontmatter, then title, then the file name. An existing note is an error unless overwrite=true; pass expected_checksum (from bm_read) to replace only the revision you read. To change part of a note use bm_edit. Content may hold frontmatter, observations ('- [category] fact #tag') and relations ('- relation_type [[Other Note]]').

Inputs: content (required), project (required), tags, title, +7 more. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 12 tools

    Disambiguation4/5

    There is real overlap among three retrieval tools (bm_find, bm_list, bm_search), but the descriptions explicitly route the agent: bm_list for one folder, bm_find for recursive name/frontmatter matching, bm_search for ranked text/semantic search. Similarly bm_read (one note body) is distinguished from bm_context (graph traversal) and bm_write (full replace) from bm_edit (partial change). Only a small chance of misselection remains for an agent skimming names.

    Naming Consistency4/5

    All 12 tools follow a single predictable bm_<word> snake_case pattern with no style mixing. Most suffixes are verbs (find, list, read, write, edit, move, delete, search), but a few are nouns/commands (bm_context, bm_schema, bm_project, bm_man), which is a minor deviation rather than an inconsistency.

    Tool Count5/5

    Twelve tools sit comfortably in the well-scoped range and each maps to a distinct capability: directory listing, find, search, read, write, edit, move, delete, graph context, schema ops, project ops, and docs. None look like padding, and the surface is not so thin that agents would have to chain workarounds.

    Completeness4/5

    Note lifecycle is fully covered (create/replace, read, partial edit, move, delete, plus graph context and search), and bm_schema and bm_project cover schema and project management. Minor gaps: bm_project only supports list/create/recent (no rename or delete of projects), and there is no copy/duplicate operation, though the description notes the read+write+delete workaround.

    Maintenance

    ActivityActive
    ResponsivenessSyncing

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      F
      maintenance
      Provides persistent memory functionality for AI conversations by creating, managing and querying entities and relationships in a knowledge graph. Features SQLite storage, advanced search capabilities, and Windows auto-start integration for long-term AI memory retention.
      34 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides persistent memory for AI tools by building a local knowledge graph from conversations, enabling cross-session recall and context awareness without cloud dependencies.
      9
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to share persistent, self-improving memory by ingesting, classifying, synthesizing, and retrieving knowledge from Obsidian vaults, code, documents, transcripts, bookmarks, and sessions through MCP and REST interfaces with token-optimized search.
      10 npm
      MIT